From ebddbabf8f859c24ebdc703c3fbb807ac6055800 Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 18 Nov 2012 17:37:13 -0500 Subject: [PATCH] fix rare failure when starting reported by Smoovius --- p2pool/data.py | 8 ++++++++ p2pool/p2p.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/p2pool/data.py b/p2pool/data.py index 652be08..9995e6b 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -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 diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 84ebb00..38ddfed 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -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] -- 1.7.1