fix a few bugs
authorThomasV <thomasv@gitorious>
Wed, 14 Nov 2012 12:13:09 +0000 (16:13 +0400)
committerThomasV <thomasv@gitorious>
Wed, 14 Nov 2012 12:13:09 +0000 (16:13 +0400)
backends/bitcoind/blockchain_processor.py
processor.py

index 5a88bc3..1ad48f3 100644 (file)
@@ -110,7 +110,7 @@ class BlockchainProcessor(Processor):
 
     def block2header(self, b):
         return {"block_height":b.get('height'), "version":b.get('version'), "prev_block_hash":b.get('previousblockhash'), 
-                "merkle_root":b.get('merkleroot'), "timestamp":b.get('time'), "bits":b.get('bits'), "nonce":b.get('nonce')}
+                "merkle_root":b.get('merkleroot'), "timestamp":b.get('time'), "bits":int(b.get('bits'),16), "nonce":b.get('nonce')}
 
 
     def get_header(self, height):
@@ -154,7 +154,7 @@ class BlockchainProcessor(Processor):
         for txid in self.mempool_hist.get(addr,[]):
             hist.append((txid, 0))
 
-        hist = map(lambda x: {'tx_hash':x[0], 'height':x[1]}, hist)
+        hist = map(lambda x: {'tx_hash':x[0], 'height':x[2]}, hist)
         with self.cache_lock: self.history_cache[addr] = hist
         return hist
 
@@ -372,13 +372,13 @@ class BlockchainProcessor(Processor):
         elif method == 'blockchain.address.subscribe2':
             try:
                 address = params[0]
-                result = self.get_status2(address, cache_only)
+                result = self.get_status(address, cache_only)
                 self.watch_address(address)
             except BaseException, e:
                 error = str(e) + ': ' + address
                 print_log( "error:", error )
 
-        elif method == 'blockchain.address.get_history':
+        elif method == 'blockchain.address.get_history2':
             try:
                 address = params[0]
                 result = self.get_history( address, cache_only )
index e7a340c..9d1355d 100644 (file)
@@ -183,9 +183,9 @@ class RequestDispatcher(threading.Thread):
             except:
                 pass
 
-        if session.protocol_version < 0.6:
-            print_log("stopping session from old client")
-            session.stop()
+            if session.protocol_version < 0.6:
+                print_log("stopping session from old client", session.protocol_version)
+                session.stop()
 
     def get_sessions(self):
         with self.lock: