aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-05-16 22:31:31 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-06-07 06:56:21 +0000
commit9f807970865fc4f47c06da94ce866cb1fab0d238 (patch)
tree435401bbbc402d351ffb17d480fd50bb75d587f3 /src
parentMerge pull request #8842 (diff)
downloadmonero-9f807970865fc4f47c06da94ce866cb1fab0d238.tar.xz
protocol: drop peers sending duplicate txes
Diffstat (limited to 'src')
-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 325737789..94a937258 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -979,8 +979,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;