New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]P2PNodesManager: Refine computation of Timeout and nodes choice/disconnection #12720
Conversation
var p2pSourceData = new P2pSourceData(statusCode, duration, node, connectedNodes); | ||
await P2PNodesManager.NotifyDownloadFinishedAsync(p2pSourceData).ConfigureAwait(false); | ||
return new P2pBlockResponse(Block: block, p2pSourceData); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed logging for now, we can log again in P2PNodesManager
. I'd prefer not logging from here, maybe only in case of a success.
@@ -21,10 +24,23 @@ public P2PNodesManager(Network network, NodesGroup nodes, bool isTorEnabled) | |||
private Network Network { get; } | |||
private NodesGroup Nodes { get; } | |||
private bool IsTorEnabled { get; } | |||
private int NodeTimeouts { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information is still stored but at another place, NodeMetadata.Durations
public int? Score { get; set; } = null; | ||
} | ||
|
||
public async Task<Node?> GetBestNodeAsync(CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: This should provide the node with the lowest score or a node that doesn't yet have a score.
{ | ||
DisconnectNode(node, reason); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case there is no information that we can save, it simply means that there were no nodes.
e92d4b7
to
f34c4d8
Compare
I think that the ideas are mostly good but I would place the code elsewhere. The idea behind BDS and removing The hieararchy as I see it:
And yes, the API is not 100 per cent correct but that should not be a reason to hard-wire stuff. So to keep the system agile, I would recommend to implement your "behavior"/"strategy" on top of |
This PR is still relevant, and should be finished, I'm closing it simply because I will not maintain it in a foreseeable future |
This currently includes only the refactoring, the actual computations are not made.
The idea is to keep track of node performances and total blocks downloaded by the nodes, so we can make an informed choice whether to keep it or to disconnect it, to protect privacy while downloading fast.
@kiminuo I'm really interested into what you think of the concept. If it looks good for you, I can go ahead and do some ground work on the actual algorithms. You can also do it if you want :)