Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show First 20 Lines • Show All 514 Lines • ▼ Show 20 Lines | |||||
BLOCK_HEADER_SIZE = len(CBlockHeader().serialize()) | BLOCK_HEADER_SIZE = len(CBlockHeader().serialize()) | ||||
assert_equal(BLOCK_HEADER_SIZE, 80) | assert_equal(BLOCK_HEADER_SIZE, 80) | ||||
class CBlock(CBlockHeader): | class CBlock(CBlockHeader): | ||||
__slots__ = ("vtx",) | __slots__ = ("vtx",) | ||||
def __init__(self, header=None): | def __init__(self, header=None): | ||||
super(CBlock, self).__init__(header) | super().__init__(header) | ||||
self.vtx = [] | self.vtx = [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
super(CBlock, self).deserialize(f) | super().deserialize(f) | ||||
self.vtx = deser_vector(f, CTransaction) | self.vtx = deser_vector(f, CTransaction) | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += super(CBlock, self).serialize() | r += super().serialize() | ||||
r += ser_vector(self.vtx) | r += ser_vector(self.vtx) | ||||
return r | return r | ||||
# Calculate the merkle root given a vector of transaction hashes | # Calculate the merkle root given a vector of transaction hashes | ||||
def get_merkle_root(self, hashes): | def get_merkle_root(self, hashes): | ||||
while len(hashes) > 1: | while len(hashes) > 1: | ||||
newhashes = [] | newhashes = [] | ||||
for i in range(0, len(hashes), 2): | for i in range(0, len(hashes), 2): | ||||
▲ Show 20 Lines • Show All 1,250 Lines • Show Last 20 Lines |