From: Forrest Voight Date: Wed, 28 Nov 2012 07:29:33 +0000 (-0500) Subject: fixed bug, speeding up share loading and verification by 50% X-Git-Tag: 9.2~4 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=1139df0910d05cf138dfca9265c9a60d7bc15832 fixed bug, speeding up share loading and verification by 50% --- diff --git a/p2pool/data.py b/p2pool/data.py index a68eedf..44ddbc4 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -236,10 +236,12 @@ class Share(object): self.new_script = bitcoin_data.pubkey_hash_to_script2(self.share_data['pubkey_hash']) self.desired_version = self.share_data['desired_version'] + n = set() for x in self.share_info['transaction_hash_refs']: assert x['share_count'] < 110 - for i, x in enumerate(self.share_info['new_transaction_hashes']): - assert dict(share_count=0, tx_count=i) in self.share_info['transaction_hash_refs'] + if x['share_count'] == 0: + n.add(x['tx_count']) + assert n == set(range(len(self.share_info['new_transaction_hashes']))) self.gentx_hash = check_hash_link( self.hash_link, diff --git a/p2pool/util/pack.py b/p2pool/util/pack.py index 2762605..0c50fc2 100644 --- a/p2pool/util/pack.py +++ b/p2pool/util/pack.py @@ -265,22 +265,26 @@ def get_record(fields): if isinstance(other, dict): return dict(self) == other elif isinstance(other, _Record): - return all(self[k] == other[k] for k in self.keys()) + for k in fields: + if getattr(self, k) != getattr(other, k): + return False + return True elif other is None: return False raise TypeError() def __ne__(self, other): return not (self == other) _record_types[fields] = _Record - return _record_types[fields]() + return _record_types[fields] class ComposedType(Type): def __init__(self, fields): - self.fields = tuple(fields) + self.fields = list(fields) self.field_names = set(k for k, v in fields) + self.record_type = get_record(k for k, v in self.fields) def read(self, file): - item = get_record(k for k, v in self.fields) + item = self.record_type() for key, type_ in self.fields: item[key], file = type_.read(file) return item, file