MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / update_block

Method update_block

test/functional/feature_block.py:1406–1423  ·  view source on GitHub ↗
(self, block_number, new_transactions, *, nTime=None)

Source from the content-addressed store, hash-verified

1404
1405 # adds transactions to the block and updates state
1406 def update_block(self, block_number, new_transactions, *, nTime=None):
1407 block = self.blocks[block_number]
1408 self.add_transactions_to_block(block, new_transactions)
1409 old_hash_int = block.hash_int
1410 if nTime is not None:
1411 block.nTime = nTime
1412 block.hashMerkleRoot = block.calc_merkle_root()
1413 has_witness_tx = any(not tx.wit.is_null() for tx in block.vtx)
1414 if has_witness_tx:
1415 add_witness_commitment(block)
1416 block.solve()
1417 # Update the internal state just like in next_block
1418 self.tip = block
1419 if block.hash_int != old_hash_int:
1420 self.block_heights[block.hash_int] = self.block_heights[old_hash_int]
1421 del self.block_heights[old_hash_int]
1422 self.blocks[block_number] = block
1423 return block
1424
1425 def bootstrap_p2p(self, timeout=10):
1426 """Add a P2P connection to the node.

Callers 1

run_testMethod · 0.95

Calls 5

add_witness_commitmentFunction · 0.90
calc_merkle_rootMethod · 0.80
solveMethod · 0.80
is_nullMethod · 0.45

Tested by

no test coverage detected