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 consumed. Guarded
11    /// 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 per-tx
20    /// [`crate::transaction::TransactionStoreUpdate`]s failed. Callers should trigger `sync_state`
21    /// 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 the per-tx updates to
32    /// the local store failed. Callers should trigger `sync_state` to reconcile.
33    #[error(
34        "batch was accepted at block {block_num} but applying to the store failed; sync_state to reconcile"
35    )]
36    BatchSubmittedButApplyFailed {
37        block_num: BlockNumber,
38        #[source]
39        source: StoreError,
40    },
41}