pub struct ChainTracker<L: ChainListener + Ord> {
    pub headers: VecDeque<Headers>,
    pub tip: Headers,
    pub height: u32,
    pub network: Network,
    pub listeners: OrderedMap<L, ListenSlot>,
    /* private fields */
}
Expand description

Track chain, with basic validation

Fields§

§headers: VecDeque<Headers>

headers past the tip

§tip: Headers

tip header

§height: u32

height

§network: Network

The network

§listeners: OrderedMap<L, ListenSlot>

listeners

Implementations§

source§

impl<L: ChainListener + Ord> ChainTracker<L>

source

pub fn new( network: Network, height: u32, tip: Headers, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Result<Self, Error>

Create a new tracker

source

pub fn restore( headers: VecDeque<Headers>, tip: Headers, height: u32, network: Network, listeners: OrderedMap<L, ListenSlot>, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Self

Restore a tracker

source

pub fn genesis( network: Network, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Self

Create a tracker at genesis

source

pub fn tip(&self) -> &Headers

Current chain tip header

source

pub fn headers(&self) -> &VecDeque<Headers>

Headers past the tip

source

pub fn height(&self) -> u32

Height of current chain tip

source

pub fn remove_block( &mut self, proof: UnspentProof ) -> Result<BlockHeader, Error>

Remove block at tip due to reorg

source

pub fn add_block( &mut self, header: BlockHeader, proof: UnspentProof ) -> Result<(), Error>

Add a block, which becomes the new tip

source

pub fn add_listener( &mut self, listener: L, initial_txid_watches: OrderedSet<Txid> )

Add a listener and initialize the watched outpoint set

source

pub fn add_listener_watches( &mut self, listener: L, watches: OrderedSet<OutPoint> )

Add more watches to a listener

source

pub fn get_all_forward_watches(&self) -> (Vec<Txid>, Vec<OutPoint>)

Return all Txid and OutPoint watches for future blocks.

source

pub fn get_all_reverse_watches(&self) -> (Vec<Txid>, Vec<OutPoint>)

Return all Txid and OutPoint watches for removing blocks. This is a superset of the forward watches, and also includes watches for outpoints which were seen as spent in previous blocks.

Auto Trait Implementations§

§

impl<L> !RefUnwindSafe for ChainTracker<L>

§

impl<L> Send for ChainTracker<L>

§

impl<L> Sync for ChainTracker<L>

§

impl<L> Unpin for ChainTracker<L>

§

impl<L> !UnwindSafe for ChainTracker<L>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V