Skip to content

Commit

Permalink
refactor: use atomic to avoid blocking chainlocks cs on each call to …
Browse files Browse the repository at this point in the history
…cleanup
  • Loading branch information
PastaPastaPasta committed Feb 24, 2024
1 parent 3fd913a commit 75d81fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/llmq/chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,8 @@ void CChainLocksHandler::Cleanup()
return;
}

{
LOCK(cs);
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
return;
}
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
return;
}

// need mempool.cs due to GetTransaction calls
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/chainlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CChainLocksHandler : public CRecoveredSigsListener

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

int64_t lastCleanupTime GUARDED_BY(cs) {0};
std::atomic<int64_t> lastCleanupTime{0};

public:
explicit CChainLocksHandler(CChainState& chainstate, CConnman& _connman, CMasternodeSync& mn_sync, CQuorumManager& _qman,
Expand Down

0 comments on commit 75d81fd

Please sign in to comment.