kaspa_cli_lib/modules/
disconnect.rs

1use crate::imports::*;
2
3#[derive(Default, Handler)]
4#[help("Disconnect from the kaspa network")]
5pub struct Disconnect;
6
7impl Disconnect {
8    async fn main(self: Arc<Self>, ctx: &Arc<dyn Context>, _argv: Vec<String>, _cmd: &str) -> Result<()> {
9        let ctx = ctx.clone().downcast_arc::<KaspaCli>()?;
10        if let Some(wrpc_client) = ctx.wallet().try_wrpc_client().as_ref() {
11            wrpc_client.disconnect().await?;
12        } else {
13            terrorln!(ctx, "Unable to disconnect from non-wRPC client");
14        }
15        Ok(())
16    }
17}