mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Only call parseBlocksOnHeadHeight if our latest block from
persistance is below the chain height of btc core. With the new handling of dao state hashblocks it can be the we have persisted the latest block up to the chain height. Before that change we only had the last snapshot which was at least 20 blocks back persisted. We want to avoid to get caught in a retry loop at parseBlocksOnHeadHeight so we filter out that case just at the caller. At parseBlocksOnHeadHeight we inline the requestChainHeadHeightAndParseBlocks method as it is not used by other callers anymore. This case that we request a block but our local btc core chain hight is below that might be some edge case when we had a synced dao blocks but we btc core is resyncing...
This commit is contained in:
parent
42500c0370
commit
0edccd9fe1
@ -107,7 +107,18 @@ public class FullNode extends BsqNode {
|
||||
|
||||
@Override
|
||||
protected void startParseBlocks() {
|
||||
requestChainHeadHeightAndParseBlocks(getStartBlockHeight());
|
||||
int startBlockHeight = getStartBlockHeight();
|
||||
|
||||
log.info("startParseBlocks: startBlockHeight={}", startBlockHeight);
|
||||
rpcService.requestChainHeadHeight(chainHeight -> {
|
||||
// If our persisted block is equal to the chain height we have startBlockHeight 1 block higher,
|
||||
// so we do not call parseBlocksOnHeadHeight
|
||||
log.info("startParseBlocks: chainHeight={}", chainHeight);
|
||||
if (startBlockHeight <= chainHeight) {
|
||||
parseBlocksOnHeadHeight(startBlockHeight, chainHeight);
|
||||
}
|
||||
},
|
||||
this::handleError);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -185,12 +196,6 @@ public class FullNode extends BsqNode {
|
||||
this::handleError);
|
||||
}
|
||||
|
||||
private void requestChainHeadHeightAndParseBlocks(int startBlockHeight) {
|
||||
log.info("requestChainHeadHeightAndParseBlocks with startBlockHeight={}", startBlockHeight);
|
||||
rpcService.requestChainHeadHeight(chainHeight -> parseBlocksOnHeadHeight(startBlockHeight, chainHeight),
|
||||
this::handleError);
|
||||
}
|
||||
|
||||
private void parseBlocksOnHeadHeight(int startBlockHeight, int chainHeight) {
|
||||
if (startBlockHeight <= chainHeight) {
|
||||
blocksToParseInBatch = chainHeight - startBlockHeight;
|
||||
@ -212,7 +217,9 @@ public class FullNode extends BsqNode {
|
||||
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(() -> requestChainHeadHeightAndParseBlocks(startBlockHeight), 60);
|
||||
UserThread.runAfter(() -> rpcService.requestChainHeadHeight(chainHeight1 ->
|
||||
parseBlocksOnHeadHeight(startBlockHeight, chainHeight1),
|
||||
this::handleError), 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user