Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_pruning.py
Show All 33 Lines | |||||
TIMESTAMP_WINDOW = 2 * 60 * 60 | TIMESTAMP_WINDOW = 2 * 60 * 60 | ||||
def mine_large_blocks(node, n): | def mine_large_blocks(node, n): | ||||
# Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN | # Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN | ||||
# followed by 950k of OP_NOP. This would be non-standard in a non-coinbase | # followed by 950k of OP_NOP. This would be non-standard in a non-coinbase | ||||
# transaction but is consensus valid. | # transaction but is consensus valid. | ||||
# Set the nTime if this is the first time this function has been called. | |||||
# A static variable ensures that time is monotonicly increasing and is therefore | |||||
# different for each block created => blockhash is unique. | |||||
if "nTimes" not in mine_large_blocks.__dict__: | |||||
mine_large_blocks.nTime = 0 | |||||
# Get the block parameters for the first block | # Get the block parameters for the first block | ||||
big_script = CScript([OP_RETURN] + [OP_NOP] * 950000) | big_script = CScript([OP_RETURN] + [OP_NOP] * 950000) | ||||
best_block = node.getblock(node.getbestblockhash()) | best_block = node.getblock(node.getbestblockhash()) | ||||
height = int(best_block["height"]) + 1 | height = int(best_block["height"]) + 1 | ||||
try: | mine_large_blocks.nTime = max( | ||||
# Static variable ensures that time is monotonicly increasing and is therefore | |||||
# different for each block created => blockhash is unique. | |||||
mine_large_blocks.nTime = min( | |||||
mine_large_blocks.nTime, int(best_block["time"])) + 1 | mine_large_blocks.nTime, int(best_block["time"])) + 1 | ||||
except AttributeError: | |||||
mine_large_blocks.nTime = int(best_block["time"]) + 1 | |||||
previousblockhash = int(best_block["hash"], 16) | previousblockhash = int(best_block["hash"], 16) | ||||
for _ in range(n): | for _ in range(n): | ||||
# Build the coinbase transaction (with large scriptPubKey) | # Build the coinbase transaction (with large scriptPubKey) | ||||
coinbase_tx = create_coinbase(height) | coinbase_tx = create_coinbase(height) | ||||
coinbase_tx.vin[0].nSequence = 2 ** 32 - 1 | coinbase_tx.vin[0].nSequence = 2 ** 32 - 1 | ||||
coinbase_tx.vout[0].scriptPubKey = big_script | coinbase_tx.vout[0].scriptPubKey = big_script | ||||
coinbase_tx.rehash() | coinbase_tx.rehash() | ||||
▲ Show 20 Lines • Show All 453 Lines • Show Last 20 Lines |