Skip to content

Commit

Permalink
use_height_if_available
Browse files Browse the repository at this point in the history
  • Loading branch information
almogdepaz committed Dec 9, 2024
1 parent e46b2bc commit e06555f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,18 +769,19 @@ async def validate_unfinished_block(

return PreValidationResult(None, required_iters, conds, uint32(0))

def contains_block(self, header_hash: bytes32) -> bool:
def contains_block(self, header_hash: bytes32, height: Optional[uint32] = None) -> 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.
"""
# 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
if height is None:
block_rec = self.__block_records[header_hash]
if block_rec is None:
return False
height = block_rec.height
block_hash_from_hh = self.height_to_hash(height)
assert block_hash_from_hh is not None
assert block_hash_from_hh == header_hash
return True

def block_record(self, header_hash: bytes32) -> BlockRecord:
Expand Down

0 comments on commit e06555f

Please sign in to comment.