Skip to content

Commit 09e60df

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23723: test: Replace hashlib.new with named constructor
fa1b63c test: Replace hashlib.new with named constructor (MarcoFalke) Pull request description: A small refactor that doesn't matter too much, but it using the named constructor is nice because: * It clarifies that it is a built-in function * It is (trivially) faster and less code. ACKs for top commit: Zero-1729: ACK fa1b63c w0xlt: ACK fa1b63c Tree-SHA512: d23dc4552c1e6fc1f90f8272e47e4efcbe727f0b66a6f6a264db8a50ee6cb6d57a2809befcb95fda6725136672268633817a03dd1859f2298d20e3f9e0ca4a7f
2 parents aab5e48 + fa1b63c commit 09e60df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/functional/test_framework/messages.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@
6464

6565
WITNESS_SCALE_FACTOR = 4
6666

67-
# Serialization/deserialization tools
67+
6868
def sha256(s):
69-
return hashlib.new('sha256', s).digest()
69+
return hashlib.sha256(s).digest()
70+
7071

7172
def hash256(s):
7273
return sha256(sha256(s))
7374

75+
7476
def ser_compact_size(l):
7577
r = b""
7678
if l < 253:

0 commit comments

Comments
 (0)