aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.cpp
diff options
context:
space:
mode:
authorZachary Michaels <mikezackles@gmail.com>2014-07-17 11:02:05 -0400
committerZachary Michaels <mikezackles@gmail.com>2014-07-17 16:53:48 -0400
commita3f57648696c522a65fed2cde151a43eab17980d (patch)
tree121c92ac3d4247b0e1f48fb704281d5a110fd7e7 /src/cryptonote_core/tx_pool.cpp
parentUse const where appropriate in tx_pool (diff)
downloadmonero-a3f57648696c522a65fed2cde151a43eab17980d.tar.xz
Add transaction size limit
Transactions larger than the limit will not enter the pool
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r--src/cryptonote_core/tx_pool.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 11e899c1c..5927c9587 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -22,6 +22,11 @@ DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated
namespace cryptonote
{
+ namespace
+ {
+ size_t const TRANSACTION_SIZE_LIMIT = (((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 125) / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE);
+ }
+
//---------------------------------------------------------------------------------
tx_memory_pool::tx_memory_pool(blockchain_storage& bchs): m_blockchain(bchs)
{
@@ -54,6 +59,13 @@ namespace cryptonote
return false;
}
+ if (!kept_by_block && blob_size >= TRANSACTION_SIZE_LIMIT)
+ {
+ LOG_ERROR("transaction is too big: " << blob_size << " bytes, maximum size: " << TRANSACTION_SIZE_LIMIT);
+ tvc.m_verifivation_failed = true;
+ return false;
+ }
+
//check key images for transaction if it is not kept by block
if(!kept_by_block)
{
@@ -446,6 +458,8 @@ namespace cryptonote
//---------------------------------------------------------------------------------
bool tx_memory_pool::init(const std::string& config_folder)
{
+ CRITICAL_REGION_LOCAL(m_transactions_lock);
+
m_config_folder = config_folder;
std::string state_file_path = config_folder + "/" + CRYPTONOTE_POOLDATA_FILENAME;
boost::system::error_code ec;
@@ -456,6 +470,16 @@ namespace cryptonote
{
LOG_PRINT_L0("Failed to load memory pool from file " << state_file_path);
}
+
+ for (auto it = m_transactions.begin(); it != m_transactions.end(); ) {
+ auto it2 = it++;
+ if (it2->second.blob_size >= TRANSACTION_SIZE_LIMIT) {
+ LOG_PRINT_L0("Transaction " << get_transaction_hash(it2->second.tx) << " is too big (" << it2->second.blob_size << " bytes), removing it from pool");
+ remove_transaction_keyimages(it2->second.tx);
+ m_transactions.erase(it2);
+ }
+ }
+
return res;
}