def serialize(self): if self.numTx == UNINITIALIZED: raise UnitializedBlockDataError, 'PyBlockData object not initialized!' binOut = BinaryPacker() binOut.put(VAR_INT, self.numTx) for tx in self.txList: binOut.put(BINARY_CHUNK, tx.serialize()) return binOut.getBinaryString()
def serialize(self): bp = BinaryPacker() bp.put(BINARY_CHUNK, self.header.serialize()) bp.put(VAR_INT, len(self.headerList)) for header in self.headerList: bp.put(BINARY_CHUNK, header.serialize()) bp.put(VAR_INT, 0) return bp.getBinaryString()
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()
def serialize(self): nhash = len(self.hashList) bp = BinaryPacker() bp.put(UINT32, self.version) bp.put(VAR_INT, nhash) for i in range(nhash): bp.put(BINARY_CHUNK, self.hashList[i], width=32) bp.put(BINARY_CHUNK, self.hashList, width=32) return bp.getBinaryString()
def serialize(self): bp = BinaryPacker() bp.put(BINARY_CHUNK, self.magic, width= 4) bp.put(BINARY_CHUNK, self.cmd.ljust(12, '\x00'), width=12) payloadBin = self.payload.serialize() bp.put(UINT32, len(payloadBin)) bp.put(BINARY_CHUNK, hash256(payloadBin)[:4], width= 4) bp.put(BINARY_CHUNK, payloadBin) return bp.getBinaryString()
def serialize(self): bp = BinaryPacker() bp.put(VAR_INT, len(self.invList)) for inv in self.invList: bp.put(UINT32, inv[0]) bp.put(BINARY_CHUNK, inv[1], width=32) return bp.getBinaryString()
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()
def serialize(self): bp = BinaryPacker() bp.put(VAR_INT, len(self.addrList)) for netaddr in self.addrList: bp.put(BINARY_CHUNK, netaddr.serialize(), width=30) return bp.getBinaryString()
def serialize(self): bp = BinaryPacker() bp.put(INT8, self.nonSigLength) bp.put(UINT32, self.version) bp.put(UINT64, self.expiration) bp.put(UINT64, self.relayUntil) bp.put(UINT32, self.uniqueID) bp.put(UINT32, self.cancelVal) bp.put(INT8, len(self.cancelSet)) for cancel in self.cancelSet: bp.put(UINT32, cancel) bp.put(UINT32, self.minVersion) bp.put(UINT32, self.maxVersion) bp.put(INT8, len(self.subVerSet)) for subVer in self.subVerSet: bp.put(VAR_STR, subVer) bp.put(UINT32, self.priority) bp.put(VAR_STR, self.comment) bp.put(VAR_STR, self.statusBar) bp.put(VAR_STR, self.reserved) bp.put(VAR_STR, self.signature) return bp.getBinaryString()
def serialize(self): if self.version == UNINITIALIZED: raise UnitializedBlockDataError, 'PyBlockHeader object not initialized!' binOut = BinaryPacker() binOut.put(UINT32, self.version) binOut.put(BINARY_CHUNK, self.prevBlkHash) binOut.put(BINARY_CHUNK, self.merkleRoot) binOut.put(UINT32, self.timestamp) binOut.put(BINARY_CHUNK, self.diffBits) binOut.put(UINT32, self.nonce) return binOut.getBinaryString()
def serialize(self): assert( not self.blockHeader == UNINITIALIZED ) binOut = BinaryPacker() binOut.put(BINARY_CHUNK, self.blockHeader.serialize()) binOut.put(BINARY_CHUNK, self.blockData.serialize()) return binOut.getBinaryString()
def serialize(self): assert (not self.blockHeader == UNINITIALIZED) binOut = BinaryPacker() binOut.put(BINARY_CHUNK, self.blockHeader.serialize()) binOut.put(BINARY_CHUNK, self.blockData.serialize()) return binOut.getBinaryString()
def serialize(self): if self.version == UNINITIALIZED: raise UnitializedBlockDataError, 'PyBlockHeader object not initialized!' binOut = BinaryPacker() binOut.put(UINT32, self.version) binOut.put(BINARY_CHUNK, self.prevBlkHash) binOut.put(BINARY_CHUNK, self.merkleRoot) binOut.put(UINT32, self.timestamp) binOut.put(BINARY_CHUNK, self.diffBits) binOut.put(UINT32, self.nonce) return binOut.getBinaryString()
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()
def serialize(self): bp = BinaryPacker() bp.put(VAR_INT, len(self.addrList)) for netaddr in self.addrList: bp.put(BINARY_CHUNK, netaddr.serialize(), width=30) return bp.getBinaryString()
def serialize(self): bp = BinaryPacker() bp.put(INT8, self.nonSigLength) bp.put(UINT32, self.version) bp.put(UINT64, self.expiration) bp.put(UINT64, self.relayUntil) bp.put(UINT32, self.uniqueID) bp.put(UINT32, self.cancelVal) bp.put(INT8, len(self.cancelSet)) for cancel in self.cancelSet: bp.put(UINT32, cancel) bp.put(UINT32, self.minVersion) bp.put(UINT32, self.maxVersion) bp.put(INT8, len(self.subVerSet)) for subVer in self.subVerSet: bp.put(VAR_STR, subVer) bp.put(UINT32, self.priority) bp.put(VAR_STR, self.comment) bp.put(VAR_STR, self.statusBar) bp.put(VAR_STR, self.reserved) bp.put(VAR_STR, self.signature) return bp.getBinaryString()