Struct BlockExtra

Source
pub struct BlockExtra { /* private fields */ }
Expand description

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

Implementations§

Source§

impl BlockExtra

Source

pub fn version(&self) -> u8

Source

pub fn block(&self) -> &Block

Returns the block from the bytes

This is an expensive operation, re-use the results instead of calling it multiple times

Source

pub fn block_bytes(&self) -> &[u8]

Source

pub fn block_hash(&self) -> BlockHash

Source

pub fn size(&self) -> u32

Source

pub fn next(&self) -> &Vec<BlockHash>

Source

pub fn height(&self) -> u32

Source

pub fn outpoint_values(&self) -> &HashMap<OutPoint, TxOut>

Source

pub fn block_total_inputs(&self) -> usize

Source

pub fn block_total_outputs(&self) -> usize

Source

pub fn txids(&self) -> &Vec<Txid>

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

requires serializing the block bytes, consider using a visitor on the bytes for performance

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 for BlockExtra

Source§

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

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

const 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 TryFrom<FsBlock> for BlockExtra

Source§

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 StructuralPartialEq for BlockExtra

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.