Skip to content

Commit

Permalink
Increase the new txns per share size limit to 100 kB
Browse files Browse the repository at this point in the history
  • Loading branch information
veqtrus committed Feb 28, 2017
1 parent a50c0f3 commit f6a6ea0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions p2pool/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ class BaseShare(object):
VERSION = 0
VOTING_VERSION = 0
SUCCESSOR = None


MAX_BLOCK_WEIGHT = 4000000
MAX_NEW_TXS_SIZE = 50000

small_block_header_type = pack.ComposedType([
('version', pack.VarIntType()),
('previous_block', pack.PossiblyNoneType(0, pack.IntType(256))),
Expand Down Expand Up @@ -166,7 +169,7 @@ def generate_transaction(cls, tracker, share_data, block_target, desired_timesta
else:
if known_txs is not None:
this_size = bitcoin_data.tx_type.packed_size(known_txs[tx_hash])
if new_transaction_size + this_size > 50000: # only allow 50 kB of new txns/share
if new_transaction_size + this_size > cls.MAX_NEW_TXS_SIZE: # limit the size of new txns/share
break
new_transaction_size += this_size
new_transaction_hashes.append(tx_hash)
Expand Down Expand Up @@ -411,11 +414,11 @@ def should_punish_reason(self, previous_block, bits, tracker, known_txs):
else:
all_txs_size = sum(bitcoin_data.tx_type.packed_size(tx) for tx in other_txs)
stripped_txs_size = sum(bitcoin_data.tx_id_type.packed_size(tx) for tx in other_txs)
if all_txs_size + 3 * stripped_txs_size > 4000000:
if all_txs_size + 3 * stripped_txs_size > self.MAX_BLOCK_WEIGHT:
return True, 'txs over block size limit'

new_txs_size = sum(bitcoin_data.tx_type.packed_size(known_txs[tx_hash]) for tx_hash in self.share_info['new_transaction_hashes'])
if new_txs_size > 50000:
if new_txs_size > self.MAX_NEW_TXS_SIZE:
return True, 'new txs over limit'

return False, None
Expand All @@ -430,6 +433,7 @@ class NewShare(BaseShare):
VERSION = 17
VOTING_VERSION = 17
SUCCESSOR = None
MAX_NEW_TXS_SIZE = 100000

class Share(BaseShare):
VERSION = 16
Expand Down

0 comments on commit f6a6ea0

Please sign in to comment.