Not blocking, but this seemed slightly more correct to me before, since now if fNetworkActive == false
when caching the result, but true
when disconnecting, we might not attempt v1 reconnect when we should have.
The probability that someone will be able to toggle fNetworkActive
false -> true
between the first loop starting and the second loop, when one also happens to have a peer in the right step in the handshake.. just doesn’t feel like it should be something we need to support. By keeping it “atomic” we compress down from 4 to 2 permutations.
Counter-example - Running V1 with V2 capable node
On master
, one could contrive the possibility of having a V2 peer which we are handshaking with,
- User toggles
fNetworkActive
true -> false
.
- Making
CConnman::DisconnectNodes()
:
a. Set pnode->fDisconnect = true
.
b. Queue a v1 reconnection attempt.
- User toggles
fNetworkActive
false -> true
before we process reconnections.
- We now end up using V1 with a peer capable of V2.
Behavior with current version of this PR in this case will be to drop the V2 peer and not attempt immediate reconnection.
(If we instead read fNetworkActive
a second time when checking for reconnection like this PR did initially, on could reorder 2.b. and 3. in the above example to run into the same issue).