예제 #1
0
def generate_mock_recent_block_hashes(genesis_block, current_block_number,
                                      cycle_length):
    chain_length = (current_block_number // cycle_length + 1) * cycle_length
    blocks = get_pseudo_chain(chain_length, genesis_block)
    recent_block_hashes = [
        b'\x00' * 32 for i in range(cycle_length * 2 - current_block_number)
    ] + [block.hash for block in blocks[:current_block_number]]
    return blocks, recent_block_hashes
예제 #2
0
def generate_mock_latest_block_roots(genesis_block, current_block_number,
                                     epoch_length):
    chain_length = (current_block_number // epoch_length + 1) * epoch_length
    blocks = get_pseudo_chain(chain_length, genesis_block)
    latest_block_roots = [
        b'\x00' * 32 for i in range(epoch_length * 2 - current_block_number)
    ] + [block.root for block in blocks[:current_block_number]]
    return blocks, latest_block_roots
예제 #3
0
def generate_mock_latest_block_roots(genesis_block, current_slot, epoch_length,
                                     latest_block_roots_length):
    assert current_slot < latest_block_roots_length

    chain_length = (current_slot // epoch_length + 1) * epoch_length
    blocks = get_pseudo_chain(chain_length, genesis_block)
    latest_block_roots = [block.hash for block in blocks[:current_slot]] + [
        ZERO_HASH32 for _ in range(latest_block_roots_length - current_slot)
    ]
    return blocks, latest_block_roots