Struct Block
pub struct Block {
pub header: Header,
pub txdata: Vec<Transaction>,
}
Expand description
Bitcoin block.
A collection of transactions with an attached proof of work.
See Bitcoin Wiki: Block for more information.
§Bitcoin Core References
Fields§
§header: Header
The block header
txdata: Vec<Transaction>
List of transactions contained in the block
Implementations§
§impl Block
impl Block
pub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the block hash.
pub fn check_merkle_root(&self) -> bool
pub fn check_merkle_root(&self) -> bool
Checks if merkle root of header matches merkle root of the transaction list.
pub fn check_witness_commitment(&self) -> bool
pub fn check_witness_commitment(&self) -> bool
Checks if witness commitment in coinbase matches the transaction list.
pub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
pub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
Computes the transaction merkle root.
pub fn compute_witness_commitment(
witness_root: &WitnessMerkleNode,
witness_reserved_value: &[u8],
) -> WitnessCommitment
pub fn compute_witness_commitment( witness_root: &WitnessMerkleNode, witness_reserved_value: &[u8], ) -> WitnessCommitment
Computes the witness commitment for the block’s transaction list.
pub fn witness_root(&self) -> Option<WitnessMerkleNode>
pub fn witness_root(&self) -> Option<WitnessMerkleNode>
Computes the merkle root of transactions hashed for witness.
pub fn weight(&self) -> Weight
pub fn weight(&self) -> Weight
Returns the weight of the block.
Block weight is defined as Base size * 3 + Total size.
pub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Returns the total block size.
Total size is the block size in bytes with transactions serialized as described in BIP144, including base data and witness data.
pub fn coinbase(&self) -> Option<&Transaction>
pub fn coinbase(&self) -> Option<&Transaction>
Returns the coinbase transaction, if one is present.
pub fn bip34_block_height(&self) -> Result<u64, Bip34Error>
pub fn bip34_block_height(&self) -> Result<u64, Bip34Error>
Returns the block height, as encoded in the coinbase transaction according to BIP34.
Trait Implementations§
§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Block, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Block, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Block
impl Serialize for Block
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request