Skip to main content

abtc_application/
queries.rs

1//! Query types for the application
2//!
3//! Queries represent actions that retrieve state without modifying it (CQRS pattern).
4
5use abtc_domain::primitives::{BlockHash, Txid};
6
7/// Query to get a specific block by hash
8#[derive(Clone, Debug)]
9pub struct GetBlock {
10    pub hash: BlockHash,
11}
12
13impl GetBlock {
14    pub fn new(hash: BlockHash) -> Self {
15        GetBlock { hash }
16    }
17}
18
19/// Query to get block height
20#[derive(Clone, Debug)]
21pub struct GetBlockHeight {
22    pub hash: BlockHash,
23}
24
25impl GetBlockHeight {
26    pub fn new(hash: BlockHash) -> Self {
27        GetBlockHeight { hash }
28    }
29}
30
31/// Query to get a specific transaction
32#[derive(Clone, Debug)]
33pub struct GetTransaction {
34    pub txid: Txid,
35}
36
37impl GetTransaction {
38    pub fn new(txid: Txid) -> Self {
39        GetTransaction { txid }
40    }
41}
42
43/// Query to get wallet balance
44#[derive(Clone, Debug)]
45pub struct GetBalance {
46    pub address: Option<String>,
47}
48
49impl GetBalance {
50    pub fn new(address: Option<String>) -> Self {
51        GetBalance { address }
52    }
53}
54
55/// Query to get chain info
56#[derive(Clone, Debug)]
57pub struct GetChainInfo;
58
59/// Query to get mempool contents
60#[derive(Clone, Debug)]
61pub struct GetMempool {
62    pub verbose: bool,
63}
64
65impl GetMempool {
66    pub fn new(verbose: bool) -> Self {
67        GetMempool { verbose }
68    }
69}
70
71/// Query to estimate fee
72#[derive(Clone, Debug)]
73pub struct EstimateFee {
74    pub target_blocks: u32,
75}
76
77impl EstimateFee {
78    pub fn new(target_blocks: u32) -> Self {
79        EstimateFee { target_blocks }
80    }
81}