zebrad/components/mempool/error.rs
1//! Errors that can occur when interacting with the mempool.
2//!
3//! Most of the mempool errors are related to manipulating transactions in the
4//! mempool.
5
6use thiserror::Error;
7
8#[cfg(any(test, feature = "proptest-impl"))]
9use proptest_derive::Arbitrary;
10
11use super::storage::{
12 ExactTipRejectionError, NonStandardTransactionError, SameEffectsChainRejectionError,
13 SameEffectsTipRejectionError,
14};
15
16/// Mempool errors.
17#[derive(Error, Clone, Debug, PartialEq, Eq)]
18#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
19pub enum MempoolError {
20 /// Transaction rejected based on its authorizing data (scripts, proofs,
21 /// signatures). The rejection is valid for the current chain tip.
22 ///
23 /// See [`ExactTipRejectionError`] for more details.
24 ///
25 /// Note that the mempool caches this error. See [`super::storage::Storage`]
26 /// for more details.
27 #[error(
28 "the transaction will be rejected from the mempool until the next chain tip block: {0}"
29 )]
30 StorageExactTip(#[from] ExactTipRejectionError),
31
32 /// Transaction rejected based on its effects (spends, outputs, transaction
33 /// header). The rejection is valid for the current chain tip.
34 ///
35 /// See [`SameEffectsTipRejectionError`] for more details.
36 ///
37 /// Note that the mempool caches this error. See [`super::storage::Storage`]
38 /// for more details.
39 #[error("any transaction with the same effects will be rejected from the mempool until the next chain tip block: {0}")]
40 StorageEffectsTip(#[from] SameEffectsTipRejectionError),
41
42 /// Transaction rejected based on its effects (spends, outputs, transaction
43 /// header). The rejection is valid while the current chain continues to
44 /// grow.
45 ///
46 /// See [`SameEffectsChainRejectionError`] for more details.
47 ///
48 /// Note that the mempool caches this error. See [`super::storage::Storage`]
49 /// for more details.
50 #[error("any transaction with the same effects will be rejected from the mempool until a chain reset: {0}")]
51 StorageEffectsChain(#[from] SameEffectsChainRejectionError),
52
53 /// Transaction rejected because the mempool already contains another
54 /// transaction with the same hash.
55 #[error("transaction already exists in mempool")]
56 InMempool,
57
58 /// The transaction hash is already queued, so this request was ignored.
59 ///
60 /// Another peer has already gossiped the same hash to us, or the mempool crawler has fetched it.
61 #[error("transaction dropped because it is already queued for download")]
62 AlreadyQueued,
63
64 /// The queue is at capacity, so this request was ignored.
65 ///
66 /// The mempool crawler should discover this transaction later.
67 /// If it is mined into a block, it will be downloaded by the syncer, or the inbound block downloader.
68 ///
69 /// The queue's capacity is [`super::downloads::MAX_INBOUND_CONCURRENCY`].
70 #[error("transaction dropped because the queue is full")]
71 FullQueue,
72
73 /// The mempool is not enabled yet.
74 ///
75 /// Zebra enables the mempool when it is at the chain tip.
76 #[error("mempool is disabled since synchronization is behind the chain tip")]
77 Disabled,
78
79 /// The transaction is non-standard.
80 #[error("transaction is non-standard")]
81 NonStandardTransaction(#[from] NonStandardTransactionError),
82}