aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2023-06-27 11:44:58 -0500
committerluigi1111 <luigi1111w@gmail.com>2023-06-27 11:44:58 -0500
commit0fbe21e9e9f28f4011cf0f1afb9db326020e0e25 (patch)
treeb4b006441dbfe56ee3c5873edaa9c0024f551806
parentMerge pull request #8860 (diff)
parentprotocol: drop peers sending duplicate txes (diff)
downloadmonero-0fbe21e9e9f28f4011cf0f1afb9db326020e0e25.tar.xz
Merge pull request #8862
9f80797 protocol: drop peers sending duplicate txes (moneromooo-monero)
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 5dbc614ca..af667dc0c 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -984,8 +984,18 @@ namespace cryptonote
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& context)
{
MLOG_P2P_MESSAGE("Received NOTIFY_NEW_TRANSACTIONS (" << arg.txs.size() << " txes)");
+ std::unordered_set<blobdata> seen;
for (const auto &blob: arg.txs)
+ {
MLOGIF_P2P_MESSAGE(cryptonote::transaction tx; crypto::hash hash; bool ret = cryptonote::parse_and_validate_tx_from_blob(blob, tx, hash);, ret, "Including transaction " << hash);
+ if (seen.find(blob) != seen.end())
+ {
+ LOG_PRINT_CCONTEXT_L1("Duplicate transaction in notification, dropping connection");
+ drop_connection(context, false, false);
+ return 1;
+ }
+ seen.insert(blob);
+ }
if(context.m_state != cryptonote_connection_context::state_normal)
return 1;