Skip to content

Commit

Permalink
[net] Add Disconnection methods to CNode
Browse files Browse the repository at this point in the history
Add Disconnect(), IsDisconnecting() and CancelDisconnect() methods to
the CNode class. A future commit will make fDisconnect private.
  • Loading branch information
jnewbery committed Feb 8, 2022
1 parent 5034b7f commit 563bec8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,18 @@ class CNode
m_min_ping_time = std::min(m_min_ping_time.load(), ping_time);
}

template <typename... Args>
void Disconnect(const char* message, const Args&... args)
{
LogPrint(BCLog::NET, "Disconnecting peer=%d: ", id); /* Continued */
LogPrint(BCLog::NET, message, args...); /* Continued */
LogPrint(BCLog::NET, "/n");
fDisconnect = true;
}
bool IsDisconnecting() const { return fDisconnect; }
/** Only used in tests. TODO: remove. */
void CancelDisconnect() { fDisconnect=false; }

private:
const NodeId id;
const uint64_t nLocalHostNonce;
Expand Down

0 comments on commit 563bec8

Please sign in to comment.