Enumerate mempool errors (#2615)

* Enumerate mempool errors.

* Update code formatting

* Allow dead code

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>

* Allow dead code

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>

* Add a new error

* Update error formatting

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>

* Remove TransactionQueryError

* Derive Copy and Clone

Co-authored-by: teor <teor@riseup.net>

* Remove the Copy trait

Co-authored-by: teor <teor@riseup.net>

* Rename enum variants

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
This commit is contained in:
Marek 2021-08-25 20:39:27 +02:00 committed by GitHub
parent ace7aec933
commit 1c232ff5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -1,5 +1,8 @@
//! Zebra mempool.
/// Mempool-related errors.
pub mod error;
mod crawler;
pub use self::crawler::Crawler;

View File

@ -0,0 +1,25 @@
//! Errors that can occur when manipulating transactions in the mempool.
use thiserror::Error;
#[derive(Error, Clone, Debug, PartialEq)]
#[allow(dead_code)]
pub enum MempoolError {
#[error("transaction already exists in mempool")]
InMempool,
#[error("transaction did not pass consensus validation")]
Invalid(#[from] zebra_consensus::error::TransactionError),
#[error("transaction is committed in block {0:?}")]
InBlock(zebra_chain::block::Hash),
#[error("transaction has expired")]
Expired,
#[error("transaction fee is too low for the current mempool state")]
LowFee,
#[error("transaction was not found in mempool")]
NotInMempool,
}