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 31dd8b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 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
4 changes: 2 additions & 2 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,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(
Expand Down

0 comments on commit 31dd8b3

Please sign in to comment.