#[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
WrongLength
The byte slice is not the family’s wire size (80 or 164).
Fields
family: HeaderFamilyThe family the bytes were decoded as.
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).
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§
impl Copy for Error
impl Eq for Error
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.