diff options
author | mydesktop <dev.mc2@gmail.com> | 2014-05-26 19:51:22 -0400 |
---|---|---|
committer | mydesktop <dev.mc2@gmail.com> | 2014-05-26 19:51:22 -0400 |
commit | f545fd8ff04d66667c10c7668c0529c578e29db0 (patch) | |
tree | 66dc54e2b7403dffcd6b5f00f76b7addec375a49 /src/cryptonote_core/tx_pool.cpp | |
parent | temporary fix for block reward dos (diff) | |
download | monero-f545fd8ff04d66667c10c7668c0529c578e29db0.tar.xz |
maximum block size 130% of median
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 37f4632a9..a95002dc8 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -357,13 +357,18 @@ namespace cryptonote size_t max_total_size = 2 * median_size - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; // Max block size std::unordered_set<crypto::key_image> k_images; + + // Tx size limit as in wallet2.h + uint64_t upper_transaction_size_limit = ((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 125) / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; + BOOST_FOREACH(transactions_container::value_type& tx, m_transactions) { // Can not exceed maximum block size if (max_total_size < total_size + tx.second.blob_size) continue; - // Check to see if the minimum fee is included + // Check to see if the minimum fee is included; + // exclude tx missing minimum fee if (tx.second.fee < DEFAULT_FEE) continue; @@ -372,14 +377,20 @@ namespace cryptonote // such that it is based on median block size; // We need to make a similar patch for // wallet2.h - uint64_t upper_transaction_size_limit = ((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 125) / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; if (tx.second.blob_size > upper_transaction_size_limit) continue; + // If adding this tx will make the block size + // greater than 130% of the median, reject the + // tx; this will keep down largely punitive tx + // from being included + if ( (total_size + tx.second.blob_size) > ((130 * median_size) / 100) ) + continue; + // If we've exceeded the penalty free size, // stop including more tx if (total_size > median_size) - continue; + break; // Skip transactions that are not ready to be // included into the blockchain or that are |