From e46b2bc69c25983c09bea434013110342327a8c6 Mon Sep 17 00:00:00 2001 From: almogdepaz Date: Mon, 9 Dec 2024 11:06:45 +0200 Subject: [PATCH] add assertions --- chia/consensus/blockchain.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chia/consensus/blockchain.py b/chia/consensus/blockchain.py index f989bfe96344..28df0e32b0d9 100644 --- a/chia/consensus/blockchain.py +++ b/chia/consensus/blockchain.py @@ -774,7 +774,14 @@ def contains_block(self, header_hash: bytes32) -> bool: True if we have already added this block to the chain. This may return false for orphan blocks that we have added but no longer keep in memory. """ - return header_hash in self.__block_records + # check block records + block_rec = self.__block_records[header_hash] + if block_rec is None: + return False + block_rec = self.height_to_block_record(block_rec.height) + assert block_rec is not None + assert block_rec.header_hash == header_hash + return True def block_record(self, header_hash: bytes32) -> BlockRecord: return self.__block_records[header_hash]