aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorCory Fields <[email protected]>2017-10-04 18:25:34 -0400
committerCarl Dong <[email protected]>2019-01-16 11:04:05 -0500
commit7cc2b9f6786f9bc33853220551eed33ca6b7b7b2 (patch)
tree93ed4cf7b37c8994fefc4fb31eac75acea9f7329 /src/net.cpp
parentMerge #15122: [RPC] Expand help text for importmulti changes (diff)
downloaddiscoin-7cc2b9f6786f9bc33853220551eed33ca6b7b7b2.tar.xz
discoin-7cc2b9f6786f9bc33853220551eed33ca6b7b7b2.zip
net: Break disconnecting out of Ban()
These are separate events which need to be carried out by separate subsystems. This also cleans up some whitespace and tabs in qt to avoid getting flagged by the linter. Current behavior is preserved.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 98bd518ec..6f0d76ccf 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -554,13 +554,6 @@ void CConnman::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t ba
}
if(clientInterface)
clientInterface->BannedListChanged();
- {
- LOCK(cs_vNodes);
- for (CNode* pnode : vNodes) {
- if (subNet.Match(static_cast<CNetAddr>(pnode->addr)))
- pnode->fDisconnect = true;
- }
- }
if(banReason == BanReasonManuallyAdded)
DumpBanlist(); //store banlist to disk immediately if user requested ban
}
@@ -2643,6 +2636,25 @@ bool CConnman::DisconnectNode(const std::string& strNode)
}
return false;
}
+
+bool CConnman::DisconnectNode(const CSubNet& subnet)
+{
+ bool disconnected = false;
+ LOCK(cs_vNodes);
+ for (CNode* pnode : vNodes) {
+ if (subnet.Match(pnode->addr)) {
+ pnode->fDisconnect = true;
+ disconnected = true;
+ }
+ }
+ return disconnected;
+}
+
+bool CConnman::DisconnectNode(const CNetAddr& addr)
+{
+ return DisconnectNode(CSubNet(addr));
+}
+
bool CConnman::DisconnectNode(NodeId id)
{
LOCK(cs_vNodes);