mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
scripted-diff: test: Use int.to_bytes over struct packing
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's!struct.pack\(.<?B., (.*)\)!\1.to_bytes(1, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<I., (.*)\)!\1.to_bytes(4, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<H., (.*)\)!\1.to_bytes(2, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<i., (.*)\)!\1.to_bytes(4, "little", signed=True)!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<q., (.*)\)!\1.to_bytes(8, "little", signed=True)!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.>H., (.*)\)!\1.to_bytes(2, "big")!g' $( git grep -l struct.pack ) -END VERIFY SCRIPT-
This commit is contained in:
@@ -28,15 +28,15 @@ def serialize_addrman(
|
||||
tried = []
|
||||
INCOMPATIBILITY_BASE = 32
|
||||
r = MAGIC_BYTES[net_magic]
|
||||
r += struct.pack("B", format)
|
||||
r += struct.pack("B", (INCOMPATIBILITY_BASE + lowest_compatible))
|
||||
r += format.to_bytes(1, "little")
|
||||
r += (INCOMPATIBILITY_BASE + lowest_compatible).to_bytes(1, "little")
|
||||
r += ser_uint256(bucket_key)
|
||||
r += struct.pack("<i", (len_new or len(new)))
|
||||
r += struct.pack("<i", (len_tried or len(tried)))
|
||||
r += (len_new or len(new)).to_bytes(4, "little", signed=True)
|
||||
r += (len_tried or len(tried)).to_bytes(4, "little", signed=True)
|
||||
ADDRMAN_NEW_BUCKET_COUNT = 1 << 10
|
||||
r += struct.pack("<i", (ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30)))
|
||||
r += (ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30)).to_bytes(4, "little", signed=True)
|
||||
for _ in range(ADDRMAN_NEW_BUCKET_COUNT):
|
||||
r += struct.pack("<i", (0))
|
||||
r += (0).to_bytes(4, "little", signed=True)
|
||||
checksum = hash256(r)
|
||||
r += mock_checksum or checksum
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user