pub struct Ledger {
Show 16 fields pub(crate) utxos: Ledger<Address>, pub(crate) oldutxos: Ledger<Addr>, pub(crate) accounts: Ledger<Identifier, ()>, pub(crate) settings: Settings, pub(crate) updates: UpdateState, pub(crate) multisig: Ledger, pub(crate) delegation: PoolsState, pub(crate) static_params: Arc<LedgerStaticParameters, Global>, pub(crate) date: BlockDate, pub(crate) chain_length: ChainLength, pub(crate) era: TimeEra, pub(crate) pots: Pots, pub(crate) leaders_log: LeadersParticipationRecord, pub(crate) votes: VotePlanLedger, pub(crate) governance: Governance, pub(crate) token_totals: TokenTotals,
}
Expand description

Overall ledger structure.

This represent a given state related to utxo/old utxo/accounts/… at a given point in time.

The ledger can be easily and cheaply cloned despite containing reference to a lot of data (millions of utxos, thousands of accounts, ..)

Fields§

§utxos: Ledger<Address>§oldutxos: Ledger<Addr>§accounts: Ledger<Identifier, ()>§settings: Settings§updates: UpdateState§multisig: Ledger§delegation: PoolsState§static_params: Arc<LedgerStaticParameters, Global>§date: BlockDate§chain_length: ChainLength§era: TimeEra§pots: Pots§leaders_log: LeadersParticipationRecord§votes: VotePlanLedger§governance: Governance§token_totals: TokenTotals

Implementations§

source§

impl Ledger

source

pub fn stats(&self) -> Vec<String, Global>

source

pub fn info_eq(&self, other: &Ledger) -> Vec<String, Global>

source§

impl Ledger

source

pub fn iter(&self) -> LedgerIterator<'_>

source§

impl Ledger

source

pub fn new<'a, I>( block0_initial_hash: Hash, contents: I ) -> Result<Ledger, Error>where I: IntoIterator<Item = &'a Fragment>,

source

pub fn can_distribute_reward(&self) -> bool

source

pub fn apply_protocol_changes(&self) -> Result<Ledger, Error>

source

pub fn distribute_rewards( &self, distribution: &StakeDistribution, rewards_info_params: RewardsInfoParameters ) -> Result<(Ledger, EpochRewardsInfo), Error>

This need to be called before the first block of a new epoch

  • Reset the leaders log
  • Distribute the contribution (rewards + fees) to pools and their delegatees
source

pub fn begin_block( &self, chain_length: ChainLength, block_date: BlockDate ) -> Result<ApplyBlockLedger, Error>

source

pub fn apply_block( &self, contents: &Contents, metadata: &HeaderContentEvalContext ) -> Result<Ledger, Error>

Try to apply messages to a State, and return the new State if successful

source

pub fn apply_fragment( &self, content: &Fragment, block_date: BlockDate ) -> Result<Ledger, Error>

Try to apply a message to the State, and return the new State if successful

this does not advance the state to the new state but apply a simple fragment of block to the current context.

source

pub fn apply_transaction<Extra>( self, fragment_id: &Hash, tx: &TransactionSlice<'_, Extra> ) -> Result<(Ledger, Value), Error>where Extra: Payload, LinearFee: FeeAlgorithm,

Applies transaction to the account ledger by validating and verifying inputs and outputs, as well as spending the fee value from the related account id. Returns an Error if the account cannot afford the fee or if the spending counter doesn’t match.

source

pub fn apply_update(self, update: &UpdateProposal) -> Result<Ledger, Error>

source

pub fn apply_update_proposal( self, proposal_id: Hash, proposal: UpdateProposal, auth_data: &TransactionBindingAuthData<'_>, sig: SingleAccountBindingSignature, cur_date: BlockDate ) -> Result<Ledger, Error>

source

pub fn apply_update_vote( self, vote: &UpdateVote, auth_data: &TransactionBindingAuthData<'_>, sig: SingleAccountBindingSignature ) -> Result<Ledger, Error>

source

pub fn apply_vote_plan( self, tx: &TransactionSlice<'_, VotePlan>, cur_date: BlockDate, vote_plan: VotePlan, sig: VotePlanProof ) -> Result<Ledger, Error>

source

pub fn apply_vote_cast( self, account_id: Identifier, vote: VoteCast ) -> Result<Ledger, Error>

source

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

source

pub fn apply_vote_tally( self, tally: &VoteTally, bad: &TransactionBindingAuthData<'_>, sig: TallyProof ) -> Result<Ledger, Error>

source

pub fn apply_pool_registration_signcheck( self, cert: &PoolRegistration, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>

source

pub fn apply_pool_registration( self, cert: &PoolRegistration ) -> Result<Ledger, Error>

source

pub fn apply_pool_retirement( self, auth_cert: &PoolRetirement, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>

source

pub fn apply_pool_update( self, auth_cert: &PoolUpdate, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>

source

pub fn apply_stake_delegation( self, auth_cert: &StakeDelegation ) -> Result<Ledger, Error>

source

pub fn apply_owner_stake_delegation( self, account_id: &UnspecifiedAccountIdentifier, witness: &Witness, delegation: &OwnerStakeDelegation ) -> Result<Ledger, Error>

source

pub fn mint_token(self, mt: MintToken) -> Result<Ledger, Error>

source

pub fn mint_token_unchecked(self, mt: MintToken) -> Result<Ledger, Error>

source

pub fn get_stake_distribution(&self) -> StakeDistribution

source

pub fn get_static_parameters(&self) -> &LedgerStaticParameters

access the ledger static parameters

source

pub fn accounts(&self) -> &Ledger<Identifier, ()>

source

pub fn updates(&self) -> &UpdateState

source

pub fn token_totals(&self) -> &TokenTotals

source

pub fn token_distribution(&self) -> TokenDistribution<'_, ()>

source

pub fn consensus_version(&self) -> ConsensusType

source

pub fn utxo_out(&self, fragment_id: Hash, index: u8) -> Option<&Output<Address>>

source

pub fn utxos(&self) -> Iter<'_, Address>

source

pub fn chain_length(&self) -> ChainLength

source

pub fn settings(&self) -> &Settings

source

pub fn delegation(&self) -> &PoolsState

source

pub fn delegation_mut(&mut self) -> &mut PoolsState

source

pub fn date(&self) -> BlockDate

source

pub fn era(&self) -> &TimeEra

source

pub fn get_total_value(&self) -> Result<Value, Error>

source

pub fn remaining_rewards(&self) -> Value

source

pub fn treasury_value(&self) -> Value

Trait Implementations§

source§

impl Arbitrary for Ledger

source§

fn arbitrary<G>(g: &mut G) -> Ledgerwhere G: Gen,

§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>, Global>

source§

impl Clone for Ledger

source§

fn clone(&self) -> Ledger

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

impl Debug for Ledger

source§

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

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

impl DeserializeFromSlice for Ledger

source§

impl From<TestLedger> for Ledger

source§

fn from(from: TestLedger) -> Ledger

Converts to this type from the input type.
source§

impl PartialEq<Ledger> for Ledger

source§

fn eq(&self, other: &Ledger) -> 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 Serialize for Ledger

source§

fn serialize<W>(&self, codec: &mut Codec<W>) -> Result<(), WriteError>where W: Write,

source§

fn serialized_size(&self) -> usize

Default implementation, not efficient, not recommended to use it
source§

fn serialize_as_vec(&self) -> Result<Vec<u8, Global>, WriteError>

Convenience method to serialize into a byte vector.
source§

impl Eq for Ledger

source§

impl StructuralEq for Ledger

source§

impl StructuralPartialEq for Ledger

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<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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