Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show First 20 Lines • Show All 823 Lines • ▼ Show 20 Lines | class AvalancheResponse(): | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += struct.pack("<q", self.round) | r += struct.pack("<q", self.round) | ||||
r += struct.pack("<i", self.cooldown) | r += struct.pack("<i", self.cooldown) | ||||
r += ser_vector(self.votes) | r += ser_vector(self.votes) | ||||
return r | return r | ||||
def get_hash(self): | |||||
return hash256(self.serialize()) | |||||
def __repr__(self): | def __repr__(self): | ||||
return "AvalancheResponse(round={}, cooldown={}, votes={})".format( | return "AvalancheResponse(round={}, cooldown={}, votes={})".format( | ||||
self.round, self.cooldown, repr(self.votes)) | self.round, self.cooldown, repr(self.votes)) | ||||
class TCPAvalancheResponse(): | |||||
__slots__ = ("response", "sig") | |||||
def __init__(self, response=AvalancheResponse()): | |||||
self.response = response | |||||
self.sig = b"\0" * 64 | |||||
def deserialize(self, f): | |||||
self.response.deserialize(f) | |||||
self.sig = f.read(64) | |||||
def serialize(self): | |||||
r = b"" | |||||
r += self.response.serialize() | |||||
r += self.sig | |||||
return r | |||||
def __repr__(self): | |||||
return "TCPAvalancheResponse(response={}, sig={})".format( | |||||
repr(self.response), self.sig) | |||||
class CPartialMerkleTree: | class CPartialMerkleTree: | ||||
__slots__ = ("fBad", "nTransactions", "vBits", "vHash") | __slots__ = ("fBad", "nTransactions", "vBits", "vHash") | ||||
def __init__(self): | def __init__(self): | ||||
self.nTransactions = 0 | self.nTransactions = 0 | ||||
self.vHash = [] | self.vHash = [] | ||||
self.vBits = [] | self.vBits = [] | ||||
self.fBad = False | self.fBad = False | ||||
▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | class msg_avaresponse(): | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += self.response.serialize() | r += self.response.serialize() | ||||
return r | return r | ||||
def __repr__(self): | def __repr__(self): | ||||
return "msg_avaresponse(response={})".format(repr(self.response)) | return "msg_avaresponse(response={})".format(repr(self.response)) | ||||
class msg_tcpavaresponse(): | |||||
__slots__ = ("response",) | |||||
command = b"avaresponse" | |||||
def __init__(self): | |||||
self.response = TCPAvalancheResponse() | |||||
def deserialize(self, f): | |||||
self.response.deserialize(f) | |||||
def serialize(self): | |||||
r = b"" | |||||
r += self.response.serialize() | |||||
return r | |||||
def __repr__(self): | |||||
return "msg_tcpavaresponse(response={})".format(repr(self.response)) |