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