[][src]Struct grin_chain::Chain

pub struct Chain { /* fields omitted */ }

Facade to the blockchain block processing pipeline and storage. Provides the current view of the TxHashSet according to the chain state. Also maintains locking for the pipeline to avoid conflicting processing.

Methods

impl Chain
[src]

Initializes the blockchain and returns a new Chain instance. Does a check on the current chain head to make sure it exists and creates one based on the genesis block if necessary.

Return our shared txhashset instance.

Shared store instance.

Reset sync_head to current header_head. We do this when we first transition to header_sync to ensure we extend the "sync" header MMR from a known consistent state and to ensure we track the header chain correctly at the fork point.

Processes a single block, then checks for orphans, processing those as well if they're found

Process a block header received during "header first" propagation.

Attempt to add new headers to the header chain (or fork). This is only ever used during sync and is based on sync_head. We update header_head here if our total work increases.

Check if hash is for a known orphan.

Get the OrphanBlockPool accumulated evicted number of blocks

Check for orphans, once a block is successfully added

TODO - where do we call this from? And do we need a rewind first? For the given commitment find the unspent output and return the associated Return an error if the output does not exist or has been spent. This querying is done in a way that is consistent with the current chain state, specifically the current winning (valid, most work) fork.

Validate the tx against the current UTXO set.

Verify we are not attempting to spend a coinbase output that has not yet sufficiently matured.

Verify that the tx has a lock_height that is less than or equal to the height of the next block.

Validate the current chain state.

*** Only used in tests. *** Convenience for setting roots on a block header when creating a chain fork during tests.

Sets the txhashset roots on a brand new block by applying the block on the current txhashset state.

Return a Merkle proof for the given commitment from the store.

Return a merkle proof valid for the current output pmmr state at the given pos

Returns current txhashset roots.

Provides a reading view into the current txhashset state as well as the required indexes for a consumer to rewind to a consistent state at the provided block hash.

Rebuild the sync MMR based on current header_head. We rebuild the sync MMR when first entering sync mode so ensure we have an MMR we can safely rewind based on the headers received from a peer. TODO - think about how to optimize this.

Check chain status whether a txhashset downloading is needed

Writes a reading view on a txhashset state that's been provided to us. If we're willing to accept that new state, the data stream will be read as a zip file, unzipped and the resulting state files should be rewound to the provided indexes.

Triggers chain compaction.

  • compacts the txhashset based on current prune_list
  • removes historical blocks and associated data from the db (unless archive mode)

returns the last n nodes inserted into the output sum tree

as above, for rangeproofs

as above, for kernels

outputs by insertion index

Orphans pool size

Tip (head) of the block chain.

Tail of the block chain in this node after compact (cross-block cut-through)

Tip (head) of the header chain.

Block header for the chain head

Gets a block header by hash

Gets a block header by hash

Get previous block header.

Get block_sums by header hash.

Gets the block header at the provided height. Note: This takes a read lock on the txhashset. Take care not to call this repeatedly in a tight loop.

Gets the block header in which a given output appears in the txhashset.

Verifies the given block header is actually on the current chain. Checks the header_by_height index to verify the header is where we say it is

Get the tip of the current "sync" header chain. This may be significantly different to current header chain.

Important traits for DifficultyIter<'a>

Builds an iterator on blocks starting from the current chain head and running backward. Specialized to return information pertaining to block difficulty calculation (timestamp and previous difficulties).

Check whether we have a block without reading it

Auto Trait Implementations

impl Send for Chain

impl Sync for Chain

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SafeBorrow for T where
    T: ?Sized

impl<T> UnsafeAny for T where
    T: Any

impl<T> Erased for T

impl<T> Same for T

Should always be Self