Skip to main content

ConfirmationStatus

Enum ConfirmationStatus 

Source
pub enum ConfirmationStatus {
    Confirmed(BlockHeight),
    Mempool(BlockHeight),
    Transmitted(BlockHeight),
    Calculated(BlockHeight),
    Failed(BlockHeight),
}
Expand description

Transaction confirmation status. As a transaction is created and transmitted to the blockchain, it will move through each of these states. Received transactions will either be seen in the mempool or scanned from confirmed blocks. Variant order is logical display order for efficient sorting instead of the order of logical status flow.

Variants§

§

Confirmed(BlockHeight)

The transaction has been included in a confirmed block on the blockchain. The block height is the height of the confirmed block that contains the transaction.

§

Mempool(BlockHeight)

The transaction is known to be - or has been - in the mempool. The block height is the chain height when the transaction was seen in the mempool + 1 (target height).

§

Transmitted(BlockHeight)

The transaction has been transmitted to the blockchain but has not been seen in the mempool yet. The block height is the chain height when the transaction was transmitted + 1 (target height).

§

Calculated(BlockHeight)

The transaction has been created but not yet transmitted to the blockchain. The block height is the chain height when the transaction was created + 1 (target height).

§

Failed(BlockHeight)

The transaction has been created but failed to be transmitted, was not accepted into the mempool, was rejected from the mempool or expired before it was included in a confirmed block on the block chain. The block height is the chain height when the transaction was last updated + 1 (target height).

Implementations§

Source§

impl ConfirmationStatus

Source

pub fn is_confirmed(&self) -> bool

A wrapper matching the Confirmed case.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed());
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed());
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed());
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed());
Source

pub fn is_confirmed_after_or_at(&self, comparison_height: &BlockHeight) -> bool

To return true, the status must be confirmed and no earlier than specified height.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after_or_at(&9.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after_or_at(&10.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after_or_at(&11.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after_or_at(&9.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after_or_at(&10.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after_or_at(&11.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after_or_at(&9.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after_or_at(&10.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after_or_at(&11.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_after_or_at(&9.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_after_or_at(&10.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_after_or_at(&11.into()));
Source

pub fn is_confirmed_after(&self, comparison_height: &BlockHeight) -> bool

To return true, the status must be confirmed and no earlier than specified height.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after(&9.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after(&10.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_after(&11.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after(&9.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after(&10.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_after(&11.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after(&9.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after(&10.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_after(&11.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_after(&9.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_after(&10.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_after(&11.into()));
Source

pub fn is_confirmed_before_or_at(&self, comparison_height: &BlockHeight) -> bool

To return true, the status must be confirmed and no later than specified height.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before_or_at(&9.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before_or_at(&10.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before_or_at(&11.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before_or_at(&9.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before_or_at(&10.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before_or_at(&11.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before_or_at(&9.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before_or_at(&10.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before_or_at(&11.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_before_or_at(&9.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_before_or_at(&10.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_before_or_at(&11.into()));
Source

pub fn is_confirmed_before(&self, comparison_height: &BlockHeight) -> bool

To return true, the status must be confirmed earlier than specified height.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before(&9.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before(&10.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_confirmed_before(&11.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before(&9.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before(&10.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_confirmed_before(&11.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before(&9.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before(&10.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_confirmed_before(&11.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_before(&9.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_confirmed_before(&10.into()));
assert!(ConfirmationStatus::Confirmed(10.into()).is_confirmed_before(&11.into()));
Source

pub fn is_pending_before(&self, comparison_height: &BlockHeight) -> bool

To return true, the status must not be confirmed and it must have been submitted sufficiently far in the past. This allows deduction of expired transactions.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(10.into()).is_pending_before(&9.into()));
assert!(!ConfirmationStatus::Calculated(10.into()).is_pending_before(&10.into()));
assert!(ConfirmationStatus::Calculated(10.into()).is_pending_before(&11.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_pending_before(&9.into()));
assert!(!ConfirmationStatus::Transmitted(10.into()).is_pending_before(&10.into()));
assert!(ConfirmationStatus::Transmitted(10.into()).is_pending_before(&11.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_pending_before(&9.into()));
assert!(!ConfirmationStatus::Mempool(10.into()).is_pending_before(&10.into()));
assert!(ConfirmationStatus::Mempool(10.into()).is_pending_before(&11.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_pending_before(&9.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_pending_before(&10.into()));
assert!(!ConfirmationStatus::Confirmed(10.into()).is_pending_before(&11.into()));
Source

pub fn is_pending(&self) -> bool

Check if transaction has Calculated, Transmitted or Mempool status.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(ConfirmationStatus::Calculated(1.into()).is_pending());
assert!(ConfirmationStatus::Transmitted(1.into()).is_pending());
assert!(ConfirmationStatus::Mempool(1.into()).is_pending());
assert!(!ConfirmationStatus::Confirmed(1.into()).is_pending());
assert!(!ConfirmationStatus::Failed(1.into()).is_pending());
Source

pub fn is_failed(&self) -> bool

Check if transaction has Failed status.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

assert!(!ConfirmationStatus::Calculated(1.into()).is_failed());
assert!(!ConfirmationStatus::Transmitted(1.into()).is_failed());
assert!(!ConfirmationStatus::Mempool(1.into()).is_failed());
assert!(!ConfirmationStatus::Confirmed(1.into()).is_failed());
assert!(ConfirmationStatus::Failed(1.into()).is_failed());
Source

pub fn get_confirmed_height(&self) -> Option<BlockHeight>

Returns none if transaction is not confirmed, otherwise returns the height it was confirmed at.

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

let status = ConfirmationStatus::Confirmed(16.into());
assert_eq!(status.get_confirmed_height(), Some(16.into()));

let status = ConfirmationStatus::Mempool(15.into());
assert_eq!(status.get_confirmed_height(), None);
Source

pub fn get_height(&self) -> BlockHeight

§Examples
use zingo_status::confirmation_status::ConfirmationStatus;
use zcash_protocol::consensus::BlockHeight;

let status = ConfirmationStatus::Confirmed(15.into());
assert_eq!(status.get_height(), 15.into());
Source

pub fn read<R: Read>(reader: R) -> Result<Self>

Deserialize into reader

Source

pub fn write<W: Write>(&self, writer: &mut W) -> Result<()>

Serialize into writer

Trait Implementations§

Source§

impl Clone for ConfirmationStatus

Source§

fn clone(&self) -> ConfirmationStatus

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ConfirmationStatus

Source§

impl Debug for ConfirmationStatus

a more complete stringification

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ConfirmationStatus

a public interface, writ in stone

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ConfirmationStatus

Source§

impl From<ConfirmationStatus> for String

Source§

fn from(value: ConfirmationStatus) -> Self

Converts to this type from the input type.
Source§

impl Ord for ConfirmationStatus

Source§

fn cmp(&self, other: &ConfirmationStatus) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ConfirmationStatus

Source§

fn eq(&self, other: &ConfirmationStatus) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ConfirmationStatus

Source§

fn partial_cmp(&self, other: &ConfirmationStatus) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ConfirmationStatus

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.