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>
impl Block<Unchecked>
Sourcepub fn new_unchecked(
header: Header,
transactions: Vec<Transaction>,
) -> Block<Unchecked>
pub fn new_unchecked( header: Header, transactions: Vec<Transaction>, ) -> Block<Unchecked>
Constructs a new Block
without doing any validation.
Sourcepub fn assume_checked(
self,
witness_root: Option<WitnessMerkleNode>,
) -> Block<Checked>
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.
Sourcepub fn into_parts(self) -> (Header, Vec<Transaction>)
pub fn into_parts(self) -> (Header, Vec<Transaction>)
Decomposes block into its constituent parts.
Source§impl Block<Checked>
impl Block<Checked>
Sourcepub fn transactions(&self) -> &[Transaction]
pub fn transactions(&self) -> &[Transaction]
Gets a reference to the block’s list of transactions.
Sourcepub fn cached_witness_root(&self) -> Option<WitnessMerkleNode>
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>
impl<V: Validation> Block<V>
Sourcepub fn block_hash(&self) -> BlockHash
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.
impl<'a> Arbitrary<'a> for Block
Available on crate feature
arbitrary
only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
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 moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
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 moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
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 moreSource§impl<'de, V> Deserialize<'de> for Block<V>where
V: Validation,
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>,
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<V> Serialize for Block<V>where
V: Validation,
impl<V> Serialize for Block<V>where
V: Validation,
impl<V> Eq for Block<V>where
V: Validation + Eq,
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> 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
Mutably borrows from an owned value. Read more