Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show First 20 Lines • Show All 641 Lines • ▼ Show 20 Lines | class HeaderAndShortIDs: | ||||
__slots__ = ("header", "nonce", "prefilled_txn", "shortids") | __slots__ = ("header", "nonce", "prefilled_txn", "shortids") | ||||
def __init__(self, p2pheaders_and_shortids=None): | def __init__(self, p2pheaders_and_shortids=None): | ||||
self.header = CBlockHeader() | self.header = CBlockHeader() | ||||
self.nonce = 0 | self.nonce = 0 | ||||
self.shortids = [] | self.shortids = [] | ||||
self.prefilled_txn = [] | self.prefilled_txn = [] | ||||
if p2pheaders_and_shortids != None: | if p2pheaders_and_shortids is not None: | ||||
self.header = p2pheaders_and_shortids.header | self.header = p2pheaders_and_shortids.header | ||||
self.nonce = p2pheaders_and_shortids.nonce | self.nonce = p2pheaders_and_shortids.nonce | ||||
self.shortids = p2pheaders_and_shortids.shortids | self.shortids = p2pheaders_and_shortids.shortids | ||||
last_index = -1 | last_index = -1 | ||||
for x in p2pheaders_and_shortids.prefilled_txn: | for x in p2pheaders_and_shortids.prefilled_txn: | ||||
self.prefilled_txn.append( | self.prefilled_txn.append( | ||||
PrefilledTransaction(x.index + last_index + 1, x.tx)) | PrefilledTransaction(x.index + last_index + 1, x.tx)) | ||||
last_index = self.prefilled_txn[-1].index | last_index = self.prefilled_txn[-1].index | ||||
Show All 40 Lines | def __repr__(self): | ||||
repr(self.prefilled_txn)) | repr(self.prefilled_txn)) | ||||
class BlockTransactionsRequest: | class BlockTransactionsRequest: | ||||
__slots__ = ("blockhash", "indexes") | __slots__ = ("blockhash", "indexes") | ||||
def __init__(self, blockhash=0, indexes=None): | def __init__(self, blockhash=0, indexes=None): | ||||
self.blockhash = blockhash | self.blockhash = blockhash | ||||
self.indexes = indexes if indexes != None else [] | self.indexes = indexes if indexes is not None else [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
self.blockhash = deser_uint256(f) | self.blockhash = deser_uint256(f) | ||||
indexes_length = deser_compact_size(f) | indexes_length = deser_compact_size(f) | ||||
for i in range(indexes_length): | for i in range(indexes_length): | ||||
self.indexes.append(deser_compact_size(f)) | self.indexes.append(deser_compact_size(f)) | ||||
def serialize(self): | def serialize(self): | ||||
Show All 25 Lines | def __repr__(self): | ||||
self.blockhash, repr(self.indexes)) | self.blockhash, repr(self.indexes)) | ||||
class BlockTransactions: | class BlockTransactions: | ||||
__slots__ = ("blockhash", "transactions") | __slots__ = ("blockhash", "transactions") | ||||
def __init__(self, blockhash=0, transactions=None): | def __init__(self, blockhash=0, transactions=None): | ||||
self.blockhash = blockhash | self.blockhash = blockhash | ||||
self.transactions = transactions if transactions != None else [] | self.transactions = transactions if transactions is not None else [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
self.blockhash = deser_uint256(f) | self.blockhash = deser_uint256(f) | ||||
self.transactions = deser_vector(f, CTransaction) | self.transactions = deser_vector(f, CTransaction) | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += ser_uint256(self.blockhash) | r += ser_uint256(self.blockhash) | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | def __repr__(self): | ||||
return "msg_inv(inv={})".format(repr(self.inv)) | return "msg_inv(inv={})".format(repr(self.inv)) | ||||
class msg_getdata: | class msg_getdata: | ||||
__slots__ = ("inv",) | __slots__ = ("inv",) | ||||
command = b"getdata" | command = b"getdata" | ||||
def __init__(self, inv=None): | def __init__(self, inv=None): | ||||
self.inv = inv if inv != None else [] | self.inv = inv if inv is not None else [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
self.inv = deser_vector(f, CInv) | self.inv = deser_vector(f, CInv) | ||||
def serialize(self): | def serialize(self): | ||||
return ser_vector(self.inv) | return ser_vector(self.inv) | ||||
def __repr__(self): | def __repr__(self): | ||||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |