Skip to content

Peer address management across behaviors and connection errors during simultaneous peer startup #6088

Answered by tqwewe
tqwewe asked this question in Q&A
Discussion options

You must be logged in to vote

A simple workaround I implemented for now is to delay calling self.kademlia.remove_address(&peer_id, addr); until 5 seconds later. And if within those 5 seconds, the a connection is established with that peer, then it wont be removed anymore.

pub struct Behaviour {
    kademlia: kad::Behaviour<kad::store::MemoryStore>,
    pending_peers: HashMap<(PeerId, Multiaddr), Instant>,
}

impl NetworkBehaviour for Behaviour {
    // ...

    fn on_swarm_event(&mut self, event: FromSwarm<'_>) {
        match event {
            FromSwarm::ConnectionEstablished(ConnectionEstablished {
                peer_id,
                failed_addresses,
                ..
            }) => {
                self.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jxs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant