[DRAFT] Quit application: Stop P2P faster #10668
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10155
There are 2 commits:
NBitcoin.Kimi
fork7.0.25.1
)Explanation
Now what is happening. We have P2pNetwork.cs where we initialize a
NodesGroup
:WalletWasabi/WalletWasabi/BitcoinP2p/P2pNetwork.cs
Line 97 in 969b6bb
so on NBitcoin's side we start NodesGroup.StartConnecting(). So far so good.
The process of stopping
P2pNetwork
relies on NodesGroup.Disconnect() and there is a slight issue in the NBitcoin impl:... and the issue is that NBitcoin does not cancel connecting of a not-yet-connected node (if there is one) in NodesGroup.StartConnecting. How is that possible? One would expect that:
_Disconnect.Cancel();
stops connecting to any not-yet-connected node, and_ConnectedNodes.DisconnectAll();
disconnects all connected nodes.The issue seems to be in
and the issue is that
_Connection
(NodeConnection
) has its own cancellation token that is not being cancelled byNodesGroup.Disconnect()
(here).And that's why kiminuo/NBitcoin@46dfc4b makes sense to me.