From 31dd8b3de2847f601482e8b014eb12e5408dc42d Mon Sep 17 00:00:00 2001 From: YI Date: Mon, 21 Oct 2024 18:35:50 +0800 Subject: [PATCH] Make the parameter save to connect_peer optional --- src/rpc/README.md | 1 + src/rpc/peer.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpc/README.md b/src/rpc/README.md index 4f75874b..08c8a318 100644 --- a/src/rpc/README.md +++ b/src/rpc/README.md @@ -241,6 +241,7 @@ Attempts to connect to a peer. ###### Params * `address` - The address of the peer to connect to +* `save` - Whether to save the peer address, an optional parameter (default value true) ###### Returns diff --git a/src/rpc/peer.rs b/src/rpc/peer.rs index b5a7b480..f8028ec4 100644 --- a/src/rpc/peer.rs +++ b/src/rpc/peer.rs @@ -12,7 +12,7 @@ use tentacle::{multiaddr::MultiAddr, secio::PeerId}; #[derive(Serialize, Deserialize, Debug, Clone)] pub(crate) struct ConnectPeerParams { address: MultiAddr, - save: bool, + save: Option, } #[serde_as] @@ -46,7 +46,7 @@ impl PeerRpcServer for PeerRpcServerImpl { async fn connect_peer(&self, params: ConnectPeerParams) -> Result<(), ErrorObjectOwned> { let message = NetworkActorMessage::Command(NetworkActorCommand::ConnectPeer(params.address.clone())); - if params.save { + if params.save.unwrap_or(true) { crate::handle_actor_cast!( self.actor, NetworkActorMessage::Command(NetworkActorCommand::ConnectPeer(