Skip to main content

miden_client/transaction/batch/
error.rs

1use miden_protocol::block::BlockNumber;
2use miden_protocol::note::NoteId;
3
4use crate::store::StoreError;
5use crate::transaction::TransactionStoreUpdateError;
6
7/// Errors specific to `BatchBuilder` construction and operation.
8#[derive(Debug, thiserror::Error)]
9pub enum BatchBuilderError {
10    /// A push consumed an input note that an earlier push in this batch already
11    /// consumed. Guarded client-side to fail fast before hitting the node.
12    #[error("input note {0} is already consumed by an earlier transaction in this batch")]
13    DuplicateInputNote(NoteId),
14
15    /// `submit` was called on a builder with zero successful pushes.
16    #[error("batch is empty — push at least one transaction before submitting")]
17    Empty,
18
19    /// The node accepted the batch (RPC returned `block_num`), but building one of the
20    /// per-tx [`crate::transaction::TransactionStoreUpdate`]s failed. Callers should trigger
21    /// `sync_state` to reconcile.
22    #[error(
23        "batch was accepted at block {block_num} but building store updates failed; sync_state to reconcile"
24    )]
25    BatchSubmittedButUpdateBuildFailed {
26        block_num: BlockNumber,
27        #[source]
28        source: TransactionStoreUpdateError,
29    },
30
31    /// The node accepted the batch (RPC returned `block_num`), but applying
32    /// the per-tx updates to the local store failed. Callers should trigger
33    /// `sync_state` to reconcile.
34    #[error(
35        "batch was accepted at block {block_num} but applying to the store failed; sync_state to reconcile"
36    )]
37    BatchSubmittedButApplyFailed {
38        block_num: BlockNumber,
39        #[source]
40        source: StoreError,
41    },
42}