compute and send utxo_root with header
authorThomasV <thomasv1@gmx.de>
Sat, 25 Jan 2014 10:27:20 +0000 (11:27 +0100)
committerThomasV <thomasv1@gmx.de>
Sat, 25 Jan 2014 10:27:20 +0000 (11:27 +0100)
backends/bitcoind/blockchain_processor.py
backends/bitcoind/storage.py

index 09644b9..18117fa 100644 (file)
@@ -661,8 +661,8 @@ class BlockchainProcessor(Processor):
                     prev_root_hash = None
 
 
-
         self.header = self.block2header(self.bitcoind('getblock', [self.storage.last_hash]))
+        self.header['utxo_root'] = self.storage.get_root_hash().encode('hex')
 
         if self.shared.stopped(): 
             print_log( "closing database" )
index 691b400..36f1366 100644 (file)
@@ -22,7 +22,6 @@ class Storage(object):
         self.shared = shared
         self.hash_list = {}
         self.parents = {}
-        self.root_hash = None
 
         self.test_reorgs = test_reorgs
         try:
@@ -55,6 +54,11 @@ class Storage(object):
             return
 
 
+        # compute root hash
+        d = self.get_node('')
+        self.root_hash, v = self.get_node_hash('',d,None)
+        print_log("UTXO tree root hash:", self.root_hash.encode('hex'))
+        print_log("Coins in database:", v)
 
     # convert between bitcoin addresses and 20 bytes keys used for storage. 
     def address_to_key(self, addr):