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([
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)
class Share(object):
VERSION = 9
VOTING_VERSION = 11
- SUCCESSOR = None
+ SUCCESSOR = NewShare
small_block_header_type = pack.ComposedType([
('version', pack.VarIntType()),