mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add new methods and refactor APIs. Needed later for new classes....
This commit is contained in:
parent
7122ef0356
commit
df90b2440a
1 changed files with 8 additions and 3 deletions
|
@ -77,12 +77,17 @@ public class Storage<T extends PersistableEnvelope> {
|
||||||
this.corruptedDatabaseFilesHandler = corruptedDatabaseFilesHandler;
|
this.corruptedDatabaseFilesHandler = corruptedDatabaseFilesHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public T getPersisted(String fileName) {
|
||||||
|
return getPersisted(new File(dir, fileName));
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public T initAndGetPersistedWithFileName(String fileName, long delay) {
|
public T initAndGetPersistedWithFileName(String fileName, long delay) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
storageFile = new File(dir, fileName);
|
storageFile = new File(dir, fileName);
|
||||||
fileManager = new FileManager<>(dir, storageFile, delay, persistenceProtoResolver);
|
fileManager = new FileManager<>(dir, storageFile, delay, persistenceProtoResolver);
|
||||||
return getPersisted();
|
return getPersisted(storageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -96,7 +101,7 @@ public class Storage<T extends PersistableEnvelope> {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
storageFile = new File(dir, fileName);
|
storageFile = new File(dir, fileName);
|
||||||
fileManager = new FileManager<>(dir, storageFile, delay, persistenceProtoResolver);
|
fileManager = new FileManager<>(dir, storageFile, delay, persistenceProtoResolver);
|
||||||
return getPersisted();
|
return getPersisted(storageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queueUpForSave() {
|
public void queueUpForSave() {
|
||||||
|
@ -144,7 +149,7 @@ public class Storage<T extends PersistableEnvelope> {
|
||||||
// We do the file read on the UI thread to avoid problems from multi threading.
|
// We do the file read on the UI thread to avoid problems from multi threading.
|
||||||
// Data are small and read is done only at startup, so it is no performance issue.
|
// Data are small and read is done only at startup, so it is no performance issue.
|
||||||
@Nullable
|
@Nullable
|
||||||
private T getPersisted() {
|
private T getPersisted(File storageFile) {
|
||||||
if (storageFile.exists()) {
|
if (storageFile.exists()) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue