Skip to content

Commit

Permalink
chore: dial instead of add into RT
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Dec 13, 2024
1 parent a683c81 commit d61fc8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ant-networking/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,12 @@ impl SwarmDriver {
NetworkSwarmCmd::AddPeerAddresses { addresses, sender } => {
cmd_string = "AddPeerAddresses";
for (peer, addr) in addresses {
let _update = self.swarm.behaviour_mut().kademlia.add_address(&peer, addr);
if let Some(kbucket) = self.swarm.behaviour_mut().kademlia.kbucket(peer) {
let ilog2 = kbucket.range().0.ilog2();
let peers = self.bootstrap_peers.entry(ilog2).or_default();
peers.insert(peer);
}
let _ = self.dial(addr);
}
let _ = sender.send(());
}
Expand Down
9 changes: 8 additions & 1 deletion autonomi/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ impl Client {
if peers_with_p2p.len() < peers_len {
tracing::warn!("Some bootstrap addresses have no peer ID, skipping them");
}
let _ = network.add_peer_addresses(peers_with_p2p).await;

let network_clone = network.clone();
let _handle = ant_networking::target_arch::spawn(async move {
if let Err(err) = network_clone.add_peer_addresses(peers_with_p2p).await {
error!("Failed to add addresses with err: {err:?}");
}
});

Ok(Self {
network,
client_event_sender: Arc::new(None),
evm_network: Default::default(),
})
}

Expand Down

0 comments on commit d61fc8a

Please sign in to comment.