fix sql request in get_merkle
authorThomasV <thomasv@gitorious>
Sat, 27 Oct 2012 08:39:53 +0000 (12:39 +0400)
committerThomasV <thomasv@gitorious>
Sat, 27 Oct 2012 08:39:53 +0000 (12:39 +0400)
backends/abe/__init__.py
transports/stratum_tcp.py

index 2e4e806..91435fd 100644 (file)
@@ -470,7 +470,9 @@ class AbeStore(Datastore_class):
              JOIN block_tx on tx.tx_id = block_tx.tx_id 
              JOIN chain_summary on chain_summary.block_id = block_tx.block_id
              WHERE tx_hash='%s' AND in_longest = 1"""%tx_hash)
-        block_id = out[0]
+
+        if not out: raise BaseException("not in a block")
+        block_id = int(out[0][0])
 
         # get block height
         out = self.safe_sql("SELECT block_height FROM chain_summary WHERE block_id = %d AND in_longest = 1"%block_id)
@@ -691,7 +693,9 @@ class BlockchainProcessor(Processor):
     def run_store_iteration(self):
         
         try:
+            t1 = time.time()
             block_header = self.store.main_iteration()
+            t2 = time.time() - t1
         except:
             traceback.print_exc(file=sys.stdout)
             print "terminating"
@@ -703,13 +707,14 @@ class BlockchainProcessor(Processor):
 
         if self.block_number != block_header.get('block_height'):
             self.block_number = block_header.get('block_height')
-            print "block number:", self.block_number
+            print "block number: %d  (%.3f seconds)"%(self.block_number, t2)
             self.push_response({ 'id': None, 'method':'blockchain.numblocks.subscribe', 'params':[self.block_number] })
 
         if self.block_header != block_header:
             self.block_header = block_header
             self.push_response({ 'id': None, 'method':'blockchain.headers.subscribe', 'params':[self.block_header] })
 
+
         while True:
             try:
                 addr = self.store.address_queue.get(False)
index 0aebc0f..e1ebcd1 100644 (file)
@@ -10,7 +10,6 @@ class TcpSession(Session):
 
     def __init__(self, connection, address, use_ssl, ssl_certfile, ssl_keyfile):
         Session.__init__(self)
-        print connection, address, use_ssl
         if use_ssl:
             import ssl
             self._connection = ssl.wrap_socket(