mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 02:49:27 -05:00
protocol: drop peers sending duplicate txes
This commit is contained in:
parent
94e67bf96b
commit
9f80797086
@ -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)
|
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)");
|
MLOG_P2P_MESSAGE("Received NOTIFY_NEW_TRANSACTIONS (" << arg.txs.size() << " txes)");
|
||||||
|
std::unordered_set<blobdata> seen;
|
||||||
for (const auto &blob: arg.txs)
|
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);
|
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)
|
if(context.m_state != cryptonote_connection_context::state_normal)
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user