Skip to content

Commit

Permalink
Prevent adding yourself as a peer
Browse files Browse the repository at this point in the history
Updated add_peers_to_comms to prevent adding yourself as a peer

Update builder.rs

Update builder.rs

Update builder.rs

Update builder.rs
  • Loading branch information
StriderDM committed Apr 3, 2020
1 parent 63e1cb9 commit 7e960a2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions applications/tari_base_node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,23 @@ async fn setup_wallet_comms(
}

async fn add_peers_to_comms(comms: &CommsNode, peers: Vec<Peer>) -> Result<(), String> {
let node_identity = (&*comms.node_identity()).clone();
for p in peers {
let peer_desc = p.to_string();
info!(target: LOG_TARGET, "Adding seed peer [{}]", peer_desc);
comms
.peer_manager()
.add_peer(p)
.await
.map_err(|e| format!("Could not add peer {} to comms layer: {}", peer_desc, e))?;

if p.public_key != node_identity.public_key().to_owned() {
comms
.peer_manager()
.add_peer(p)
.await
.map_err(|e| format!("Could not add peer {} to comms layer: {}", peer_desc, e))?;
} else {
info!(
target: LOG_TARGET,
"Attempting to add yourself [{}] as a seed peer to comms layer, ignoring request", peer_desc
);
}
}
Ok(())
}
Expand Down

0 comments on commit 7e960a2

Please sign in to comment.