Skip to main content

Stock

Struct Stock 

Source
pub struct Stock;
Expand description

The stock 80-byte Bitcoin header, hashed with double SHA-256 (parents btc and tbtc4). Version 0x20000000, bit 31 clear, so a Knots node never mistakes it for a v2 header. The stock header does not carry the height, so beside a stock parent the coinbase is the only place the height is written (coinbase_height).

Trait Implementations§

Source§

impl Clone for Stock

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 Stock

Source§

impl Debug for Stock

Source§

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

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

impl Default for Stock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Stock

Source§

impl HeaderFamily for Stock

Source§

fn decode_header(&self, bytes: &[u8]) -> Result<Header>

Exactly 80 bytes with bit 31 of the version clear; a set bit 31 is refused as the kernel’s structVariants would select the v2 layout for it (and as sidestr-header’s StockHeader::decode refuses it).

Source§

fn version_number(&self, header: &Header) -> i64

i32le: bit 31 set reads as a negative version.

Source§

const FAMILY: Family = Family::Stock

Which family this is.
Source§

const HEADER_LEN: usize = 80

The serialised header length: 80 or 164.
Source§

type Header = Header

The header: the parent’s layout, decoded.
Source§

type Block = Block

The block: this header followed by the transactions. bitcoin::Block for the stock family; FamilyBlock otherwise.
Source§

fn encode_header(&self, header: &Header) -> Vec<u8> ⓘ

The header’s wire bytes.
Source§

fn block_hash(&self, header: &Header) -> BlockHash

The block hash: the parent’s proof-of-work hash over the header.
Source§

fn signed_prefix(&self, header: &Header) -> Vec<u8> ⓘ

The bytes the block signature commits to (SPEC 4): the header’s first 72 bytes, version, prev, merkle root and time on wire — never the nonce, which is found after signing.
Source§

fn header_height(&self, _header: &Header) -> Option<u32>

The height the header itself carries, when the family writes it there.
Source§

fn new_header( &self, prev: BlockHash, merkle_root: TxMerkleNode, time: u32, bits: CompactTarget, _height: u32, _tx_count: usize, ) -> Header

An unsigned header on prev with this family’s version and zero nonce (siding/lib/block.mjs buildBlock). height and tx_count are for the families whose header commits to them; the stock header ignores both.
Source§

fn version(&self, header: &Header) -> u32

The raw wire version word, unsigned.
Source§

fn prev(&self, header: &Header) -> BlockHash

The previous block’s hash.
Source§

fn merkle_root(&self, header: &Header) -> TxMerkleNode

The merkle root.
Source§

fn time(&self, header: &Header) -> u32

The consensus time: for a v2 header, the wire time with its offset applied.
Source§

fn bits(&self, header: &Header) -> CompactTarget

The compact target.
Source§

fn nonce(&self, header: &Header) -> u32

The (first) nonce.
Source§

fn set_merkle_root(&self, header: &mut Header, root: TxMerkleNode)

Replace the merkle root; seal_block does so once the solution is in.
Source§

fn set_nonce(&self, header: &mut Header, nonce: u32)

Replace the nonce; seal_block grinds it.
Source§

fn family(&self) -> Family

Which family this is.
Source§

fn header_len(&self) -> usize

The serialised header length.
Source§

fn header_rules(&self, header: &Self::Header, height: u32) -> Vec<RuleResult>

The header rules the parent’s fork adds beyond Bitcoin’s (the Knots overlay’s knots:rule-header-*), judged for a header at height. None for the stock family.
Source§

fn block_rules(&self, header: &Self::Header, tx_count: usize) -> Vec<RuleResult>

The block rules the parent’s fork adds (knots:rule-block-txcount), given the header and the block’s transaction count.
Source§

fn sighash_rules(&self, height: u32) -> SighashRules

The signature-hash rules a spend at height is judged by: BIP 341 on a stock chain; Knots’ unified opt-in sighash from the fork height on a BLAKE2b chain, which for a sidestr chain is height 0 (siding/lib/overlay.mjs: unifiedSighashParam: 'blake2bHeight', blake2bHeight: 0).
Source§

impl PartialEq for Stock

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 Stock

Auto Trait Implementations§

§

impl Freeze for Stock

§

impl RefUnwindSafe for Stock

§

impl Send for Stock

§

impl Sync for Stock

§

impl Unpin for Stock

§

impl UnsafeUnpin for Stock

§

impl UnwindSafe for Stock

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> 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, 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.