Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
NODE_AVALANCHE = (1 << 24) | NODE_AVALANCHE = (1 << 24) | ||||
MSG_TX = 1 | MSG_TX = 1 | ||||
MSG_BLOCK = 2 | MSG_BLOCK = 2 | ||||
MSG_FILTERED_BLOCK = 3 | MSG_FILTERED_BLOCK = 3 | ||||
MSG_CMPCTBLOCK = 4 | MSG_CMPCTBLOCK = 4 | ||||
MSG_TYPE_MASK = 0xffffffff >> 2 | MSG_TYPE_MASK = 0xffffffff >> 2 | ||||
FILTER_TYPE_BASIC = 0 | |||||
# Serialization/deserialization tools | # Serialization/deserialization tools | ||||
def sha256(s): | def sha256(s): | ||||
return hashlib.new('sha256', s).digest() | return hashlib.new('sha256', s).digest() | ||||
def hash256(s): | def hash256(s): | ||||
return sha256(sha256(s)) | return sha256(sha256(s)) | ||||
▲ Show 20 Lines • Show All 1,390 Lines • ▼ Show 20 Lines | def serialize(self): | ||||
r += self.block_transactions.serialize() | r += self.block_transactions.serialize() | ||||
return r | return r | ||||
def __repr__(self): | def __repr__(self): | ||||
return "msg_blocktxn(block_transactions={})".format( | return "msg_blocktxn(block_transactions={})".format( | ||||
repr(self.block_transactions)) | repr(self.block_transactions)) | ||||
class msg_getcfcheckpt: | |||||
__slots__ = ("filter_type", "stop_hash") | |||||
msgtype = b"getcfcheckpt" | |||||
def __init__(self, filter_type, stop_hash): | |||||
self.filter_type = filter_type | |||||
self.stop_hash = stop_hash | |||||
def deserialize(self, f): | |||||
self.filter_type = struct.unpack("<B", f.read(1))[0] | |||||
self.stop_hash = deser_uint256(f) | |||||
def serialize(self): | |||||
r = b"" | |||||
r += struct.pack("<B", self.filter_type) | |||||
r += ser_uint256(self.stop_hash) | |||||
return r | |||||
def __repr__(self): | |||||
return "msg_getcfcheckpt(filter_type={:#x}, stop_hash={:x})".format( | |||||
self.filter_type, self.stop_hash) | |||||
class msg_cfcheckpt: | |||||
__slots__ = ("filter_type", "stop_hash", "headers") | |||||
msgtype = b"cfcheckpt" | |||||
def __init__(self, filter_type=None, stop_hash=None, headers=None): | |||||
self.filter_type = filter_type | |||||
self.stop_hash = stop_hash | |||||
self.headers = headers | |||||
def deserialize(self, f): | |||||
self.filter_type = struct.unpack("<B", f.read(1))[0] | |||||
self.stop_hash = deser_uint256(f) | |||||
self.headers = deser_uint256_vector(f) | |||||
def serialize(self): | |||||
r = b"" | |||||
r += struct.pack("<B", self.filter_type) | |||||
r += ser_uint256(self.stop_hash) | |||||
r += ser_uint256_vector(self.headers) | |||||
return r | |||||
def __repr__(self): | |||||
return "msg_cfcheckpt(filter_type={:#x}, stop_hash={:x})".format( | |||||
self.filter_type, self.stop_hash) | |||||
class msg_avapoll(): | class msg_avapoll(): | ||||
__slots__ = ("poll",) | __slots__ = ("poll",) | ||||
msgtype = b"avapoll" | msgtype = b"avapoll" | ||||
def __init__(self): | def __init__(self): | ||||
self.poll = AvalanchePoll() | self.poll = AvalanchePoll() | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |