Skip to content

Commit

Permalink
NetRpcImpl::get_peers return Remoteaddress.addresses dedup
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <execvy@gmail.com>
  • Loading branch information
eval-exec committed Jan 24, 2025
1 parent b44d2d2 commit 9508269
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 9508269

Please sign in to comment.