test: rename CBlockHeader .rehash()/.sha256 -> .hash_int for consistency

Note that we unfortunately can't use a scripted diff here, as the
`sha256` symbol is also used for other instances (e.g. as function
in hashlib, or in the `UTXO` class in p2p_segwit.py).
This commit is contained in:
Sebastian Falbesoner
2025-06-12 14:13:55 +02:00
parent 8b09cc350a
commit 23be0ec2f0
33 changed files with 141 additions and 145 deletions

View File

@@ -625,7 +625,7 @@ class P2PInterface(P2PConnection):
def wait_for_block(self, blockhash, *, timeout=60):
def test_function():
return self.last_message.get("block") and self.last_message["block"].block.rehash() == blockhash
return self.last_message.get("block") and self.last_message["block"].block.hash_int == blockhash
self.wait_until(test_function, timeout=timeout)
@@ -634,7 +634,7 @@ class P2PInterface(P2PConnection):
last_headers = self.last_message.get('headers')
if not last_headers:
return False
return last_headers.headers[0].rehash() == int(blockhash, 16)
return last_headers.headers[0].hash_int == int(blockhash, 16)
self.wait_until(test_function, timeout=timeout)
@@ -643,7 +643,7 @@ class P2PInterface(P2PConnection):
last_filtered_block = self.last_message.get('merkleblock')
if not last_filtered_block:
return False
return last_filtered_block.merkleblock.header.rehash() == int(blockhash, 16)
return last_filtered_block.merkleblock.header.hash_int == int(blockhash, 16)
self.wait_until(test_function, timeout=timeout)
@@ -837,14 +837,14 @@ class P2PDataStore(P2PInterface):
return
headers_list = [self.block_store[self.last_block_hash]]
while headers_list[-1].sha256 not in locator.vHave:
while headers_list[-1].hash_int not in locator.vHave:
# Walk back through the block store, adding headers to headers_list
# as we go.
prev_block_hash = headers_list[-1].hashPrevBlock
if prev_block_hash in self.block_store:
prev_block_header = CBlockHeader(self.block_store[prev_block_hash])
headers_list.append(prev_block_header)
if prev_block_header.sha256 == hash_stop:
if prev_block_header.hash_int == hash_stop:
# if this is the hashstop header, stop here
break
else:
@@ -872,8 +872,8 @@ class P2PDataStore(P2PInterface):
with p2p_lock:
for block in blocks:
self.block_store[block.sha256] = block
self.last_block_hash = block.sha256
self.block_store[block.hash_int] = block
self.last_block_hash = block.hash_int
reject_reason = [reject_reason] if reject_reason else []
with node.assert_debug_log(expected_msgs=reject_reason):
@@ -885,7 +885,7 @@ class P2PDataStore(P2PInterface):
else:
self.send_without_ping(msg_headers([CBlockHeader(block) for block in blocks]))
self.wait_until(
lambda: blocks[-1].sha256 in self.getdata_requests,
lambda: blocks[-1].hash_int in self.getdata_requests,
timeout=timeout,
check_connected=success,
)