Skip to content

Commit

Permalink
[fix] Catch BlockNotFoundException on blockchain indexation
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Jan 27, 2020
1 parent 4fb9089 commit 3c2f1f7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ private Collection<String> indexBlocksNoBulk(Peer peer, String currencyName, int
indexCurrentBlockFromJson(currencyName, blockAsJson, true /*wait*/);
}
}
catch(Throwable t) {
catch(BlockNotFoundException | TechnicalException t) {
logger.debug(String.format("Error while getting block #%s: %s. Skipping this block.", curNumber, t.getMessage()));
missingBlockNumbers.add(String.valueOf(curNumber));
}
Expand Down Expand Up @@ -663,7 +663,7 @@ private Collection<String> indexBlocksUsingBulk(Peer peer, String currencyName,
try {
final int batchFirstNumberFinal = batchFirstNumber;
blocksAsJson = executeWithRetry(()->blockchainRemoteService.getBlocksAsJson(peer, batchSize, batchFirstNumberFinal));
} catch(TechnicalException e) {
} catch(BlockNotFoundException | TechnicalException e) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("[%s] [%s] Error while getting blocks from #%s (count=%s): %s. Skipping blocks.",currencyName, peer, batchFirstNumber, batchSize, e.getMessage()));
}
Expand Down Expand Up @@ -830,7 +830,7 @@ private Collection<String> indexMissingBlocksFromOtherPeers(Peer peer, Blockchai
// Update the list, for the next iteration
sortedMissingBlocks = newMissingBlocks;
}
catch(TechnicalException e) {
catch(BlockNotFoundException | TechnicalException e) {
if (debug) {
logger.debug(String.format("Error while getting blocks from peer [%s]: %s. Skipping this peer.", childPeer), e.getMessage());
}
Expand Down Expand Up @@ -912,7 +912,7 @@ private boolean detectAndResolveFork(Peer peer, final String currencyName, final

// Check is exists on ES index
sameBlockIndexed = isBlockIndexed(currencyName, forkOriginNumber, forkOriginHash);
} catch (TechnicalException e) {
} catch (BlockNotFoundException | TechnicalException e) {
logger.warn(I18n.t("duniter4j.blockIndexerService.detectFork.remoteBlockNotFound", currencyName, peer, forkOriginNumber, e.getMessage()));
sameBlockIndexed = false; // continue (go back again)
}
Expand Down

0 comments on commit 3c2f1f7

Please sign in to comment.