mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Add heightsOfLastAppliedSnapshots list and resync in case we tried to apply 3 times with same height
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
04ea4ae053
commit
1f131b346e
@ -39,6 +39,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -78,7 +79,7 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
|
||||
private int daoRequiresRestartHandlerAttempts = 0;
|
||||
private boolean readyForPersisting = true;
|
||||
private boolean isParseBlockChainComplete;
|
||||
|
||||
private final List<Integer> heightsOfLastAppliedSnapshots = new ArrayList<>();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -285,6 +286,16 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
|
||||
}
|
||||
|
||||
int chainHeightOfPersistedDaoState = persistedDaoState.getChainHeight();
|
||||
int numSameAppliedSnapshots = (int) heightsOfLastAppliedSnapshots.stream()
|
||||
.filter(height -> height == chainHeightOfPersistedDaoState)
|
||||
.count();
|
||||
if (numSameAppliedSnapshots >= 3) {
|
||||
log.warn("We got called applySnapshot the 3rd time with the same snapshot height. " +
|
||||
"We abort and call resyncDaoStateFromResources.");
|
||||
resyncDaoStateFromResources();
|
||||
return;
|
||||
}
|
||||
heightsOfLastAppliedSnapshots.add(chainHeightOfPersistedDaoState);
|
||||
|
||||
if (persistedDaoState.getBlocks().isEmpty()) {
|
||||
if (fromInitialize) {
|
||||
|
Loading…
Reference in New Issue
Block a user