Skip to content

Commit

Permalink
Fix issues when sync from behind.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjos2372 committed Mar 24, 2021
1 parent 9b54725 commit c27ac79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/brs/GeneratorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ public long estimateCommitment(long generatorId, Block previousBlock) {
blockIt = downloadCache.getBlock(previousBlock.getId());
}
// Get some pending from cache and later from DB directly when available
while(blockIt != null && (blockchain.getHeight() < blockIt.getHeight() ||
blockchain.getBlockIdAtHeight(blockIt.getHeight()) != blockIt.getId()) ) {
// We also check if the blockchain actually have blockIt, we might be processing a fork
while(blockIt != null && (endHeight >= blockchain.getHeight() ||
blockchain.getBlockIdAtHeight(blockIt.getHeight()) != blockIt.getId())) {
if(blockIt.getGeneratorId() == generatorId) {
if(height - endHeight <= Constants.CAPACITY_ESTIMATION_BLOCKS)
nBlocksMinedOnCache++;
Expand Down

0 comments on commit c27ac79

Please sign in to comment.