Ejemplo n.º 1
0
 def msg_ser(self, f):
     f.write(struct.pack(b"<i", self.nVersion))
     f.write(struct.pack(b"<Q", self.nServices))
     f.write(struct.pack(b"<q", self.nTime))
     self.addrTo.stream_serialize(f, True)
     self.addrFrom.stream_serialize(f, True)
     f.write(struct.pack(b"<Q", self.nNonce))
     VarStringSerializer.stream_serialize(self.strSubVer, f)
     f.write(struct.pack(b"<i", self.nStartingHeight))
Ejemplo n.º 2
0
 def msg_ser(self, f):
     f.write(struct.pack(b"<i", self.nVersion))
     f.write(struct.pack(b"<Q", self.nServices))
     f.write(struct.pack(b"<q", self.nTime))
     self.addrTo.stream_serialize(f, True)
     self.addrFrom.stream_serialize(f, True)
     f.write(struct.pack(b"<Q", self.nNonce))
     VarStringSerializer.stream_serialize(self.strSubVer, f)
     f.write(struct.pack(b"<i", self.nStartingHeight))
Ejemplo n.º 3
0
 def msg_deser(cls, f, protover=PROTO_VERSION):
     c = cls()
     c.nVersion = struct.unpack(b"<i", ser_read(f, 4))[0]
     if c.nVersion == 10300:
         c.nVersion = 300
     c.nServices = struct.unpack(b"<Q", ser_read(f, 8))[0]
     c.nTime = struct.unpack(b"<q", ser_read(f, 8))[0]
     c.addrTo = CAddress.stream_deserialize(f, True)
     if c.nVersion >= 106:
         c.addrFrom = CAddress.stream_deserialize(f, True)
         c.nNonce = struct.unpack(b"<Q", ser_read(f, 8))[0]
         c.strSubVer = VarStringSerializer.stream_deserialize(f)
         if c.nVersion >= 209:
             c.nStartingHeight = struct.unpack(b"<i", ser_read(f,4))[0]
         else:
             c.nStartingHeight = None
     else:
         c.addrFrom = None
         c.nNonce = None
         c.strSubVer = None
         c.nStartingHeight = None
     return c
Ejemplo n.º 4
0
 def msg_deser(cls, f, protover=PROTO_VERSION):
     c = cls()
     c.nVersion = struct.unpack(b"<i", ser_read(f, 4))[0]
     if c.nVersion == 10300:
         c.nVersion = 300
     c.nServices = struct.unpack(b"<Q", ser_read(f, 8))[0]
     c.nTime = struct.unpack(b"<q", ser_read(f, 8))[0]
     c.addrTo = CAddress.stream_deserialize(f, True)
     if c.nVersion >= 106:
         c.addrFrom = CAddress.stream_deserialize(f, True)
         c.nNonce = struct.unpack(b"<Q", ser_read(f, 8))[0]
         c.strSubVer = VarStringSerializer.stream_deserialize(f)
         if c.nVersion >= 209:
             c.nStartingHeight = struct.unpack(b"<i", ser_read(f, 4))[0]
         else:
             c.nStartingHeight = None
     else:
         c.addrFrom = None
         c.nNonce = None
         c.strSubVer = None
         c.nStartingHeight = None
     return c
Ejemplo n.º 5
0
 def msg_ser(self, f):
     VarStringSerializer.stream_serialize(self.message, f)
     f.write(struct.pack(b"<c", self.ccode))
     VarStringSerializer.stream_serialize(self.reason, f)
Ejemplo n.º 6
0
 def msg_deser(cls, f, protover=PROTO_VERSION):
     c = cls()
     c.message = VarStringSerializer.stream_deserialize(f)
     c.ccode = struct.unpack(b"<c", ser_read(f,1))[0]
     c.reason = VarStringSerializer.stream_deserialize(f)
     return c
Ejemplo n.º 7
0
 def msg_ser(self, f):
     VarStringSerializer.stream_serialize(self.message, f)
     f.write(struct.pack(b"<c", self.ccode))
     VarStringSerializer.stream_serialize(self.reason, f)
Ejemplo n.º 8
0
 def msg_deser(cls, f, protover=PROTO_VERSION):
     c = cls()
     c.message = VarStringSerializer.stream_deserialize(f)
     c.ccode = struct.unpack(b"<c", ser_read(f, 1))[0]
     c.reason = VarStringSerializer.stream_deserialize(f)
     return c