From ccafc1999ca0321752027ff7c85e0100699a30b5 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Wed, 30 Oct 2019 12:22:57 -0700 Subject: [PATCH] Adds a method to get all blocks from the tip to a target --- pisa/block_processor.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pisa/block_processor.py b/pisa/block_processor.py index 5e63ce5..c2572ac 100644 --- a/pisa/block_processor.py +++ b/pisa/block_processor.py @@ -45,6 +45,18 @@ class BlockProcessor: return block_count + def get_missed_blocks(self, last_know_block_hash): + current_block_hash = self.get_best_block_hash() + missed_blocks = [] + + while current_block_hash != last_know_block_hash and current_block_hash is not None: + missed_blocks.append(current_block_hash) + + current_block = self.get_block(current_block_hash) + current_block_hash = current_block.get("previousblockhash") + + return missed_blocks[::-1] + def get_distance_to_tip(self, target_block_hash): distance = None