Example #1
0
 def _index_transactions(self, blockhash, block=None):
     block_handle = self.get_block_handle(blockhash)
     #Add all transactions to the indexdb
     if not block:
         block = block_handle.get_block()
     size_blockheader = BlockheaderSerializer().get_size(block.blockheader)
     size_tx_size = VarintSerializer().get_size(len(block.transactions))
     tx_serializer = TxSerializer()
     blockpos = block_handle.blockindex.blockpos
     txpos = block_handle.blockindex.blockpos + size_blockheader + size_tx_size 
     
     for i, tx in enumerate(block.transactions):
         txindex = DbTxIndex(1, DiskTxPos(1, blockpos, txpos), [DiskTxPos() for _ in range(tx.output_count())])
         self.indexdb.set_transactionindex(hash_tx(tx), txindex)
         #TODO: speed this up...
         if tx.rawdata:
             txpos += len(tx.rawdata)
         else:
             txpos += tx_serializer.get_size(tx)