pub enum Error {
    InvalidNumericOp,
    Push,
    GetRoot,
    Commit,
    GenerateProof,
    Verify,
    LeafNotFound,
    PalletNotIncluded,
    InvalidLeafIndex,
    InvalidBestKnownBlock,
}
Expand description

Merkle Mountain Range operation error.

Variants§

§

InvalidNumericOp

Error during translation of a block number into a leaf index.

§

Push

Error while pushing new node.

§

GetRoot

Error getting the new root.

§

Commit

Error committing changes.

§

GenerateProof

Error during proof generation.

§

Verify

Proof verification error.

§

LeafNotFound

Leaf not found in the storage.

§

PalletNotIncluded

Mmr Pallet not included in runtime

§

InvalidLeafIndex

Cannot find the requested leaf index

§

InvalidBestKnownBlock

The provided best know block number is invalid.

Implementations§

Consume given error e with self and generate a native log entry with error details.

Consume given error e with self and generate a native log entry with error details.

Examples found in repository?
src/utils.rs (line 36)
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pub fn first_mmr_block_num<H: Header>(
	best_block_num: H::Number,
	mmr_leaf_count: LeafIndex,
) -> Result<H::Number, Error> {
	let mmr_blocks_count = mmr_leaf_count.try_into().map_err(|_| {
		Error::InvalidNumericOp
			.log_debug("The number of leaves couldn't be converted to a block number.")
	})?;
	best_block_num
		.checked_sub(&mmr_blocks_count)
		.and_then(|last_non_mmr_block| last_non_mmr_block.checked_add(&One::one()))
		.ok_or_else(|| {
			Error::InvalidNumericOp
				.log_debug("The best block should be greater than the number of mmr blocks.")
		})
}

/// Convert a block number into a leaf index.
pub fn block_num_to_leaf_index<H: Header>(
	block_num: H::Number,
	first_mmr_block_num: H::Number,
) -> Result<LeafIndex, Error> {
	let leaf_idx = block_num.checked_sub(&first_mmr_block_num).ok_or_else(|| {
		Error::InvalidNumericOp
			.log_debug("The provided block should be greater than the first mmr block.")
	})?;

	leaf_idx.try_into().map_err(|_| {
		Error::InvalidNumericOp.log_debug("Couldn't convert the leaf index to `LeafIndex`.")
	})
}

Trait Implementations§

Formats the value using the given formatter. Read more
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
Returns the fixed encoded size of the type. Read more
Formats the value using the given formatter. Read more
Convert self to a slice and append it to the destination.
If possible give a hint of expected size of the encoding. Read more
Convert self to an owned vector.
Convert self to a slice and then invoke the given closure with it.
Calculates the encoded size. Read more
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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
Convert from a value of T into an equivalent instance of Option<Self>. Read more
Consume self to return Some equivalent value of Option<T>. Read more
Decode Self and consume all of the given input data. Read more
Decode Self and consume all of the given input data. Read more
Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Return an encoding of Self prepended by given slice.
🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
Should always be Self
Convert from a value of T into an equivalent instance of Self. Read more
Consume self to return an equivalent value of T. Read more
Converts the given value to a String. Read more
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.
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more