pub trait MmrApi<Block: BlockT, Hash: Codec, BlockNumber: Codec>: Core<Block> {
    // Provided methods
    fn mmr_root(
        &self,
        __runtime_api_at_param__: <Block as BlockT>::Hash
    ) -> Result<Result<Hash, Error>, ApiError> { ... }
    fn mmr_leaf_count(
        &self,
        __runtime_api_at_param__: <Block as BlockT>::Hash
    ) -> Result<Result<LeafIndex, Error>, ApiError> { ... }
    fn generate_proof(
        &self,
        __runtime_api_at_param__: <Block as BlockT>::Hash,
        block_numbers: Vec<BlockNumber>,
        best_known_block_number: Option<BlockNumber>
    ) -> Result<Result<(Vec<EncodableOpaqueLeaf>, Proof<Hash>), Error>, ApiError> { ... }
    fn verify_proof(
        &self,
        __runtime_api_at_param__: <Block as BlockT>::Hash,
        leaves: Vec<EncodableOpaqueLeaf>,
        proof: Proof<Hash>
    ) -> Result<Result<(), Error>, ApiError> { ... }
    fn verify_proof_stateless(
        &self,
        __runtime_api_at_param__: <Block as BlockT>::Hash,
        root: Hash,
        leaves: Vec<EncodableOpaqueLeaf>,
        proof: Proof<Hash>
    ) -> Result<Result<(), Error>, ApiError> { ... }
}
Expand description

API to interact with MMR pallet.

Provided Methods§

source

fn mmr_root( &self, __runtime_api_at_param__: <Block as BlockT>::Hash ) -> Result<Result<Hash, Error>, ApiError>

Return the on-chain MMR root hash.

source

fn mmr_leaf_count( &self, __runtime_api_at_param__: <Block as BlockT>::Hash ) -> Result<Result<LeafIndex, Error>, ApiError>

Return the number of MMR blocks in the chain.

source

fn generate_proof( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, block_numbers: Vec<BlockNumber>, best_known_block_number: Option<BlockNumber> ) -> Result<Result<(Vec<EncodableOpaqueLeaf>, Proof<Hash>), Error>, ApiError>

Generate MMR proof for a series of block numbers. If best_known_block_number = Some(n), use historical MMR state at given block height n. Else, use current MMR state.

source

fn verify_proof( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, leaves: Vec<EncodableOpaqueLeaf>, proof: Proof<Hash> ) -> Result<Result<(), Error>, ApiError>

Verify MMR proof against on-chain MMR for a batch of leaves.

Note this function will use on-chain MMR root hash and check if the proof matches the hash. Note, the leaves should be sorted such that corresponding leaves and leaf indices have the same position in both the leaves vector and the leaf_indices vector contained in the Proof

source

fn verify_proof_stateless( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, root: Hash, leaves: Vec<EncodableOpaqueLeaf>, proof: Proof<Hash> ) -> Result<Result<(), Error>, ApiError>

Verify MMR proof against given root hash for a batch of leaves.

Note this function does not require any on-chain storage - the proof is verified against given MMR root hash.

Note, the leaves should be sorted such that corresponding leaves and leaf indices have the same position in both the leaves vector and the leaf_indices vector contained in the Proof

Trait Implementations§

source§

impl<Block: BlockT, Hash: Codec, BlockNumber: Codec> RuntimeApiInfo for dyn MmrApi<Block, Hash, BlockNumber>

source§

const ID: [u8; 8] = _

The identifier of the runtime api.
source§

const VERSION: u32 = 2u32

The version of the runtime api.

Implementors§