Skip to content
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: fix identify disconnect #3052

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion network/src/protocols/identify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ impl Callback for IdentifyCallback {
// it is possible that the node will be accidentally evicted, so it is necessary
// to reset the information of the node when disconnected.
self.network_state.with_peer_store_mut(|peer_store| {
peer_store.add_outbound_addr(context.session.address.clone());
if !peer_store.is_addr_banned(&context.session.address) {
peer_store.add_outbound_addr(context.session.address.clone());
}
});
}
}
Expand Down
10 changes: 9 additions & 1 deletion network/src/protocols/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,16 @@ fn test_identify_behavior() {
wait_connect_state(&node1, 1);
wait_connect_state(&node2, 0);

if !wait_until(10, || {
node1.network_state.with_peer_store_mut(|peer_store| {
peer_store.is_addr_banned(&node2.listen_addr)
&& peer_store.addr_manager().get(&node2.listen_addr).is_none()
})
}) {
panic!("identify can't ban not same net")
}

let sessions = node3.connected_sessions();
assert_eq!(sessions.len(), 1);
driftluo marked this conversation as resolved.
Show resolved Hide resolved

if !wait_until(10, || node3.connected_protocols(sessions[0]).len() == 4) {
panic!("identify can't open other protocols")
Expand Down