def stream_deserialize(cls, f, without_time=False): c = cls() if c.protover >= CADDR_TIME_VERSION and not without_time: c.nTime = struct.unpack(b"<I", ser_read(f, 4))[0] c.nServices = struct.unpack(b"<Q", ser_read(f, 8))[0] packedIP = ser_read(f, 16) if bytes(packedIP[0:12]) == IPV4_COMPAT: # IPv4 c.ip = socket.inet_ntop(socket.AF_INET, packedIP[12:16]) else: #IPv6 c.ip = socket.inet_ntop(socket.AF_INET6, packedIP) c.port = struct.unpack(b">H", ser_read(f, 2))[0] return c
def stream_deserialize(cls, f): c = cls() c.nVersion = struct.unpack(b"<i", ser_read(f, 4))[0] c.nRelayUntil = struct.unpack(b"<q", ser_read(f, 8))[0] c.nExpiration = struct.unpack(b"<q", ser_read(f, 8))[0] c.nID = struct.unpack(b"<i", ser_read(f, 4))[0] c.nCancel = struct.unpack(b"<i", ser_read(f, 4))[0] c.setCancel = intVectorSerializer.deserialize(f) c.nMinVer = struct.unpack(b"<i", ser_read(f, 4))[0] c.nMaxVer = struct.unpack(b"<i", ser_read(f, 4))[0] c.setSubVer = intVectorSerializer.deserialize(f) c.nPriority = struct.unpack(b"<i", ser_read(f, 4))[0] c.strComment = VarStringSerializer.deserialize(f) c.strStatusBar = VarStringSerializer.deserialize(f) c.strReserved = VarStringSerializer.deserialize(f) return c
def stream_deserialize(cls, f): c = cls() c.nVersion = struct.unpack(b"<i", ser_read(f,4))[0] c.nRelayUntil = struct.unpack(b"<q", ser_read(f,8))[0] c.nExpiration = struct.unpack(b"<q", ser_read(f,8))[0] c.nID = struct.unpack(b"<i", ser_read(f,4))[0] c.nCancel = struct.unpack(b"<i", ser_read(f,4))[0] c.setCancel = intVectorSerializer.deserialize(f) c.nMinVer = struct.unpack(b"<i", ser_read(f,4))[0] c.nMaxVer = struct.unpack(b"<i", ser_read(f,4))[0] c.setSubVer = intVectorSerializer.deserialize(f) c.nPriority = struct.unpack(b"<i", ser_read(f,4))[0] c.strComment = VarStringSerializer.deserialize(f) c.strStatusBar = VarStringSerializer.deserialize(f) c.strReserved = VarStringSerializer.deserialize(f) return c
def stream_deserialize(cls, f): c = cls() c.type = struct.unpack(b"<i", ser_read(f, 4))[0] c.hash = ser_read(f, 32) return c
def stream_deserialize(cls, f): c = cls() c.nVersion = struct.unpack(b"<i", ser_read(f, 4))[0] c.vHave = uint256VectorSerializer.stream_deserialize(f) return c