Struct Block

Source
pub struct Block<V = Unchecked>
where V: Validation,
{ /* private fields */ }
Available on crate feature alloc only.
Expand description

Bitcoin block.

A collection of transactions with an attached proof of work.

See Bitcoin Wiki: Block for more information.

§Bitcoin Core References

Implementations§

Source§

impl Block<Unchecked>

Source

pub fn new_unchecked( header: Header, transactions: Vec<Transaction>, ) -> Block<Unchecked>

Constructs a new Block without doing any validation.

Source

pub fn assume_checked( self, witness_root: Option<WitnessMerkleNode>, ) -> Block<Checked>

Ignores block validation logic and just assumes you know what you are doing.

You should only use this function if you trust the block i.e., it comes from a trusted node.

Source

pub fn into_parts(self) -> (Header, Vec<Transaction>)

Decomposes block into its constituent parts.

Source§

impl Block<Checked>

Source

pub fn header(&self) -> &Header

Gets a reference to the block header.

Source

pub fn transactions(&self) -> &[Transaction]

Gets a reference to the block’s list of transactions.

Source

pub fn cached_witness_root(&self) -> Option<WitnessMerkleNode>

Returns the cached witness root if one is present.

It is assumed that a block will have the witness root calculated and cached as part of the validation process.

Source§

impl<V: Validation> Block<V>

Source

pub fn block_hash(&self) -> BlockHash

Returns the block hash.

Trait Implementations§

Source§

impl<'a> Arbitrary<'a> for Block

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<V> Clone for Block<V>
where V: Validation + Clone,

Source§

fn clone(&self) -> Block<V>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V> Debug for Block<V>
where V: Validation + Debug,

Source§

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

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

impl<'de, V> Deserialize<'de> for Block<V>
where V: Validation,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&Block> for BlockHash

Source§

fn from(block: &Block) -> BlockHash

Converts to this type from the input type.
Source§

impl From<Block> for BlockHash

Source§

fn from(block: Block) -> BlockHash

Converts to this type from the input type.
Source§

impl<V> PartialEq for Block<V>
where V: Validation + PartialEq,

Source§

fn eq(&self, other: &Block<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V> Serialize for Block<V>
where V: Validation,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V> Eq for Block<V>
where V: Validation + Eq,

Source§

impl<V> StructuralPartialEq for Block<V>
where V: Validation,

Auto Trait Implementations§

§

impl<V> Freeze for Block<V>

§

impl<V> RefUnwindSafe for Block<V>
where V: RefUnwindSafe,

§

impl<V> Send for Block<V>

§

impl<V> Sync for Block<V>

§

impl<V> Unpin for Block<V>

§

impl<V> UnwindSafe for Block<V>
where V: UnwindSafe,

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<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,