stop if an exception occurs other than KeyError
[electrum-server.git] / backends / bitcoind / blockchain_processor.py
index 32cc4f2..9a14ded 100644 (file)
@@ -68,6 +68,7 @@ class BlockchainProcessor(Processor):
             print_log('initializing database')
             self.height = 0
             self.last_hash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
+            db_version = self.db_version
 
         # check version
         if self.db_version != db_version:
@@ -426,6 +427,7 @@ class BlockchainProcessor(Processor):
                 serialized_hist = serialized_hist[0:80*i] + new_item + serialized_hist[80*(i+1):]
                 break
         else:
+            self.shared.stop()
             hist = self.deserialize(serialized_hist)
             raise BaseException("prevout not found", addr, hist, txi.encode('hex'))
 
@@ -493,10 +495,14 @@ class BlockchainProcessor(Processor):
             for txi in block_inputs:
                 try:
                     addr = self.db.Get(txi)
-                except:
-                    # print "addr not in db", txi.encode('hex')
+                except KeyError:
                     # the input could come from the same block
                     continue
+                except:
+                    traceback.print_exc(file=sys.stdout)
+                    self.shared.stop()
+                    raise
+
                 self.batch_txio[txi] = addr
                 addr_to_read.append(addr)
 
@@ -525,8 +531,12 @@ class BlockchainProcessor(Processor):
         for addr in addr_to_read:
             try:
                 self.batch_list[addr] = self.db.Get(addr)
-            except:
+            except KeyError:
                 self.batch_list[addr] = ''
+            except:
+                traceback.print_exc(file=sys.stdout)
+                self.shared.stop()
+                raise
 
 
         # process