CConnman::AlreadyConnectedToAddress() searches the existent nodes by address or by address-and-port:
0FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringAddrPort())
but:
- if there is a match by just the address, then the address-and-port search will not be evaluated and the whole condition will be
true - if the there is no node with the same address, then the second search by address-and-port will not find a match either.
The search by address-and-port is comparing against CNode::m_addr_name which could be a hostname, e.g. "node.foobar.com:8333", but addr.ToStringAddrPort() is always going to be numeric.
In other words: let A be “CNetAddr equals” and B be “addr:port string matches”, then:
- If
A(istrue), thenBis irrelevant, so the conditionA || Bis equivalent toAistrue. - Observation in this PR: if
!A(Aisfalse), then!Bfor sure, thus the conditionA || Bis equivalent toAisfalse.
So, simplify A || B to A.
https://en.wikipedia.org/wiki/Modus_tollens !A => !B is equivalent to B => A. So the added fuzz test asserts that if B is true, then A is true.