Avoid unnecessary work in SetNetworkActive
This commit is contained in:
parent
db825d293b
commit
a2420ae2f1
1 changed files with 6 additions and 4 deletions
10
src/net.cpp
10
src/net.cpp
|
@ -2182,16 +2182,18 @@ void CConnman::SetNetworkActive(bool active)
|
|||
{
|
||||
LogPrint(BCLog::NET, "SetNetworkActive: %s\n", active);
|
||||
|
||||
if (!active) {
|
||||
fNetworkActive = false;
|
||||
if (fNetworkActive == active) {
|
||||
return;
|
||||
}
|
||||
|
||||
fNetworkActive = active;
|
||||
|
||||
if (!fNetworkActive) {
|
||||
LOCK(cs_vNodes);
|
||||
// Close sockets to all nodes
|
||||
for (CNode* pnode : vNodes) {
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
} else {
|
||||
fNetworkActive = true;
|
||||
}
|
||||
|
||||
uiInterface.NotifyNetworkActiveChanged(fNetworkActive);
|
||||
|
|
Loading…
Reference in a new issue