leo_lang/cli/commands/query/
mempool.rs1use super::*;
18
19use crate::cli::context::Context;
20use clap::Parser;
21
22#[derive(Parser, Debug)]
24pub struct LeoMempool {
25 #[arg(
26 long,
27 help = "Get the memory pool transactions",
28 default_value = "false",
29 required_unless_present = "transmissions",
30 conflicts_with("transmissions")
31 )]
32 pub(crate) transactions: bool,
33 #[arg(
34 long,
35 help = "Get the memory pool transmissions",
36 default_value = "false",
37 required_unless_present = "transactions",
38 conflicts_with("transactions")
39 )]
40 pub(crate) transmissions: bool,
41}
42
43impl Command for LeoMempool {
44 type Input = ();
45 type Output = String;
46
47 fn log_span(&self) -> Span {
48 tracing::span!(tracing::Level::INFO, "Leo")
49 }
50
51 fn prelude(&self, _context: Context) -> Result<Self::Input> {
52 Ok(())
53 }
54
55 fn apply(self, _context: Context, _input: Self::Input) -> Result<Self::Output> {
56 let url = if self.transactions {
58 "memoryPool/transactions".to_string()
59 } else if self.transmissions {
60 "memoryPool/transmissions".to_string()
61 } else {
62 unreachable!("All cases are covered")
63 };
64
65 Ok(url)
66 }
67}