Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(RPCs): rename get_peers_info RPC to get_directly_connected_peers #2195

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mm2src/mm2_libp2p/src/atomicdex_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const ANNOUNCE_INTERVAL: Duration = Duration::from_secs(600);
const ANNOUNCE_INITIAL_DELAY: Duration = Duration::from_secs(60);
const CHANNEL_BUF_SIZE: usize = 1024 * 8;

/// Returns info about connected peers
pub async fn get_peers_info(mut cmd_tx: AdexCmdTx) -> BTreeMap<String, Vec<String>> {
/// Returns info about directly connected peers.
pub async fn get_directly_connected_peers(mut cmd_tx: AdexCmdTx) -> BTreeMap<String, Vec<String>> {
let (result_tx, rx) = oneshot::channel();
let cmd = AdexBehaviourCmd::GetPeersInfo { result_tx };
cmd_tx.send(cmd).await.expect("Rx should be present");
Expand Down
2 changes: 1 addition & 1 deletion mm2src/mm2_main/src/rpc/dispatcher/dispatcher_legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ pub fn dispatcher(req: Json, ctx: MmArc) -> DispatcherRes {
"electrum" => hyres(electrum(ctx, req)),
"enable" => hyres(enable(ctx, req)),
"get_enabled_coins" => hyres(get_enabled_coins(ctx)),
"get_directly_connected_peers" => hyres(get_directly_connected_peers(ctx)),
"get_gossip_mesh" => hyres(get_gossip_mesh(ctx)),
"get_gossip_peer_topics" => hyres(get_gossip_peer_topics(ctx)),
"get_gossip_topic_peers" => hyres(get_gossip_topic_peers(ctx)),
"get_my_peer_id" => hyres(get_my_peer_id(ctx)),
"get_peers_info" => hyres(get_peers_info(ctx)),
"get_relay_mesh" => hyres(get_relay_mesh(ctx)),
"get_trade_fee" => hyres(get_trade_fee(ctx, req)),
// "fundvalue" => lp_fundvalue (ctx, req, false),
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_main/src/rpc/lp_commands/lp_commands_legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ pub fn version(ctx: MmArc) -> HyRes {
}
}

pub async fn get_peers_info(ctx: MmArc) -> Result<Response<Vec<u8>>, String> {
pub async fn get_directly_connected_peers(ctx: MmArc) -> Result<Response<Vec<u8>>, String> {
let ctx = P2PContext::fetch_from_mm_arc(&ctx);
let cmd_tx = ctx.cmd_tx.lock().clone();
let result = mm2_libp2p::get_peers_info(cmd_tx).await;
let result = mm2_libp2p::get_directly_connected_peers(cmd_tx).await;
let result = json!({
"result": result,
});
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_net/src/network_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ impl EventBehaviour for NetworkEvent {
loop {
let p2p_cmd_tx = p2p_ctx.cmd_tx.lock().clone();

let peers_info = atomicdex::get_peers_info(p2p_cmd_tx.clone()).await;
let directly_connected_peers = atomicdex::get_directly_connected_peers(p2p_cmd_tx.clone()).await;
let gossip_mesh = atomicdex::get_gossip_mesh(p2p_cmd_tx.clone()).await;
let gossip_peer_topics = atomicdex::get_gossip_peer_topics(p2p_cmd_tx.clone()).await;
let gossip_topic_peers = atomicdex::get_gossip_topic_peers(p2p_cmd_tx.clone()).await;
let relay_mesh = atomicdex::get_relay_mesh(p2p_cmd_tx).await;

let event_data = json!({
"peers_info": peers_info,
"directly_connected_peers": directly_connected_peers,
"gossip_mesh": gossip_mesh,
"gossip_peer_topics": gossip_peer_topics,
"gossip_topic_peers": gossip_topic_peers,
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_p2p/src/behaviours/atomicdex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ pub enum AdexBehaviourCmd {
},
}

/// Returns info about connected peers
pub async fn get_peers_info(mut cmd_tx: AdexCmdTx) -> HashMap<String, Vec<String>> {
/// Returns info about directly connected peers.
pub async fn get_directly_connected_peers(mut cmd_tx: AdexCmdTx) -> HashMap<String, Vec<String>> {
let (result_tx, rx) = oneshot::channel();
let cmd = AdexBehaviourCmd::GetPeersInfo { result_tx };
cmd_tx.send(cmd).await.expect("Rx should be present");
Expand Down
9 changes: 5 additions & 4 deletions mm2src/mm2_p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ use sha2::{Digest, Sha256};
pub use crate::swarm_runtime::SwarmRuntime;

// atomicdex related re-exports
pub use behaviours::atomicdex::{get_gossip_mesh, get_gossip_peer_topics, get_gossip_topic_peers, get_peers_info,
get_relay_mesh, spawn_gossipsub, AdexBehaviourCmd, AdexBehaviourError,
AdexBehaviourEvent, AdexCmdTx, AdexEventRx, AdexResponse, AdexResponseChannel,
GossipsubEvent, GossipsubMessage, MessageId, NodeType, TopicHash, WssCerts};
pub use behaviours::atomicdex::{get_directly_connected_peers, get_gossip_mesh, get_gossip_peer_topics,
get_gossip_topic_peers, get_relay_mesh, spawn_gossipsub, AdexBehaviourCmd,
AdexBehaviourError, AdexBehaviourEvent, AdexCmdTx, AdexEventRx, AdexResponse,
AdexResponseChannel, GossipsubEvent, GossipsubMessage, MessageId, NodeType, TopicHash,
WssCerts};

// peers-exchange re-exports
pub use behaviours::peers_exchange::PeerAddresses;
Expand Down
Loading