Skip to content

Commit

Permalink
Make the parameter save to connect_peer optional
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Oct 21, 2024
1 parent c0d3bec commit 95ce7e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/rpc/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
}

#[serde_as]
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 95ce7e7

Please sign in to comment.