Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { WrongLength { family: HeaderFamily, expected: usize, actual: usize, }, VersionBit31Set, VersionBit31Clear, ReservedFlags(u8), InvalidHex, CompactNegative(u32), CompactOverflow(u32), BitsNotPowLimit { bits: u32, expected: u32, }, TargetNotMet, }
Expand description

Why a header could not be decoded or does not satisfy a rule.

Each variant names the upstream rule it stands in for, so a rejection can be traced to the reference: the codec’s length check (codec/codec.js decode, “trailing bytes after BlockHeader”), the header-family selection on version bit 31 (siding/lib/parents.mjs, SPEC 3.2), Bitcoin Core’s arith_uint256::SetCompact overflow and negative cases, and siding’s pow rule (SPEC 4 step 1).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

WrongLength

The byte slice is not the family’s wire size (80 or 164).

Fields

§family: HeaderFamily

The family the bytes were decoded as.

§expected: usize

That family’s wire size.

§actual: usize

The length actually supplied.

§

VersionBit31Set

A stock header’s version has bit 31 set. Beside a stock parent the producer keeps it clear (siding/lib/block.mjs buildBlock, test/stock-header-test.mjs “version keeps bit 31 clear”); on a BLAKE2b-family chain the same bit would select the v2 layout, so a stock header carrying it is not a header of either family.

§

VersionBit31Clear

A v2 header’s version has bit 31 clear: the bytes are not a v2 header (isHeaderV2 in codec/pow/knots-header-v2.js).

§

ReservedFlags(u8)

A v2 header’s flags has a reserved bit (6 or 7) set (knots:rule-header-flags-reserved, error code bad-flags-highbits).

§

InvalidHex

A hex string was not 64 hex characters.

§

CompactNegative(u32)

Compact bits with the sign bit set and a non-zero mantissa (Core’s fNegative).

§

CompactOverflow(u32)

Compact bits whose mantissa would not fit in 256 bits (Core’s fOverflow).

§

BitsNotPowLimit

The header’s bits is not the compact encoding of the chain’s powLimit. Siding sets every block’s bits to that value (siding/lib/chain.mjs: compactFromTarget(powLimit)) and the kernel’s difficulty rule holds it there (powNoRetargeting).

Fields

§bits: u32

The header’s bits.

§expected: u32

powLimit in compact form.

§

TargetNotMet

The block hash, read as a 256-bit number, exceeds the target bits encodes (btc:rule-header-pow; SPEC 4 step 1).

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Error

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Error

Source§

impl Error for Error

Available on crate feature std only.
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.