mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Do not use persistNow for snapshots but requestPersistence
This avoids frequent write at dao sync and better performance.
This commit is contained in:
parent
f9f33aa16d
commit
d18b243322
2 changed files with 9 additions and 9 deletions
|
@ -94,12 +94,10 @@ public class DaoStateSnapshotService {
|
|||
long ts = System.currentTimeMillis();
|
||||
if (daoStateSnapshotCandidate != null) {
|
||||
// Serialisation happens on the userThread so we do not need to clone the data. Write to disk happens
|
||||
// in a thread but does not interfere with out objects as they got already serialized when passed to the
|
||||
// write thread.
|
||||
daoStateStorageService.persistNow(daoStateSnapshotCandidate,
|
||||
daoStateHashChainSnapshotCandidate,
|
||||
() -> {
|
||||
});
|
||||
// in a thread but does not interfere with our objects as they got already serialized when passed to the
|
||||
// write thread. We use requestPersistence so we do not write immediately but at next scheduled interval.
|
||||
// This avoids frequent write at dao sync and better performance.
|
||||
daoStateStorageService.requestPersistence(daoStateSnapshotCandidate, daoStateHashChainSnapshotCandidate);
|
||||
log.info("Serializing snapshotCandidate for writing to Disc with height {} at height {} took {} ms",
|
||||
daoStateSnapshotCandidate.getChainHeight(), chainHeight, System.currentTimeMillis() - ts);
|
||||
}
|
||||
|
|
|
@ -76,10 +76,10 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
|
|||
return FILE_NAME;
|
||||
}
|
||||
|
||||
public void persistNow(DaoState daoState, LinkedList<DaoStateHash> daoStateHashChain, Runnable completeHandler) {
|
||||
public void requestPersistence(DaoState daoState, LinkedList<DaoStateHash> daoStateHashChain) {
|
||||
store.setDaoState(daoState);
|
||||
store.setDaoStateHashChain(daoStateHashChain);
|
||||
persistenceManager.persistNow(completeHandler);
|
||||
persistenceManager.requestPersistence();
|
||||
}
|
||||
|
||||
public DaoState getPersistedBsqState() {
|
||||
|
@ -91,7 +91,9 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
|
|||
}
|
||||
|
||||
public void resyncDaoStateFromGenesis(Runnable resultHandler) {
|
||||
persistNow(new DaoState(), new LinkedList<>(), resultHandler);
|
||||
store.setDaoState(new DaoState());
|
||||
store.setDaoStateHashChain(new LinkedList<>());
|
||||
persistenceManager.persistNow(resultHandler);
|
||||
}
|
||||
|
||||
public void resyncDaoStateFromResources(File storageDir) throws IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue