def unserialize(self, toUnpack): if isinstance(toUnpack, BinaryUnpacker): verData = toUnpack else: verData = BinaryUnpacker( toUnpack ) self.version = verData.get(INT32) self.services = int_to_bitset(verData.get(UINT64), widthBytes=8) self.time = verData.get(INT64) self.addrRecv = PyNetAddress().unserialize(verData, hasTimeField=False) self.addrFrom = PyNetAddress().unserialize(verData, hasTimeField=False) self.nonce = verData.get(UINT64) self.subver = verData.get(VAR_STR) self.height0 = verData.get(INT32) return self
def unserialize(self, toUnpack): if isinstance(toUnpack, BinaryUnpacker): verData = toUnpack else: verData = BinaryUnpacker(toUnpack) self.version = verData.get(INT32) self.services = int_to_bitset(verData.get(UINT64), widthBytes=8) self.time = verData.get(INT64) self.addrRecv = PyNetAddress().unserialize(verData, hasTimeField=False) self.addrFrom = PyNetAddress().unserialize(verData, hasTimeField=False) self.nonce = verData.get(UINT64) self.subver = verData.get(VAR_STR) self.height0 = verData.get(INT32) return self
def unserialize(self, toUnpack, hasTimeField=True): if isinstance(toUnpack, BinaryUnpacker): addrData = toUnpack else: addrData = BinaryUnpacker( toUnpack ) if hasTimeField: self.time = addrData.get(UINT32) self.services = addrData.get(UINT64) self.addrQuad = addrData.get(BINARY_CHUNK,16)[-4:] self.port = addrData.get(UINT16, endianness=NETWORKENDIAN) self.services = int_to_bitset(self.services) self.addrQuad = binary_to_quad(self.addrQuad) return self
def unserialize(self, toUnpack, hasTimeField=True): if isinstance(toUnpack, BinaryUnpacker): addrData = toUnpack else: addrData = BinaryUnpacker(toUnpack) if hasTimeField: self.time = addrData.get(UINT32) self.services = addrData.get(UINT64) self.addrQuad = addrData.get(BINARY_CHUNK, 16)[-4:] self.port = addrData.get(UINT16, endianness=NETWORKENDIAN) self.services = int_to_bitset(self.services) self.addrQuad = binary_to_quad(self.addrQuad) return self