mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
[net/refactor] Simplify multiple-connection checks
Extract logic that check multiple connection types into interface functions & structure as switch statements. This makes it very clear what touch points are for accessing `m_conn_type` & using the switch statements enables the compiler to warn if a new connection type is introduced but not handled for these cases.
This commit is contained in:
parent
7f7b83deb2
commit
2f2e13b6c2
3 changed files with 19 additions and 4 deletions
|
|
@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
|
|||
|
||||
static bool IsOutboundDisconnectionCandidate(const CNode& node)
|
||||
{
|
||||
return !(node.IsInboundConn() || node.IsManualConn() || node.IsFeelerConn() || node.IsAddrFetchConn());
|
||||
return node.IsOutboundOrBlockRelayConn();
|
||||
}
|
||||
|
||||
void PeerLogicValidation::InitializeNode(CNode *pnode) {
|
||||
|
|
@ -2324,7 +2324,7 @@ void ProcessMessage(
|
|||
{
|
||||
connman.SetServices(pfrom.addr, nServices);
|
||||
}
|
||||
if (!pfrom.IsInboundConn() && !pfrom.IsFeelerConn() && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices))
|
||||
if (pfrom.ExpectServicesFromConn() && !HasAllDesirableServiceFlags(nServices))
|
||||
{
|
||||
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom.GetId(), nServices, GetDesirableServiceFlags(nServices));
|
||||
pfrom.fDisconnect = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue