Skip to content

Commit 3c818e9

Browse files
authored
Only track last seen time instead of first and last seen time (#3165)
This avoids timeouts on parts of the network
1 parent df3dbe8 commit 3c818e9

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
@@ -675,18 +675,10 @@ void CSigSharesManager::ProcessSigShare(NodeId nodeId, const CSigShare& sigShare
675675
if (!sigShares.Add(sigShare.GetKey(), sigShare)) {
676676
return;
677677
}
678-
679678
sigSharesToAnnounce.Add(sigShare.GetKey(), true);
680679

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

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

1220-
if (now - firstSeenTime >= SESSION_TOTAL_TIMEOUT || now - lastSeenTime >= SESSION_NEW_SHARES_TIMEOUT) {
1211+
if (now - lastSeenTime >= SESSION_NEW_SHARES_TIMEOUT) {
12211212
timeoutSessions.emplace(signHash);
12221213
}
12231214
}

src/llmq/quorums_signing_shares.h

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

335334
// we try to keep total message size below 10k
@@ -347,8 +346,8 @@ class CSigSharesManager : public CRecoveredSigsListener
347346

348347
SigShareMap<CSigShare> sigShares;
349348

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

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

0 commit comments

Comments
 (0)