mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Improve handling of case when Bitcoin Core sync is not completed.
We repeat with a quadratically increasing delay 5 times, then we give up. In the previous code we repeated forever which could be risky in case that code branch is called unexpectedly. Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
811ae52f27
commit
0f14ea29c9
1 changed files with 14 additions and 6 deletions
|
@ -57,6 +57,7 @@ public class FullNode extends BsqNode {
|
|||
private boolean addBlockHandlerAdded;
|
||||
private int blocksToParseInBatch;
|
||||
private long parseInBatchStartTime;
|
||||
private int parseBlocksOnHeadHeightCounter;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -206,12 +207,19 @@ public class FullNode extends BsqNode {
|
|||
parseBlocksIfNewBlockAvailable(chainHeight);
|
||||
}, this::handleError);
|
||||
} else {
|
||||
log.warn("We are trying to start with a block which is above the chain height of Bitcoin Core. " +
|
||||
"We need probably wait longer until Bitcoin Core has fully synced. " +
|
||||
"We try again after a delay of 1 min.");
|
||||
UserThread.runAfter(() -> rpcService.requestChainHeadHeight(chainHeight1 ->
|
||||
parseBlocksOnHeadHeight(startBlockHeight, chainHeight1),
|
||||
this::handleError), 60);
|
||||
parseBlocksOnHeadHeightCounter++;
|
||||
if (parseBlocksOnHeadHeightCounter <= 5) {
|
||||
log.warn("We are trying to start with a block which is above the chain height of Bitcoin Core. " +
|
||||
"We need to wait longer until Bitcoin Core has fully synced. " +
|
||||
"We try again after a delay of {} min.", parseBlocksOnHeadHeightCounter * parseBlocksOnHeadHeightCounter);
|
||||
UserThread.runAfter(() -> rpcService.requestChainHeadHeight(height ->
|
||||
parseBlocksOnHeadHeight(startBlockHeight, height),
|
||||
this::handleError), parseBlocksOnHeadHeightCounter * parseBlocksOnHeadHeightCounter * 60L);
|
||||
} else {
|
||||
log.warn("We tried {} times to start with startBlockHeight {} which is above the chain height {} of Bitcoin Core. " +
|
||||
"It might be that Bitcoin Core has not fully synced. We give up now.",
|
||||
parseBlocksOnHeadHeightCounter, startBlockHeight, chainHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue