Skip to content

Commit 9b49bfd

Browse files
committed
Only track last seen time instead of first and last seen time (#3165)
This avoids timeouts on parts of the network
1 parent ad720ee commit 9b49bfd

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/llmq/quorums_signing_shares.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -676,18 +676,10 @@ void CSigSharesManager::ProcessSigShare(NodeId nodeId, const CSigShare& sigShare
676676
if (!sigShares.Add(sigShare.GetKey(), sigShare)) {
677677
return;
678678
}
679-
680679
sigSharesToAnnounce.Add(sigShare.GetKey(), true);
681680

682-
auto it = timeSeenForSessions.find(sigShare.GetSignHash());
683-
if (it == timeSeenForSessions.end()) {
684-
auto t = GetTimeMillis();
685-
// insert first-seen and last-seen time
686-
timeSeenForSessions.emplace(sigShare.GetSignHash(), std::make_pair(t, t));
687-
} else {
688-
// update last-seen time
689-
it->second.second = GetTimeMillis();
690-
}
681+
// Update the time we've seen the last sigShare
682+
timeSeenForSessions[sigShare.GetSignHash()] = GetTimeMillis();
691683

692684
if (!quorumNodes.empty()) {
693685
// don't announce and wait for other nodes to request this share and directly send it to them
@@ -1215,10 +1207,9 @@ void CSigSharesManager::Cleanup()
12151207
std::unordered_set<uint256, StaticSaltedHasher> timeoutSessions;
12161208
for (auto& p : timeSeenForSessions) {
12171209
auto& signHash = p.first;
1218-
int64_t firstSeenTime = p.second.first;
1219-
int64_t lastSeenTime = p.second.second;
1210+
int64_t lastSeenTime = p.second;
12201211

1221-
if (now - firstSeenTime >= SESSION_TOTAL_TIMEOUT || now - lastSeenTime >= SESSION_NEW_SHARES_TIMEOUT) {
1212+
if (now - lastSeenTime >= SESSION_NEW_SHARES_TIMEOUT) {
12221213
timeoutSessions.emplace(signHash);
12231214
}
12241215
}

src/llmq/quorums_signing_shares.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ class CSigSharesNodeState
330330
class CSigSharesManager : public CRecoveredSigsListener
331331
{
332332
static const int64_t SESSION_NEW_SHARES_TIMEOUT = 60 * 1000;
333-
static const int64_t SESSION_TOTAL_TIMEOUT = 5 * 60 * 1000;
334333
static const int64_t SIG_SHARE_REQUEST_TIMEOUT = 5 * 1000;
335334

336335
// we try to keep total message size below 10k
@@ -348,8 +347,8 @@ class CSigSharesManager : public CRecoveredSigsListener
348347

349348
SigShareMap<CSigShare> sigShares;
350349

351-
// stores time of first and last receivedSigShare. Used to detect timeouts
352-
std::unordered_map<uint256, std::pair<int64_t, int64_t>, StaticSaltedHasher> timeSeenForSessions;
350+
// stores time of last receivedSigShare. Used to detect timeouts
351+
std::unordered_map<uint256, int64_t, StaticSaltedHasher> timeSeenForSessions;
353352

354353
std::unordered_map<NodeId, CSigSharesNodeState> nodeStates;
355354
SigShareMap<std::pair<NodeId, int64_t>> sigSharesRequested;

0 commit comments

Comments
 (0)