mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge pull request #5875 from chimp1984/fix-incorrect-chainheight
Fix incorrect start height for block request
This commit is contained in:
commit
6e1a805b22
@ -182,26 +182,6 @@ public abstract class BsqNode implements DaoSetupService {
|
||||
p2PService.removeP2PServiceListener(p2PServiceListener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected int getStartBlockHeight() {
|
||||
int chainHeight = daoStateService.getChainHeight();
|
||||
int startBlockHeight = chainHeight;
|
||||
if (chainHeight > genesisBlockHeight)
|
||||
startBlockHeight = chainHeight + 1;
|
||||
|
||||
log.info("getStartBlockHeight:\n" +
|
||||
" Start block height={}\n" +
|
||||
" Genesis txId={}\n" +
|
||||
" Genesis block height={}\n" +
|
||||
" Block height={}\n",
|
||||
startBlockHeight,
|
||||
genesisTxId,
|
||||
genesisBlockHeight,
|
||||
chainHeight);
|
||||
|
||||
return startBlockHeight;
|
||||
}
|
||||
|
||||
protected abstract void startParseBlocks();
|
||||
|
||||
protected void onParseBlockChainComplete() {
|
||||
|
@ -107,8 +107,7 @@ public class FullNode extends BsqNode {
|
||||
|
||||
@Override
|
||||
protected void startParseBlocks() {
|
||||
int startBlockHeight = getStartBlockHeight();
|
||||
|
||||
int startBlockHeight = daoStateService.getChainHeight();
|
||||
log.info("startParseBlocks: startBlockHeight={}", startBlockHeight);
|
||||
rpcService.requestChainHeadHeight(chainHeight -> {
|
||||
// If our persisted block is equal to the chain height we have startBlockHeight 1 block higher,
|
||||
|
@ -182,7 +182,20 @@ public class LiteNode extends BsqNode {
|
||||
// First we request the blocks from a full node
|
||||
@Override
|
||||
protected void startParseBlocks() {
|
||||
liteNodeNetworkService.requestBlocks(getStartBlockHeight());
|
||||
int chainHeight = daoStateService.getChainHeight();
|
||||
if (walletsSetup.isDownloadComplete() && chainHeight == bsqWalletService.getBestChainHeight()) {
|
||||
log.info("No block request needed as we have already the most recent block. " +
|
||||
"daoStateService.getChainHeight()={}, bsqWalletService.getBestChainHeight()={}",
|
||||
chainHeight, bsqWalletService.getBestChainHeight());
|
||||
onParseBlockChainComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (chainHeight == daoStateService.getGenesisBlockHeight()) {
|
||||
liteNodeNetworkService.requestBlocks(chainHeight);
|
||||
} else {
|
||||
liteNodeNetworkService.requestBlocks(chainHeight + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -221,9 +234,8 @@ public class LiteNode extends BsqNode {
|
||||
MathUtils.roundDouble(duration / blockList.size(), 2));
|
||||
// We only request again if wallet is synced, otherwise we would get repeated calls we want to avoid.
|
||||
// We deal with that case at the setupWalletBestBlockListener method above.
|
||||
if (walletsSetup.isDownloadComplete() &&
|
||||
daoStateService.getChainHeight() < bsqWalletService.getBestChainHeight()) {
|
||||
liteNodeNetworkService.requestBlocks(getStartBlockHeight());
|
||||
if (walletsSetup.isDownloadComplete() && daoStateService.getChainHeight() < bsqWalletService.getBestChainHeight()) {
|
||||
liteNodeNetworkService.requestBlocks(daoStateService.getChainHeight() + 1);
|
||||
} else {
|
||||
onParsingComplete.run();
|
||||
onParseBlockChainComplete();
|
||||
|
Loading…
Reference in New Issue
Block a user