fix rare failure when starting reported by Smoovius
authorForrest Voight <forrest@forre.st>
Sun, 18 Nov 2012 22:37:13 +0000 (17:37 -0500)
committerForrest Voight <forrest@forre.st>
Mon, 19 Nov 2012 15:27:54 +0000 (10:27 -0500)
p2pool/data.py
p2pool/p2p.py

index 652be08..9995e6b 100644 (file)
@@ -311,10 +311,14 @@ class NewNewShare(object):
         return gentx # only used by as_block
     
     def get_other_tx_hashes(self, tracker):
+        if tracker.get_height(self.hash) <= max(x['share_count'] for x in self.share_info['transaction_hash_refs']):
+            return None
         return [tracker.items[tracker.get_nth_parent_hash(self.hash, x['share_count'])].share_info['new_transaction_hashes'][x['tx_count']] for x in self.share_info['transaction_hash_refs']]
     
     def _get_other_txs(self, tracker, known_txs):
         other_tx_hashes = self.get_other_tx_hashes(tracker)
+        if other_tx_hashes is None:
+            return None # not all parents present
         
         if not all(tx_hash in known_txs for tx_hash in other_tx_hashes):
             return None # not all txs present
@@ -849,10 +853,14 @@ class NewShare(object):
         return gentx # only used by as_block
     
     def get_other_tx_hashes(self, tracker):
+        if tracker.get_height(self.hash) <= max(x['share_count'] for x in self.share_info['transaction_hash_refs']):
+            return None
         return [tracker.items[tracker.get_nth_parent_hash(self.hash, x['share_count'])].share_info['new_transaction_hashes'][x['tx_count']] for x in self.share_info['transaction_hash_refs']]
     
     def _get_other_txs(self, tracker, known_txs):
         other_tx_hashes = self.get_other_tx_hashes(tracker)
+        if other_tx_hashes is None:
+            return None # not all parents present
         
         if not all(tx_hash in known_txs for tx_hash in other_tx_hashes):
             return None # not all txs present
index 84ebb00..38ddfed 100644 (file)
@@ -267,7 +267,9 @@ class Protocol(p2protocol.Protocol):
             tx_hashes = set()
             for share in shares:
                 if share.hash in include_txs_with:
-                    tx_hashes.update(share.get_other_tx_hashes(tracker))
+                    x = share.get_other_tx_hashes(tracker)
+                    if x is not None:
+                        tx_hashes.update(x)
             
             hashes_to_send = [x for x in tx_hashes if x not in self.node.mining_txs_var.value and x in known_txs]