Skip to content

Commit

Permalink
Merge pull request #4795 from eval-exec/exec/get-peers-dedup
Browse files Browse the repository at this point in the history
`NetRpcImpl::get_peers` return `Remoteaddress.addresses` dedup
  • Loading branch information
quake authored Jan 24, 2025
2 parents b44d2d2 + 9508269 commit 05aa7b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rpc/src/module/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use ckb_systemtime::unix_time_as_millis;
use ckb_types::prelude::{Pack, Unpack};
use jsonrpc_core::Result;
use jsonrpc_utils::rpc;
use std::collections::HashSet;
use std::sync::Arc;

const MAX_ADDRS: usize = 50;
Expand Down Expand Up @@ -586,8 +587,9 @@ impl NetRpc for NetRpcImpl {
.connected_peers()
.iter()
.map(|(peer_index, peer)| {
let mut addresses = vec![&peer.connected_addr];
addresses.extend(peer.listened_addrs.iter());
let addresses: HashSet<_> = std::iter::once(peer.connected_addr.clone())
.chain(peer.listened_addrs.iter().cloned())
.collect();

let node_addresses = addresses
.iter()
Expand Down

0 comments on commit 05aa7b6

Please sign in to comment.