def are_blocks_adjacent(block: Block, prev_block: Block) -> bool: is_valid_block = block.is_valid() is_valid_next = ( block.index == prev_block.index + 1 and block.prev_hash == prev_block.hash ) return is_valid_block and is_valid_next
def add_block(self, block: Block) -> bool: if block.is_valid() and self.is_next_block(block): self.blocks.append(block) return True else: return False