From b76705cb42e79b7ffc6c65f6eb2a49605e17585e Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Mon, 15 Aug 2011 02:01:26 -0400 Subject: [PATCH] compensate for old shares being forgotton in stale calculations --- p2pool/bitcoin/data.py | 8 ++++++++ p2pool/main.py | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/p2pool/bitcoin/data.py b/p2pool/bitcoin/data.py index e87f2eb..e520c19 100644 --- a/p2pool/bitcoin/data.py +++ b/p2pool/bitcoin/data.py @@ -736,6 +736,14 @@ class Tracker(object): def get_highest_height(self): return max(self.get_height_and_last(head)[0] for head in self.heads) if self.heads else 0 + + def is_child_of(self, share_hash, possible_child_hash): + height, last = self.get_height_and_last(share_hash) + child_height, child_last = self.get_height_and_last(possible_child_hash) + if child_last != last: + return None # not connected, so can't be determined + height_up = child_height - height + return height_up >= 0 and self.get_nth_parent_hash(possible_child_hash, height_up) == share_hash class FakeShare(object): def __init__(self, **kwargs): diff --git a/p2pool/main.py b/p2pool/main.py index 1c41f93..a03c568 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -343,12 +343,17 @@ def main(args): run_identifier = struct.pack('