def generateBitfield(bitfield): bitfield = binToBinary(bitfield) return _createMessageLength(1+len(bitfield))+shortIntToBinary(5)+bitfield
def _persist(self): if self.shouldPersist and self.allowedToPersist: binaryBitfield = binToBinary( "".join((str(int(pieceIndex in self.gotPieces)) for pieceIndex in xrange(0, self.pieceAmount))) ) self.btPersister.store("PersistentStatus-bitfield", binaryBitfield)