Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-compactblocks.py
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0, extra_txns=0): | ||||
# We will add a new transaction. That means the size of | # We will add a new transaction. That means the size of | ||||
# the field enumerating how many transaction go in the block | # the field enumerating how many transaction go in the block | ||||
# may change. | # may change. | ||||
current_block_size -= len(ser_compact_size(len(block.vtx))) | current_block_size -= len(ser_compact_size(len(block.vtx))) | ||||
current_block_size += len(ser_compact_size(len(block.vtx) + 1)) | current_block_size += len(ser_compact_size(len(block.vtx) + 1)) | ||||
# Create the new transaction | # Create the new transaction | ||||
tx = get_base_transaction() | tx = get_base_transaction() | ||||
pad_tx(tx) | |||||
tx.rehash() | |||||
tx_size = len(tx.serialize()) + 18 | |||||
# Add padding to fill the block. | # Add padding to fill the block. | ||||
script_length = block_size - current_block_size - base_tx_size | script_length = block_size - current_block_size - tx_size | ||||
if script_length > 510000: | if script_length > 510000: | ||||
if script_length < 1000000: | if script_length < 1000000: | ||||
# Make sure we don't find ourselves in a position where we | # Make sure we don't find ourselves in a position where we | ||||
# need to generate a transaction smaller than what we expected. | # need to generate a transaction smaller than what we expected. | ||||
script_length = script_length // 2 | script_length = script_length // 2 | ||||
else: | else: | ||||
script_length = 500000 | script_length = 500000 | ||||
script_output = CScript([b'\x00' * script_length]) | script_output = CScript([b'\x00' * script_length]) | ||||
▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines |