pub struct Chain { /* private fields */ }
Expand description

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.

Implementations

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 header MMR handle.

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. Note: This will update header MMR and corresponding header_head if total work increases (on the header chain).

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

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.

Retrieves an unspent output using its PMMR position

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.

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

Provides a reading view into the current kernel state.

Writes kernels provided to us (via a kernel data download). Currently does not write these to disk and simply deserializes the provided data. TODO - Write this data to disk and validate the rebuilt kernel MMR.

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.

To support the ability to download the txhashset from multiple peers in parallel, the peers must all agree on the exact binary representation of the txhashset. This means compacting and rewinding to the exact same header. Since compaction is a heavy operation, peers can agree to compact every 12 hours, and no longer support requesting arbitrary txhashsets. Here we return the header of the txhashset we are currently offering to peers.

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.

Check chain status whether a txhashset downloading is needed

Clean the temporary sandbox folder

Specific tmp dir. Normally it’s ~/.epic/main/tmp for mainnet or ~/.epic/floo/tmp for floonet

Get a tmp file path in above specific tmp dir (create tmp dir if not exist) Delete file if tmp file already exists

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

Return Commit’s MMR position

outputs by insertion index

Return unspent outputs as above, but bounded between a particular range of blocks

Orphans pool size

Tip (head) of the block chain.

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

Block header for the chain head

Gets a block 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: Takes a read lock on the header_pmmr.

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

Gets the kernel with a given excess and the block height it is included in.

Gets the block header in which a given kernel mmr index 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.

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).

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

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.