X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fdata.py;h=83c1cdc42f2a6fb8b280390f4a18563629330bc8;hb=76b297b65cd33bf972b00820b635b993f28e8133;hp=4c20b7ff3153f0008c5db600188be1d4d690353b;hpb=b676c7000062ae66489a7cd38e01e6a6d79e979a;p=p2pool.git diff --git a/p2pool/data.py b/p2pool/data.py index 4c20b7f..83c1cdc 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -41,19 +41,21 @@ share_type = pack.ComposedType([ def load_share(share, net, peer_addr): assert peer_addr is None or isinstance(peer_addr, tuple) - if share['type'] in [0, 1, 2, 3, 4, 5, 6, 7, 8]: + if share['type'] < Share.VERSION: from p2pool import p2p raise p2p.PeerMisbehavingError('sent an obsolete share') elif share['type'] == Share.VERSION: return Share(net, peer_addr, Share.share_type.unpack(share['contents'])) + elif share['type'] == NewShare.VERSION: + return NewShare(net, peer_addr, NewShare.share_type.unpack(share['contents'])) else: raise ValueError('unknown share type: %r' % (share['type'],)) DONATION_SCRIPT = '4104ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664bac'.decode('hex') -class Share(object): - VERSION = 9 - VOTING_VERSION = 11 +class NewShare(object): + VERSION = 13 + VOTING_VERSION = 13 SUCCESSOR = None small_block_header_type = pack.ComposedType([ @@ -155,8 +157,8 @@ class Share(object): assert base_subsidy is not None share_data = dict(share_data, subsidy=base_subsidy + definite_fees) - weights, total_weight, donation_weight = tracker.get_cumulative_weights(share_data['previous_share_hash'], - min(height, net.REAL_CHAIN_LENGTH), + weights, total_weight, donation_weight = tracker.get_cumulative_weights(previous_share.share_data['previous_share_hash'] if previous_share is not None else None, + min(height, net.REAL_CHAIN_LENGTH-1), 65535*net.SPREAD*bitcoin_data.target_to_average_attempts(block_target), ) assert total_weight == sum(weights.itervalues()) + donation_weight, (total_weight, sum(weights.itervalues()) + donation_weight) @@ -369,7 +371,7 @@ class Share(object): class Share(object): VERSION = 9 VOTING_VERSION = 11 - SUCCESSOR = None + SUCCESSOR = NewShare small_block_header_type = pack.ComposedType([ ('version', pack.VarIntType()),