mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
perf: NodesSnapshot, do not hold m_nodes_mutex while shuffling
This commit is contained in:
parent
7c00c868d8
commit
c005011e84
@ -5118,16 +5118,16 @@ bool CConnman::IsMasternodeOrDisconnectRequested(const CService& addr) {
|
||||
CConnman::NodesSnapshot::NodesSnapshot(const CConnman& connman, std::function<bool(const CNode* pnode)> filter,
|
||||
bool shuffle)
|
||||
{
|
||||
{
|
||||
LOCK(connman.m_nodes_mutex);
|
||||
m_nodes_copy.reserve(connman.m_nodes.size());
|
||||
|
||||
for (auto& node : connman.m_nodes) {
|
||||
if (!filter(node))
|
||||
continue;
|
||||
if (!filter(node)) continue;
|
||||
node->AddRef();
|
||||
m_nodes_copy.push_back(node);
|
||||
}
|
||||
|
||||
}
|
||||
if (shuffle) {
|
||||
Shuffle(m_nodes_copy.begin(), m_nodes_copy.end(), FastRandomContext{});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user