-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix the duplicate connection bug #499
base: master
Are you sure you want to change the base?
Conversation
@@ -476,22 +476,27 @@ impl NetworkExtension<Event> for Extension { | |||
cinfo!(SYNC, "New peer detected #{}", id); | |||
self.send_status(id); | |||
|
|||
let t = self.connected_nodes.insert(*id); | |||
debug_assert!(t, "{} is already added to peer list", id); | |||
if !self.connected_nodes.contains(id) { |
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.
@MSNTCS
It seems this patch is avoiding the error case. Not fixing the error.
When the on_node_added
is called, it should not be included in connected_nodes
.
Could you try to fix this problem fundamentally?
I met this error while running I'll run the same test in the current master.
|
network/src/p2p/handler.rs
Outdated
let t = inbound_connections.insert(token, connection); | ||
assert!(t.is_none()); | ||
io.register_stream(token); | ||
let mut can_insert: bool = true; |
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.
let can_insert = inbound_connections.values().all(|in_connection| {
in_connection.peer_addr() != connection.peer_addr()
});
let is_not_out = outbound_connections.values().all(|out_connection| {
out_connection.peer_addr() != connection.peer_addr()
});
In this pr, we try to address this issue #274.