def pprint(self, nIndent=0, endian=BIGENDIAN): indstr = indent*nIndent print indstr + 'BlockHeader:' print indstr + indent + 'Version: ', self.version print indstr + indent + 'ThisHash: ', binary_to_hex( self.theHash, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'PrevBlock: ', binary_to_hex(self.prevBlkHash, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'MerkRoot: ', binary_to_hex(self.merkleRoot, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'Timestamp: ', self.timestamp fltDiff = binaryBits_to_difficulty(self.diffBits) print indstr + indent + 'Difficulty:', fltDiff, '('+binary_to_hex(self.diffBits)+')' print indstr + indent + 'Nonce: ', self.nonce if not self.blkHeight==UNINITIALIZED: print indstr + indent + 'BlkHeight: ', self.blkHeight if not self.blkHeight==UNINITIALIZED: print indstr + indent + 'BlkFileLoc:', self.fileByteLoc if not self.nextBlkHash==UNINITIALIZED: #print indstr + indent + 'NextBlock: ', binary_to_hex(self.nextBlkHash) print indstr + indent + 'NextBlock: ', self.nextBlkHash if not self.numTx==UNINITIALIZED: print indstr + indent + 'NumTx: ', self.numTx if not self.intDifficult==UNINITIALIZED: print indstr + indent + 'Difficulty:', self.intDifficult if not self.sumDifficult==UNINITIALIZED: print indstr + indent + 'DiffSum: ', self.sumDifficult
def pprint(self, nIndent=0, endian=BIGENDIAN): indstr = indent * nIndent print indstr + 'BlockHeader:' print indstr + indent + 'Version: ', self.version print indstr + indent + 'ThisHash: ', binary_to_hex( self.theHash, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'PrevBlock: ', binary_to_hex(self.prevBlkHash, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'MerkRoot: ', binary_to_hex(self.merkleRoot, endOut=endian), \ '(BE)' if endian==BIGENDIAN else '(LE)' print indstr + indent + 'Timestamp: ', self.timestamp fltDiff = binaryBits_to_difficulty(self.diffBits) print indstr + indent + 'Difficulty:', fltDiff, '(' + binary_to_hex( self.diffBits) + ')' print indstr + indent + 'Nonce: ', self.nonce if not self.blkHeight == UNINITIALIZED: print indstr + indent + 'BlkHeight: ', self.blkHeight if not self.blkHeight == UNINITIALIZED: print indstr + indent + 'BlkFileLoc:', self.fileByteLoc if not self.nextBlkHash == UNINITIALIZED: #print indstr + indent + 'NextBlock: ', binary_to_hex(self.nextBlkHash) print indstr + indent + 'NextBlock: ', self.nextBlkHash if not self.numTx == UNINITIALIZED: print indstr + indent + 'NumTx: ', self.numTx if not self.intDifficult == UNINITIALIZED: print indstr + indent + 'Difficulty:', self.intDifficult if not self.sumDifficult == UNINITIALIZED: print indstr + indent + 'DiffSum: ', self.sumDifficult
def getDifficulty(self): if self.diffBits == UNINITIALIZED: raise UnitializedBlockDataError, 'PyBlockHeader object not initialized!' self.intDifficult = binaryBits_to_difficulty(self.diffBits) return self.intDifficult