pub struct BlockExtra {
    pub version: u8,
    pub block: Block,
    pub block_hash: BlockHash,
    pub size: u32,
    pub next: Vec<BlockHash>,
    pub height: u32,
    pub outpoint_values: HashMap<OutPoint, TxOut>,
    pub block_total_inputs: u32,
    pub block_total_outputs: u32,
    pub txids: Vec<Txid>,
}
Expand description

The bitcoin block and additional metadata returned by the crate::iter() method

Fields§

§version: u8

Serialization format version

§block: Block

The bitcoin block

§block_hash: BlockHash

The bitcoin block hash, same as block.block_hash() but result from hashing is cached

§size: u32

The byte size of the block, as returned by in serialize(block).len()

§next: Vec<BlockHash>

Hash of the blocks following this one, it’s a vec because during reordering they may be more than one because of reorgs, as a result from the iteration, it’s just one.

§height: u32

The height of the current block, number of blocks between this one and the genesis block

§outpoint_values: HashMap<OutPoint, TxOut>

All the previous outputs of this block. Allowing to validate the script or computing the fee Note that when configuration skip_script_pubkey is true, the script is empty, when skip_prevout is true, this map is empty.

§block_total_inputs: u32

Total number of transaction inputs in this block

§block_total_outputs: u32

Total number of transaction outputs in this block

§txids: Vec<Txid>

Precomputed transaction hashes such that txids[i]=block.txdata[i].txid()

Implementations§

source§

impl BlockExtra

source

pub fn average_fee(&self) -> Option<f64>

Returns the average transaction fee in the block

source

pub fn fee(&self) -> Option<u64>

Returns the total fee of the block

source

pub fn tx_fee(&self, tx: &Transaction) -> Option<u64>

Returns the fee of a transaction contained in the block

source

pub fn base_reward(&self) -> u64

Return the base block reward in satoshi

source

pub fn iter_tx(&self) -> impl Iterator<Item = (&Txid, &Transaction)>

Iterate transactions of blocks together with their txids

Trait Implementations§

source§

impl Debug for BlockExtra

source§

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

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

impl Decodable for BlockExtra

source§

fn consensus_decode<D: Read + ?Sized>(d: &mut D) -> Result<Self, Error>

Decode an object with a well-defined format. Read more
source§

fn consensus_decode_from_finite_reader<R>(reader: &mut R) -> Result<Self, Error>where R: Read + ?Sized,

Decode Self from a size-limited reader. Read more
source§

impl Encodable for BlockExtra

source§

fn consensus_encode<W: Write + ?Sized>( &self, writer: &mut W ) -> Result<usize, Error>

Encodes an object with a well-defined format. Read more
source§

impl PartialEq<BlockExtra> for BlockExtra

source§

fn eq(&self, other: &BlockExtra) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<FsBlock> for BlockExtra

§

type Error = String

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

fn try_from(fs_block: FsBlock) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for BlockExtra

source§

impl StructuralEq for BlockExtra

source§

impl StructuralPartialEq for BlockExtra

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.