mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-05 19:38:54 +02:00
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:
@@ -753,14 +753,10 @@ class CBlockHeader:
|
||||
return hash256(self._serialize_header())[::-1].hex()
|
||||
|
||||
@property
|
||||
def sha256(self):
|
||||
def hash_int(self):
|
||||
"""Return block header hash as integer."""
|
||||
return uint256_from_str(hash256(self._serialize_header()))
|
||||
|
||||
# TODO: get rid of this method, replace call-sites by .sha256 access (if return value is used)
|
||||
def rehash(self):
|
||||
return self.sha256
|
||||
|
||||
def __repr__(self):
|
||||
return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x)" \
|
||||
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,
|
||||
@@ -819,7 +815,7 @@ class CBlock(CBlockHeader):
|
||||
|
||||
def is_valid(self):
|
||||
target = uint256_from_compact(self.nBits)
|
||||
if self.sha256 > target:
|
||||
if self.hash_int > target:
|
||||
return False
|
||||
for tx in self.vtx:
|
||||
if not tx.is_valid():
|
||||
@@ -830,7 +826,7 @@ class CBlock(CBlockHeader):
|
||||
|
||||
def solve(self):
|
||||
target = uint256_from_compact(self.nBits)
|
||||
while self.sha256 > target:
|
||||
while self.hash_int > target:
|
||||
self.nNonce += 1
|
||||
|
||||
# Calculate the block weight using witness and non-witness
|
||||
|
||||
Reference in New Issue
Block a user