aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2017-07-14 15:00:19 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2017-07-14 15:01:05 +0100
commita2420ae2f1e0fd9a257a0a506ff40a4dca842474 (patch)
tree04bede6e1a13fd2659350df5f835fafb39257cb5 /src/net.cpp
parentdb825d293be8134505187352ec5844b70f37a43f (diff)
Avoid unnecessary work in SetNetworkActive
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 5bf3af7ea3..756de4400e 100644
--- a/src/net.cpp
+++ b/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);