pub struct BlockChain {
    pub eip1559_transition: BlockNumber,
    /* private fields */
}
Expand description

Structure providing fast access to blockchain data.

Does not do input data verification.

Fields

eip1559_transition: BlockNumber

Number of first block where EIP-1559 rules begin. New encoding/decoding block format.

Implementations

Create new instance of blockchain from given Genesis.

Returns a tree route between from and to, which is a tuple of:

  • a vector of hashes of all blocks, ordered from from to to.

  • common ancestor of these blocks.

  • an index where best common ancestor would be

1.) from newer to older

  • bc: A1 -> A2 -> A3 -> A4 -> A5

  • from: A5, to: A4

  • route:

    { blocks: [A5], ancestor: A4, index: 1 }

2.) from older to newer

  • bc: A1 -> A2 -> A3 -> A4 -> A5

  • from: A3, to: A4

  • route:

    { blocks: [A4], ancestor: A3, index: 0 }

3.) fork:

  • bc:

    A1 -> A2 -> A3 -> A4
               -> B3 -> B4
  • from: B4, to: A4

  • route:

    { blocks: [B4, B3, A3, A4], ancestor: A2, index: 2 }

If the tree route verges into pruned or unknown blocks, None is returned.

is_from_route_finalized returns whether the from part of the route contains a finalized block. This only holds if the two parts (from and to) are on different branches, ie. on 2 different forks.

Inserts a verified, known block from the canonical chain.

Can be performed out-of-order, but care must be taken that the final chain is in a correct state. This is used by snapshot restoration and when downloading missing blocks for the chain gap. is_best forces the best block to be updated to this block. is_ancient forces the best block of the first block sequence to be updated to this block. parent_td is a parent total diffuculty Supply a dummy parent total difficulty when the parent block may not be in the chain. Returns true if the block is disconnected.

clears all caches, re-loads best block from disk for testing purposes

Update the best ancient block to the given hash, after checking that it’s directly linked to the currently known best ancient block

Insert an epoch transition. Provide an epoch number being transitioned to and epoch transition object.

The block the transition occurred at should have already been inserted into the chain.

Iterate over all epoch transitions. This will only return transitions within the canonical chain.

Get a specific epoch transition by block number and provided block hash.

Get the transition to the epoch the given parent hash is part of or transitions to. This will give the epoch that any children of this parent belong to.

The block corresponding the the parent hash must be stored already.

Write a pending epoch transition by block hash.

Get a pending epoch transition by block hash.

Add a child to a given block. Assumes that the block hash is in the chain and the child’s parent is this block.

Used in snapshots to glue the chunks together at the end.

Inserts the block into backing cache database. Expects the block to be valid and already verified. If the block is already known, does nothing.

Inserts the block into backing cache database with already generated route information. Expects the block to be valid and already verified and route is tree route information from current best block to new block’s parent. If the block is already known, does nothing.

Mark a block to be considered finalized. Returns Some(()) if the operation succeeds, and None if the block hash is not found.

t_nb 9.12 commit changed to become current greatest by applying pending insertion updates

Iterator that lists first and then all of first’s ancestors, by hash.

Iterator that lists first and then all of first’s ancestors, by extended header.

Given a block’s parent, find every block header which represents a valid possible uncle.

Given a block’s parent, find every block hash which represents a valid possible uncle.

Get best block hash.

Get best block number.

Get best block timestamp.

Get best block total difficulty.

Get best block header

Get current cache size.

Ticks our cache system and throws out any old data.

Create a block body from a block.

Returns general blockchain information

Trait Implementations

Returns true if the given block is known (though not necessarily a part of the canon chain).

Get raw block data

Get block header data

Get block body data

Get the familial details concerning a block.

Get the hash of given block’s number.

Get the address of transaction with given hash.

Get receipts of block with given hash.

Returns numbers of blocks containing given bloom.

Returns logs matching given filter. The order of logs returned will be the same as the order of the blocks provided. And it’s the callers responsibility to sort blocks provided in advance.

Get the first block of the best part of the chain. Return None if there is no gap and the first block is the genesis. Any queries of blocks which precede this one are not guaranteed to succeed. Read more

Get the best block of an first block sequence if there is a gap.

Get the number of the first block.

Returns true if the given block is known and in the canon chain.

Get the number of the first block.

Get a list of uncles for a given block. Returns None if block does not exist. Read more

Get a list of uncle hashes for a given block. Returns None if block does not exist. Read more

Get the number of given block’s hash.

Get transaction with given transaction hash.

Get a list of transactions for a given block. Returns None if block does not exist. Read more

Returns reference to genesis hash.

Returns the header of the genesis block.

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.

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.