diff --git a/src/rpc/README.md b/src/rpc/README.md index b939ecef..2d154b8b 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..7022ccd8 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,10 +46,10 @@ 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( + NetworkActorMessage::Command(NetworkActorCommand::SavePeerAddress( params.address.clone() )), params.clone()