Skip to content

Commit

Permalink
Ensure clients request peers from bootstrap peers
Browse files Browse the repository at this point in the history
  • Loading branch information
vicsn committed Jun 13, 2024
1 parent 62bfb92 commit efd5ef0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions node/src/client/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use snarkos_node_router::{
DataBlocks,
DisconnectReason,
MessageCodec,
PeerRequest,
Ping,
Pong,
PuzzleResponse,
Expand Down Expand Up @@ -66,6 +67,10 @@ where
async fn on_connect(&self, peer_addr: SocketAddr) {
// Resolve the peer address to the listener address.
let Some(peer_ip) = self.router.resolve_to_listener(&peer_addr) else { return };
// If it's a bootstrap peer, first request its peers.
if self.router.bootstrap_peers().contains(&peer_ip) {
Outbound::send(self, peer_ip, Message::PeerRequest(PeerRequest));
}
// Retrieve the block locators.
let block_locators = match self.sync.get_block_locators() {
Ok(block_locators) => Some(block_locators),
Expand Down

0 comments on commit efd5ef0

Please sign in to comment.