Пример #1
0
def generateBitfield(bitfield):
    bitfield = binToBinary(bitfield)
    return _createMessageLength(1+len(bitfield))+shortIntToBinary(5)+bitfield
Пример #2
0
 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)