use of bisq.core.dao.state.blockchain.Block in project bisq-core by bisq-network.
the class FullNode method parseBlock.
// Recursively request and parse all blocks
private void parseBlock(int blockHeight, int chainHeadHeight, Consumer<Block> newBlockHandler, ResultHandler resultHandler, Consumer<Throwable> errorHandler) {
rpcService.requestBtcBlock(blockHeight, rawBlock -> {
if (!isBlockAlreadyAdded(rawBlock)) {
try {
Block block = blockParser.parseBlock(rawBlock);
newBlockHandler.accept(block);
// Increment blockHeight and recursively call parseBlockAsync until we reach chainHeadHeight
if (blockHeight < chainHeadHeight) {
final int newBlockHeight = blockHeight + 1;
parseBlock(newBlockHeight, chainHeadHeight, newBlockHandler, resultHandler, errorHandler);
} else {
// We are done
resultHandler.handleResult();
}
} catch (BlockNotConnectingException e) {
errorHandler.accept(e);
}
}
}, errorHandler);
}
Aggregations