예제 #1
0
 def serialize(self, withTimeField=True):
    bp = BinaryPacker()
    if withTimeField:
       bp.put(UINT32,       self.time)
    bp.put(UINT64,       bitset_to_int(self.services))
    bp.put(BINARY_CHUNK, quad_to_binary(self.addrQuad).rjust(16,'\x00'))
    bp.put(UINT16,       self.port, endianness=NETWORKENDIAN)
    return bp.getBinaryString()
예제 #2
0
 def serialize(self, withTimeField=True):
     bp = BinaryPacker()
     if withTimeField:
         bp.put(UINT32, self.time)
     bp.put(UINT64, bitset_to_int(self.services))
     bp.put(BINARY_CHUNK, quad_to_binary(self.addrQuad).rjust(16, '\x00'))
     bp.put(UINT16, self.port, endianness=NETWORKENDIAN)
     return bp.getBinaryString()
예제 #3
0
 def serialize(self):
    bp = BinaryPacker()
    bp.put(INT32,   self.version )
    bp.put(UINT64,  bitset_to_int(self.services))
    bp.put(INT64,   self.time    )  # todo, should this really be int64?
    bp.put(BINARY_CHUNK, self.addrRecv.serialize(withTimeField=False))
    bp.put(BINARY_CHUNK, self.addrFrom.serialize(withTimeField=False))
    bp.put(UINT64,  self.nonce   )
    bp.put(VAR_STR, self.subver  )
    bp.put(INT32,   self.height0 )
    return bp.getBinaryString()
예제 #4
0
 def serialize(self):
     bp = BinaryPacker()
     bp.put(INT32, self.version)
     bp.put(UINT64, bitset_to_int(self.services))
     bp.put(INT64, self.time)  # todo, should this really be int64?
     bp.put(BINARY_CHUNK, self.addrRecv.serialize(withTimeField=False))
     bp.put(BINARY_CHUNK, self.addrFrom.serialize(withTimeField=False))
     bp.put(UINT64, self.nonce)
     bp.put(VAR_STR, self.subver)
     bp.put(INT32, self.height0)
     return bp.getBinaryString()