test: remove bare CBlockHeader .rehash()/.calc_sha256() calls

Since the previous commit, CBlockHeader/CBlock object calls to the
methods `.rehash()` and `.calc_sha256()` are effectively no-ops
if the returned value is not used, so we can just remove them.
This commit is contained in:
Sebastian Falbesoner
2025-06-12 13:04:39 +02:00
parent 0716382c20
commit 8b09cc350a
16 changed files with 0 additions and 32 deletions

View File

@@ -717,7 +717,6 @@ class CBlockHeader:
self.nTime = header.nTime
self.nBits = header.nBits
self.nNonce = header.nNonce
self.calc_sha256()
def set_null(self):
self.nVersion = 4
@@ -758,10 +757,6 @@ class CBlockHeader:
"""Return block header hash as integer."""
return uint256_from_str(hash256(self._serialize_header()))
# TODO: get rid of this method, remove call-sites
def calc_sha256(self):
pass
# TODO: get rid of this method, replace call-sites by .sha256 access (if return value is used)
def rehash(self):
return self.sha256
@@ -823,7 +818,6 @@ class CBlock(CBlockHeader):
return self.get_merkle_root(hashes)
def is_valid(self):
self.calc_sha256()
target = uint256_from_compact(self.nBits)
if self.sha256 > target:
return False
@@ -835,11 +829,9 @@ class CBlock(CBlockHeader):
return True
def solve(self):
self.rehash()
target = uint256_from_compact(self.nBits)
while self.sha256 > target:
self.nNonce += 1
self.rehash()
# Calculate the block weight using witness and non-witness
# serialization size (does NOT use sigops).