aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-02-24 11:55:54 +0200
committerRiccardo Spagni <ric@spagni.net>2017-02-24 11:55:54 +0200
commit2b38973b5cca207bb03581993f0ad4672ecbd2e0 (patch)
tree8396a3c5357b651db0f605aa72aa2a74bf51d349 /src/cryptonote_core/cryptonote_core.cpp
parentbc8d3252169f55bbe40df247fb39143fab5bb6f0 (diff)
parent9effa55311a97aeb3f9bcbb8eeec4d8daac0d632 (diff)
downloadmonzero-core-2b38973b5cca207bb03581993f0ad4672ecbd2e0.tar.gz
monzero-core-2b38973b5cca207bb03581993f0ad4672ecbd2e0.tar.xz
monzero-core-2b38973b5cca207bb03581993f0ad4672ecbd2e0.zip
Merge pull request #1779
9effa553 core: bound the amount of entries in bad tx semantics cache (moneromooo-monero) 240054a7 core: remove a couple unused/obsolete bits (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 98c53890e..cfe3b5441 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -60,6 +60,8 @@ DISABLE_VS_WARNINGS(4355)
#define MERROR_VER(x) MCERROR("verify", x)
+#define BAD_SEMANTICS_TXES_MAX_SIZE 100
+
namespace cryptonote
{
@@ -496,11 +498,14 @@ namespace cryptonote
}
//std::cout << "!"<< tx.vin.size() << std::endl;
- if (bad_semantics_txes.find(tx_hash) != bad_semantics_txes.end())
+ for (int idx = 0; idx < 2; ++idx)
{
- LOG_PRINT_L1("Transaction already seen with bad semantics, rejected");
- tvc.m_verifivation_failed = true;
- return false;
+ if (bad_semantics_txes[idx].find(tx_hash) != bad_semantics_txes[idx].end())
+ {
+ LOG_PRINT_L1("Transaction already seen with bad semantics, rejected");
+ tvc.m_verifivation_failed = true;
+ return false;
+ }
}
uint8_t version = m_blockchain_storage.get_current_hard_fork_version();
@@ -551,8 +556,13 @@ namespace cryptonote
if(!check_tx_semantic(tx, keeped_by_block))
{
LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected");
- bad_semantics_txes.insert(tx_hash);
tvc.m_verifivation_failed = true;
+ bad_semantics_txes[0].insert(tx_hash);
+ if (bad_semantics_txes[0].size() >= BAD_SEMANTICS_TXES_MAX_SIZE)
+ {
+ std::swap(bad_semantics_txes[0], bad_semantics_txes[1]);
+ bad_semantics_txes[0].clear();
+ }
return false;
}