Struct jormungandr::blockchain::Ref

source ·
pub struct Ref {
    ledger: Ref<Ledger>,
    time_frame: Arc<TimeFrame>,
    epoch_leadership_schedule: Arc<Leadership>,
    epoch_rewards_info: Option<Arc<EpochRewardsInfo>>,
    header: Header,
    previous_epoch_state: Option<Arc<Ref>>,
}
Expand description

a reference to a block in the blockchain

Fields§

§ledger: Ref<Ledger>

Reference holder for the object in the Multiverse<Ledger>.

§time_frame: Arc<TimeFrame>

the time frame applicable in the current branch of the blockchain

§epoch_leadership_schedule: Arc<Leadership>

the leadership used to validate the current header’s leader

this object will be shared between different Ref of the same epoch

§epoch_rewards_info: Option<Arc<EpochRewardsInfo>>

If present, this is the rewards info distributed at the beginning of the epoch. Useful to follow up on the reward distribution history

§header: Header

keep the Block header in memory, this will avoid retrieving the data from the storage if needs be

§previous_epoch_state: Option<Arc<Ref>>

holder to the previous epoch state or more precisely the previous epoch’s last Ref. Every time there is a transition this value will be filled with the parent Ref. Otherwise it will be copied from Ref to Ref.

Implementations§

source§

impl Ref

source

pub fn new( ledger: Ref<Ledger>, time_frame: Arc<TimeFrame>, epoch_leadership_schedule: Arc<Leadership>, epoch_rewards_info: Option<Arc<EpochRewardsInfo>>, header: Header, previous_epoch_state: Option<Arc<Ref>> ) -> Self

create a new Ref

source

pub fn hash(&self) -> HeaderHash

retrieve the header hash of the Ref

source

pub fn block_parent_hash(&self) -> HeaderHash

access the reference’s parent hash

source

pub fn block_date(&self) -> BlockDate

retrieve the block date of the Ref

source

pub fn chain_length(&self) -> ChainLength

retrieve the chain length, the number of blocks created between the block0 and this block. This is useful to compare the density of 2 branches.

source

pub fn header(&self) -> &Header

access the Header of the block pointed by this Ref

source

pub fn ledger(&self) -> Arc<Ledger>

source

pub fn time_frame(&self) -> &Arc<TimeFrame>

get the time frame in application in the current branch of the blockchain

source

pub fn epoch_leadership_schedule(&self) -> &Arc<Leadership>

source

pub fn epoch_rewards_info(&self) -> Option<&Arc<EpochRewardsInfo>>

access the rewards info that were distributed at the end of the previous epoch (and that are accessible/visible from this epoch only).

source

pub fn last_ref_previous_epoch(&self) -> Option<&Arc<Ref>>

source

pub fn slot(&self) -> Slot

get the chain_time’s Slot. This allows to compute an accurate block time via a given time_frame or a precise block time

source

pub fn time(&self) -> SystemTime

retrieve the time of the associated block.

source

pub fn elapsed(&self) -> Result<Duration, SystemTimeError>

retrieve the time of the slot of the block. If the block is set in the future, this function will return an error.

source

pub fn active_vote_plans(&self) -> Vec<VotePlanStatus>

clone all active vote plans at this given state

this includes, votes to be voted on, on going votes, votes to be resolved and votes to result into a change on the ledger

Trait Implementations§

source§

impl Clone for Ref

source§

fn clone(&self) -> Ref

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

Auto Trait Implementations§

§

impl RefUnwindSafe for Ref

§

impl Send for Ref

§

impl Sync for Ref

§

impl Unpin for Ref

§

impl UnwindSafe for Ref

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.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize = _

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> ToOwned for Twhere T: Clone,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more