Skip to content

Commit 75d81fd

Browse files
refactor: use atomic to avoid blocking chainlocks cs on each call to cleanup
1 parent 3fd913a commit 75d81fd

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/llmq/chainlocks.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,8 @@ void CChainLocksHandler::Cleanup()
617617
return;
618618
}
619619

620-
{
621-
LOCK(cs);
622-
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
623-
return;
624-
}
620+
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
621+
return;
625622
}
626623

627624
// need mempool.cs due to GetTransaction calls

src/llmq/chainlocks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
8282

8383
std::map<uint256, int64_t> seenChainLocks GUARDED_BY(cs);
8484

85-
int64_t lastCleanupTime GUARDED_BY(cs) {0};
85+
std::atomic<int64_t> lastCleanupTime{0};
8686

8787
public:
8888
explicit CChainLocksHandler(CChainState& chainstate, CConnman& _connman, CMasternodeSync& mn_sync, CQuorumManager& _qman,

0 commit comments

Comments
 (0)