Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/llmq/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ void CDKGPendingMessages::PushPendingMessage(NodeId from, const uint256& sender_
count++;

seenMessages.emplace(hash);
pendingMessages.emplace_back(from, std::move(pm));
if (from == -1) {
// Our own message must not wait behind a backlog of peer messages before it is relayed
pendingMessages.emplace_front(from, std::move(pm));
} else {
pendingMessages.emplace_back(from, std::move(pm));
}
}

std::list<CDKGPendingMessages::BinaryMessage> CDKGPendingMessages::PopPendingMessages(size_t maxCount)
Expand Down
3 changes: 2 additions & 1 deletion src/llmq/dkgsessionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class CDKGPendingMessages
* Enqueue a serialized DKG message under @p from with content hash @p hash.
* @p sender_protx keys the per-proTx quota: the sender's MNAuth-verified
* proTxHash for remote messages, or this node's own for messages it
* produced itself (@p from == -1). Drops the message silently on quota
* produced itself (@p from == -1), which go to the front of the queue.
* Drops the message silently on quota
* overflow or duplicate hash; quota-dropped messages are not marked seen,
* so another peer with budget can re-deliver them. Caller is responsible
* for hashing the payload and (for real peers) routing the erase-request
Expand Down
17 changes: 17 additions & 0 deletions src/test/llmq_dkg_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ BOOST_AUTO_TEST_CASE(pending_messages_own_messages_share_quota_path)
BOOST_CHECK_EQUAL(pending.PopPendingMessages(3).size(), 2U);
}

BOOST_AUTO_TEST_CASE(pending_messages_own_message_is_processed_first)
{
using namespace llmq;

CDKGPendingMessages pending{/*_maxMessagesPerProTx=*/2};
pending.PushPendingMessage(/*from=*/1, MakeTestHash(0xa1), MakeDKGMessage(), MakeTestHash(1));
pending.PushPendingMessage(/*from=*/2, MakeTestHash(0xa2), MakeDKGMessage(), MakeTestHash(2));
pending.PushPendingMessage(/*from=*/-1, MakeTestHash(0xee), MakeDKGMessage(), MakeTestHash(3));

const auto msgs = pending.PopPendingMessages(3);
BOOST_REQUIRE_EQUAL(msgs.size(), 3U);
auto it = msgs.begin();
BOOST_CHECK_EQUAL((it++)->first, -1);
BOOST_CHECK_EQUAL((it++)->first, 1);
BOOST_CHECK_EQUAL((it++)->first, 2);
}

BOOST_AUTO_TEST_CASE(pending_messages_quota_survives_reconnect)
{
using namespace llmq;
Expand Down
Loading