Struct jormungandr::blockcfg::Ledger
source · 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
impl Ledger
pub fn new<'a, I>( block0_initial_hash: Hash, contents: I ) -> Result<Ledger, Error>where I: IntoIterator<Item = &'a Fragment>,
pub fn can_distribute_reward(&self) -> bool
pub fn apply_protocol_changes(&self) -> Result<Ledger, Error>
sourcepub fn distribute_rewards(
&self,
distribution: &StakeDistribution,
rewards_info_params: RewardsInfoParameters
) -> Result<(Ledger, EpochRewardsInfo), Error>
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
pub fn begin_block( &self, chain_length: ChainLength, block_date: BlockDate ) -> Result<ApplyBlockLedger, Error>
sourcepub fn apply_block(
&self,
contents: &Contents,
metadata: &HeaderContentEvalContext
) -> Result<Ledger, Error>
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
sourcepub fn apply_fragment(
&self,
content: &Fragment,
block_date: BlockDate
) -> Result<Ledger, Error>
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.
sourcepub fn apply_transaction<Extra>(
self,
fragment_id: &Hash,
tx: &TransactionSlice<'_, Extra>
) -> Result<(Ledger, Value), Error>where
Extra: Payload,
LinearFee: FeeAlgorithm,
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.
pub fn apply_update(self, update: &UpdateProposal) -> Result<Ledger, Error>
pub fn apply_update_proposal( self, proposal_id: Hash, proposal: UpdateProposal, auth_data: &TransactionBindingAuthData<'_>, sig: SingleAccountBindingSignature, cur_date: BlockDate ) -> Result<Ledger, Error>
pub fn apply_update_vote( self, vote: &UpdateVote, auth_data: &TransactionBindingAuthData<'_>, sig: SingleAccountBindingSignature ) -> Result<Ledger, Error>
pub fn apply_vote_plan( self, tx: &TransactionSlice<'_, VotePlan>, cur_date: BlockDate, vote_plan: VotePlan, sig: VotePlanProof ) -> Result<Ledger, Error>
pub fn apply_vote_cast( self, account_id: Identifier, vote: VoteCast ) -> Result<Ledger, Error>
pub fn active_vote_plans(&self) -> Vec<VotePlanStatus, Global>
pub fn apply_vote_tally( self, tally: &VoteTally, bad: &TransactionBindingAuthData<'_>, sig: TallyProof ) -> Result<Ledger, Error>
pub fn apply_pool_registration_signcheck( self, cert: &PoolRegistration, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>
pub fn apply_pool_registration( self, cert: &PoolRegistration ) -> Result<Ledger, Error>
pub fn apply_pool_retirement( self, auth_cert: &PoolRetirement, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>
pub fn apply_pool_update( self, auth_cert: &PoolUpdate, bad: &TransactionBindingAuthData<'_>, sig: PoolSignature ) -> Result<Ledger, Error>
pub fn apply_stake_delegation( self, auth_cert: &StakeDelegation ) -> Result<Ledger, Error>
pub fn apply_owner_stake_delegation( self, account_id: &UnspecifiedAccountIdentifier, witness: &Witness, delegation: &OwnerStakeDelegation ) -> Result<Ledger, Error>
pub fn mint_token(self, mt: MintToken) -> Result<Ledger, Error>
pub fn mint_token_unchecked(self, mt: MintToken) -> Result<Ledger, Error>
pub fn get_stake_distribution(&self) -> StakeDistribution
sourcepub fn get_static_parameters(&self) -> &LedgerStaticParameters
pub fn get_static_parameters(&self) -> &LedgerStaticParameters
access the ledger static parameters
pub fn accounts(&self) -> &Ledger<Identifier, ()>
pub fn updates(&self) -> &UpdateState
pub fn token_totals(&self) -> &TokenTotals
pub fn token_distribution(&self) -> TokenDistribution<'_, ()>
pub fn consensus_version(&self) -> ConsensusType
pub fn utxo_out(&self, fragment_id: Hash, index: u8) -> Option<&Output<Address>>
pub fn utxos(&self) -> Iter<'_, Address>
pub fn chain_length(&self) -> ChainLength
pub fn settings(&self) -> &Settings
pub fn delegation(&self) -> &PoolsState
pub fn delegation_mut(&mut self) -> &mut PoolsState
pub fn date(&self) -> BlockDate
pub fn era(&self) -> &TimeEra
pub fn get_total_value(&self) -> Result<Value, Error>
pub fn remaining_rewards(&self) -> Value
pub fn treasury_value(&self) -> Value
Trait Implementations§
source§impl DeserializeFromSlice for Ledger
impl DeserializeFromSlice for Ledger
source§impl From<TestLedger> for Ledger
impl From<TestLedger> for Ledger
source§fn from(from: TestLedger) -> Ledger
fn from(from: TestLedger) -> Ledger
source§impl PartialEq<Ledger> for Ledger
impl PartialEq<Ledger> for Ledger
source§impl Serialize for Ledger
impl Serialize for Ledger
fn serialize<W>(&self, codec: &mut Codec<W>) -> Result<(), WriteError>where W: Write,
source§fn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
source§fn serialize_as_vec(&self) -> Result<Vec<u8, Global>, WriteError>
fn serialize_as_vec(&self) -> Result<Vec<u8, Global>, WriteError>
impl Eq for Ledger
impl StructuralEq for Ledger
impl StructuralPartialEq for Ledger
Auto Trait Implementations§
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnwindSafe for Ledger
Blanket Implementations§
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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