cuprated/blockchain/manager/commands.rs
1//! This module contains the commands for the blockchain manager.
2use std::collections::HashMap;
3
4use monero_oxide::block::Block;
5use tokio::sync::oneshot;
6
7use cuprate_types::TransactionVerificationData;
8
9/// The blockchain manager commands.
10#[expect(clippy::large_enum_variant)]
11pub enum BlockchainManagerCommand {
12 /// Attempt to add a new block to the blockchain.
13 AddBlock {
14 /// The [`Block`] to add.
15 block: Block,
16 /// All the transactions defined in [`Block::transactions`].
17 prepped_txs: HashMap<[u8; 32], TransactionVerificationData>,
18 /// The channel to send the response down.
19 response_tx: oneshot::Sender<Result<IncomingBlockOk, anyhow::Error>>,
20 },
21 /// Pop blocks from the top of the blockchain.
22 PopBlocks {
23 numb_blocks: usize,
24 /// The channel to send the response down.
25 response_tx: oneshot::Sender<()>,
26 },
27}
28
29/// The [`Ok`] response for an incoming block.
30pub enum IncomingBlockOk {
31 /// The block was added to the main-chain.
32 AddedToMainChain,
33 /// The blockchain manager is not ready yet.
34 NotReady,
35 /// The block was added to an alt-chain.
36 AddedToAltChain,
37 /// We already have the block.
38 AlreadyHave,
39}