diff options
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/net.cpp b/src/net.cpp index 34dc4aec5c..0ebfefa757 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -235,12 +235,11 @@ bool AddLocal(const CNetAddr &addr, int nScore) return AddLocal(CService(addr, GetListenPort()), nScore); } -bool RemoveLocal(const CService& addr) +void RemoveLocal(const CService& addr) { LOCK(cs_mapLocalHost); LogPrintf("RemoveLocal(%s)\n", addr.ToString()); mapLocalHost.erase(addr); - return true; } /** Make a particular network entirely off-limits (no automatic connects to it) */ @@ -1163,6 +1162,17 @@ void CConnman::ThreadSocketHandler() // { LOCK(cs_vNodes); + + if (!fNetworkActive) { + // Disconnect any connected nodes + for (CNode* pnode : vNodes) { + if (!pnode->fDisconnect) { + LogPrint(BCLog::NET, "Network not active, dropping peer=%d\n", pnode->GetId()); + pnode->fDisconnect = true; + } + } + } + // Disconnect unused nodes std::vector<CNode*> vNodesCopy = vNodes; for (CNode* pnode : vNodesCopy) @@ -2198,14 +2208,6 @@ void CConnman::SetNetworkActive(bool active) fNetworkActive = active; - if (!fNetworkActive) { - LOCK(cs_vNodes); - // Close sockets to all nodes - for (CNode* pnode : vNodes) { - pnode->CloseSocketDisconnect(); - } - } - uiInterface.NotifyNetworkActiveChanged(fNetworkActive); } |