mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Implement support for GETMNLISTD and MNLISTDIFF P2P message in mininode.py
This commit is contained in:
parent
585b9c2818
commit
ef6b6a1e64
@ -910,6 +910,37 @@ class CCbTx(object):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
class CSimplifiedMNListEntry(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.set_null()
|
||||||
|
|
||||||
|
def set_null(self):
|
||||||
|
self.proRegTxHash = 0
|
||||||
|
self.confirmedHash = 0
|
||||||
|
self.service = CService()
|
||||||
|
self.pubKeyOperator = b'\\x0' * 48
|
||||||
|
self.keyIDVoting = 0
|
||||||
|
self.isValid = False
|
||||||
|
|
||||||
|
def deserialize(self, f):
|
||||||
|
self.proRegTxHash = deser_uint256(f)
|
||||||
|
self.confirmedHash = deser_uint256(f)
|
||||||
|
self.service.deserialize(f)
|
||||||
|
self.pubKeyOperator = f.read(48)
|
||||||
|
self.keyIDVoting = f.read(20)
|
||||||
|
self.isValid = struct.unpack("<?", f.read(1))[0]
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
r = b""
|
||||||
|
r += ser_uint256(self.proRegTxHash)
|
||||||
|
r += ser_uint256(self.confirmedHash)
|
||||||
|
r += self.service.serialize()
|
||||||
|
r += self.pubKeyOperator
|
||||||
|
r += self.keyIDVoting
|
||||||
|
r += struct.pack("<?", self.isValid)
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
# Objects that correspond to messages on the wire
|
# Objects that correspond to messages on the wire
|
||||||
class msg_version(object):
|
class msg_version(object):
|
||||||
command = b"version"
|
command = b"version"
|
||||||
@ -1404,6 +1435,55 @@ class msg_blocktxn(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "msg_blocktxn(block_transactions=%s)" % (repr(self.block_transactions))
|
return "msg_blocktxn(block_transactions=%s)" % (repr(self.block_transactions))
|
||||||
|
|
||||||
|
class msg_getmnlistd(object):
|
||||||
|
command = b"getmnlistd"
|
||||||
|
|
||||||
|
def __init__(self, baseBlockHash=0, blockHash=0):
|
||||||
|
self.baseBlockHash = baseBlockHash
|
||||||
|
self.blockHash = blockHash
|
||||||
|
|
||||||
|
def deserialize(self, f):
|
||||||
|
self.baseBlockHash = deser_uint256(f)
|
||||||
|
self.blockHash = deser_uint256(f)
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
r = b""
|
||||||
|
r += ser_uint256(self.baseBlockHash)
|
||||||
|
r += ser_uint256(self.blockHash)
|
||||||
|
return r
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "msg_getmnlistd(baseBlockHash=%064x, blockHash=%064x)" % (self.baseBlockHash, self.blockHash)
|
||||||
|
|
||||||
|
class msg_mnlistdiff(object):
|
||||||
|
command = b"mnlistdiff"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.baseBlockHash = 0
|
||||||
|
self.blockHash = 0
|
||||||
|
self.merkleProof = CPartialMerkleTree()
|
||||||
|
self.cbTx = None
|
||||||
|
self.deletedMNs = []
|
||||||
|
self.mnList = []
|
||||||
|
|
||||||
|
def deserialize(self, f):
|
||||||
|
self.baseBlockHash = deser_uint256(f)
|
||||||
|
self.blockHash = deser_uint256(f)
|
||||||
|
self.merkleProof.deserialize(f)
|
||||||
|
self.cbTx = CTransaction()
|
||||||
|
self.cbTx.deserialize(f)
|
||||||
|
self.cbTx.rehash()
|
||||||
|
self.deletedMNs = deser_uint256_vector(f)
|
||||||
|
self.mnList = []
|
||||||
|
for i in range(deser_compact_size(f)):
|
||||||
|
e = CSimplifiedMNListEntry()
|
||||||
|
e.deserialize(f)
|
||||||
|
self.mnList.append(e)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "msg_mnlistdiff(baseBlockHash=%064x, blockHash=%064x)" % (self.baseBlockHash, self.blockHash)
|
||||||
|
|
||||||
|
|
||||||
# This is what a callback should look like for NodeConn
|
# This is what a callback should look like for NodeConn
|
||||||
# Reimplement the on_* functions to provide handling for events
|
# Reimplement the on_* functions to provide handling for events
|
||||||
class NodeConnCB(object):
|
class NodeConnCB(object):
|
||||||
@ -1487,6 +1567,7 @@ class NodeConnCB(object):
|
|||||||
def on_cmpctblock(self, conn, message): pass
|
def on_cmpctblock(self, conn, message): pass
|
||||||
def on_getblocktxn(self, conn, message): pass
|
def on_getblocktxn(self, conn, message): pass
|
||||||
def on_blocktxn(self, conn, message): pass
|
def on_blocktxn(self, conn, message): pass
|
||||||
|
def on_mnlistdiff(self, conn, message): pass
|
||||||
|
|
||||||
# More useful callbacks and functions for NodeConnCB's which have a single NodeConn
|
# More useful callbacks and functions for NodeConnCB's which have a single NodeConn
|
||||||
class SingleNodeConnCB(NodeConnCB):
|
class SingleNodeConnCB(NodeConnCB):
|
||||||
@ -1543,7 +1624,8 @@ class NodeConn(asyncore.dispatcher):
|
|||||||
b"sendcmpct": msg_sendcmpct,
|
b"sendcmpct": msg_sendcmpct,
|
||||||
b"cmpctblock": msg_cmpctblock,
|
b"cmpctblock": msg_cmpctblock,
|
||||||
b"getblocktxn": msg_getblocktxn,
|
b"getblocktxn": msg_getblocktxn,
|
||||||
b"blocktxn": msg_blocktxn
|
b"blocktxn": msg_blocktxn,
|
||||||
|
b"mnlistdiff": msg_mnlistdiff
|
||||||
}
|
}
|
||||||
MAGIC_BYTES = {
|
MAGIC_BYTES = {
|
||||||
"mainnet": b"\xbf\x0c\x6b\xbd", # mainnet
|
"mainnet": b"\xbf\x0c\x6b\xbd", # mainnet
|
||||||
|
Loading…
Reference in New Issue
Block a user