Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show First 20 Lines • Show All 684 Lines • ▼ Show 20 Lines | def get_siphash_keys(self): | ||||
header_nonce = self.header.serialize() | header_nonce = self.header.serialize() | ||||
header_nonce += struct.pack("<Q", self.nonce) | header_nonce += struct.pack("<Q", self.nonce) | ||||
hash_header_nonce_as_str = sha256(header_nonce) | hash_header_nonce_as_str = sha256(header_nonce) | ||||
key0 = struct.unpack("<Q", hash_header_nonce_as_str[0:8])[0] | key0 = struct.unpack("<Q", hash_header_nonce_as_str[0:8])[0] | ||||
key1 = struct.unpack("<Q", hash_header_nonce_as_str[8:16])[0] | key1 = struct.unpack("<Q", hash_header_nonce_as_str[8:16])[0] | ||||
return [key0, key1] | return [key0, key1] | ||||
# Version 2 compact blocks use wtxid in shortids (rather than txid) | # Version 2 compact blocks use wtxid in shortids (rather than txid) | ||||
def initialize_from_block(self, block, nonce=0, prefill_list=[0]): | def initialize_from_block(self, block, nonce=0, prefill_list=None): | ||||
if prefill_list is None: | |||||
prefill_list = [0] | |||||
self.header = CBlockHeader(block) | self.header = CBlockHeader(block) | ||||
self.nonce = nonce | self.nonce = nonce | ||||
self.prefilled_txn = [PrefilledTransaction(i, block.vtx[i]) | self.prefilled_txn = [PrefilledTransaction(i, block.vtx[i]) | ||||
for i in prefill_list] | for i in prefill_list] | ||||
self.shortids = [] | self.shortids = [] | ||||
[k0, k1] = self.get_siphash_keys() | [k0, k1] = self.get_siphash_keys() | ||||
for i in range(len(block.vtx)): | for i in range(len(block.vtx)): | ||||
if i not in prefill_list: | if i not in prefill_list: | ||||
▲ Show 20 Lines • Show All 867 Lines • Show Last 20 Lines |