pub struct RuntimeNative<S> { /* private fields */ }Expand description
State held by an instance of runtime native.
Implementations§
Source§impl<S> RuntimeNative<S>
impl<S> RuntimeNative<S>
Sourcepub fn new(
config: Config,
protocol_version: ProtocolVersion,
id: Id,
address_generator: Arc<RwLock<AddressGenerator>>,
tracking_copy: Rc<RefCell<TrackingCopy<S>>>,
address: AccountHash,
context_key: Key,
runtime_footprint: RuntimeFootprint,
access_rights: ContextAccessRights,
remaining_spending_limit: U512,
phase: Phase,
) -> Self
pub fn new( config: Config, protocol_version: ProtocolVersion, id: Id, address_generator: Arc<RwLock<AddressGenerator>>, tracking_copy: Rc<RefCell<TrackingCopy<S>>>, address: AccountHash, context_key: Key, runtime_footprint: RuntimeFootprint, access_rights: ContextAccessRights, remaining_spending_limit: U512, phase: Phase, ) -> Self
Ctor.
Sourcepub fn new_system_runtime(
config: Config,
protocol_version: ProtocolVersion,
id: Id,
address_generator: Arc<RwLock<AddressGenerator>>,
tracking_copy: Rc<RefCell<TrackingCopy<S>>>,
phase: Phase,
) -> Result<Self, TrackingCopyError>
pub fn new_system_runtime( config: Config, protocol_version: ProtocolVersion, id: Id, address_generator: Arc<RwLock<AddressGenerator>>, tracking_copy: Rc<RefCell<TrackingCopy<S>>>, phase: Phase, ) -> Result<Self, TrackingCopyError>
Creates a runtime with elevated permissions for systemic behaviors.
Sourcepub fn new_system_contract_runtime(
config: Config,
protocol_version: ProtocolVersion,
id: Id,
address_generator: Arc<RwLock<AddressGenerator>>,
tracking_copy: Rc<RefCell<TrackingCopy<S>>>,
phase: Phase,
name: &str,
) -> Result<Self, TrackingCopyError>
pub fn new_system_contract_runtime( config: Config, protocol_version: ProtocolVersion, id: Id, address_generator: Arc<RwLock<AddressGenerator>>, tracking_copy: Rc<RefCell<TrackingCopy<S>>>, phase: Phase, name: &str, ) -> Result<Self, TrackingCopyError>
Creates a runtime context for a system contract.
Sourcepub fn address_generator(&mut self) -> Arc<RwLock<AddressGenerator>> ⓘ
pub fn address_generator(&mut self) -> Arc<RwLock<AddressGenerator>> ⓘ
Returns mutable reference to address generator.
Sourcepub fn transfer_config(&self) -> &TransferConfig
pub fn transfer_config(&self) -> &TransferConfig
Returns reference to transfer config.
Sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Returns protocol version.
Sourcepub fn tracking_copy(&self) -> Rc<RefCell<TrackingCopy<S>>>
pub fn tracking_copy(&self) -> Rc<RefCell<TrackingCopy<S>>>
Returns handle to tracking copy.
Sourcepub fn address(&self) -> AccountHash
pub fn address(&self) -> AccountHash
Returns account hash being used by this instance.
Sourcepub fn with_address(&mut self, account_hash: AccountHash)
pub fn with_address(&mut self, account_hash: AccountHash)
Changes the account hash being used by this instance.
Sourcepub fn context_key(&self) -> &Key
pub fn context_key(&self) -> &Key
Returns the context key being used by this instance.
Sourcepub fn runtime_footprint(&self) -> &RuntimeFootprint
pub fn runtime_footprint(&self) -> &RuntimeFootprint
Returns a reference to the runtime footprint used by this instance.
Sourcepub fn runtime_footprint_mut(&mut self) -> &mut RuntimeFootprint
pub fn runtime_footprint_mut(&mut self) -> &mut RuntimeFootprint
Returns the addressable entity being used by this instance.
Sourcepub fn with_addressable_entity(&mut self, runtime_footprint: RuntimeFootprint)
pub fn with_addressable_entity(&mut self, runtime_footprint: RuntimeFootprint)
Changes the addressable entity being used by this instance.
Sourcepub fn named_keys(&self) -> &NamedKeys
pub fn named_keys(&self) -> &NamedKeys
Returns a reference to the named keys being used by this instance.
Sourcepub fn named_keys_mut(&mut self) -> &mut NamedKeys
pub fn named_keys_mut(&mut self) -> &mut NamedKeys
Returns a mutable reference to the named keys being used by this instance.
Sourcepub fn access_rights(&self) -> &ContextAccessRights
pub fn access_rights(&self) -> &ContextAccessRights
Returns a reference to the access rights being used by this instance.
Sourcepub fn access_rights_mut(&mut self) -> &mut ContextAccessRights
pub fn access_rights_mut(&mut self) -> &mut ContextAccessRights
Returns a mutable reference to the access rights being used by this instance.
Sourcepub fn extend_access_rights(&mut self, urefs: &[URef])
pub fn extend_access_rights(&mut self, urefs: &[URef])
Extends the access rights being used by this instance.
Sourcepub fn remaining_spending_limit(&self) -> U512
pub fn remaining_spending_limit(&self) -> U512
Returns the remaining spending limit.
Sourcepub fn set_remaining_spending_limit(&mut self, remaining: U512)
pub fn set_remaining_spending_limit(&mut self, remaining: U512)
Set remaining spending limit.
Sourcepub fn push_transfer(&mut self, transfer: Transfer)
pub fn push_transfer(&mut self, transfer: Transfer)
Push transfer instance.
Sourcepub fn vesting_schedule_period_millis(&self) -> u64
pub fn vesting_schedule_period_millis(&self) -> u64
Vesting schedule period in milliseconds.
Sourcepub fn allow_auction_bids(&self) -> bool
pub fn allow_auction_bids(&self) -> bool
Are auction bids allowed?
Sourcepub fn compute_rewards(&self) -> bool
pub fn compute_rewards(&self) -> bool
Are rewards computed?
Sourcepub fn into_transfers(self) -> Vec<Transfer>
pub fn into_transfers(self) -> Vec<Transfer>
Extracts transfer items.
Trait Implementations§
Source§impl<S> AccountProvider for RuntimeNative<S>
impl<S> AccountProvider for RuntimeNative<S>
Source§fn set_main_purse(&mut self, purse: URef)
fn set_main_purse(&mut self, purse: URef)
Set main purse.
Source§impl<S> Auction for RuntimeNative<S>
impl<S> Auction for RuntimeNative<S>
Source§fn get_era_validators(&mut self) -> Result<EraValidators, Error>
fn get_era_validators(&mut self) -> Result<EraValidators, Error>
Source§fn read_seigniorage_recipients(
&mut self,
) -> Result<SeigniorageRecipientsV2, Error>
fn read_seigniorage_recipients( &mut self, ) -> Result<SeigniorageRecipientsV2, Error>
Source§fn add_bid(
&mut self,
public_key: PublicKey,
delegation_rate: DelegationRate,
amount: U512,
minimum_delegation_amount: u64,
maximum_delegation_amount: u64,
minimum_bid_amount: u64,
max_delegators_per_validator: u32,
reserved_slots: u32,
) -> Result<U512, ApiError>
fn add_bid( &mut self, public_key: PublicKey, delegation_rate: DelegationRate, amount: U512, minimum_delegation_amount: u64, maximum_delegation_amount: u64, minimum_bid_amount: u64, max_delegators_per_validator: u32, reserved_slots: u32, ) -> Result<U512, ApiError>
Key::Bid section of the global state and
creates (or tops off) a bid purse. Post genesis, any new call on this entry point causes a
non-founding validator in the system to exist. Read moreSource§fn withdraw_bid(
&mut self,
public_key: PublicKey,
amount: U512,
minimum_bid_amount: u64,
) -> Result<U512, Error>
fn withdraw_bid( &mut self, public_key: PublicKey, amount: U512, minimum_bid_amount: u64, ) -> Result<U512, Error>
Source§fn delegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
max_delegators_per_validator: u32,
) -> Result<U512, ApiError>
fn delegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, max_delegators_per_validator: u32, ) -> Result<U512, ApiError>
Source§fn undelegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
) -> Result<U512, Error>
fn undelegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, ) -> Result<U512, Error>
Source§fn redelegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
new_validator: PublicKey,
) -> Result<U512, Error>
fn redelegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, new_validator: PublicKey, ) -> Result<U512, Error>
Source§fn add_reservations(
&mut self,
reservations: Vec<Reservation>,
) -> Result<(), Error>
fn add_reservations( &mut self, reservations: Vec<Reservation>, ) -> Result<(), Error>
Source§fn cancel_reservations(
&mut self,
validator: PublicKey,
delegators: Vec<DelegatorKind>,
max_delegators_per_validator: u32,
) -> Result<(), Error>
fn cancel_reservations( &mut self, validator: PublicKey, delegators: Vec<DelegatorKind>, max_delegators_per_validator: u32, ) -> Result<(), Error>
Source§fn slash(&mut self, validator_public_keys: Vec<PublicKey>) -> Result<(), Error>
fn slash(&mut self, validator_public_keys: Vec<PublicKey>) -> Result<(), Error>
Source§fn run_auction(
&mut self,
era_end_timestamp_millis: u64,
evicted_validators: Vec<PublicKey>,
max_delegators_per_validator: u32,
include_credits: bool,
credit_cap: Ratio<U512>,
minimum_bid_amount: u64,
) -> Result<(), ApiError>
fn run_auction( &mut self, era_end_timestamp_millis: u64, evicted_validators: Vec<PublicKey>, max_delegators_per_validator: u32, include_credits: bool, credit_cap: Ratio<U512>, minimum_bid_amount: u64, ) -> Result<(), ApiError>
Source§fn distribute(
&mut self,
rewards: BTreeMap<PublicKey, Vec<U512>>,
) -> Result<(), Error>
fn distribute( &mut self, rewards: BTreeMap<PublicKey, Vec<U512>>, ) -> Result<(), Error>
reward_factors returned by the consensus component.Source§fn activate_bid(
&mut self,
validator: PublicKey,
minimum_bid: u64,
) -> Result<(), Error>
fn activate_bid( &mut self, validator: PublicKey, minimum_bid: u64, ) -> Result<(), Error>
Source§impl<S> HandlePayment for RuntimeNative<S>
impl<S> HandlePayment for RuntimeNative<S>
Source§fn calculate_overpayment_and_fee(
&mut self,
limit: U512,
gas_price: u8,
cost: U512,
consumed: U512,
source_purse: URef,
refund_ratio: Ratio<U512>,
) -> Result<(U512, U512), Error>
fn calculate_overpayment_and_fee( &mut self, limit: U512, gas_price: u8, cost: U512, consumed: U512, source_purse: URef, refund_ratio: Ratio<U512>, ) -> Result<(U512, U512), Error>
Source§impl<S> Mint for RuntimeNative<S>
impl<S> Mint for RuntimeNative<S>
Source§fn mint(&mut self, initial_balance: U512) -> Result<URef, Error>
fn mint(&mut self, initial_balance: U512) -> Result<URef, Error>
initial_balance balance. Returns new purse on success, otherwise
an error.Source§fn reduce_total_supply(&mut self, amount: U512) -> Result<(), Error>
fn reduce_total_supply(&mut self, amount: U512) -> Result<(), Error>
amount. Returns unit on success, otherwise
an error.Source§fn balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
fn balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
purse.Source§impl<S> MintProvider for RuntimeNative<S>
impl<S> MintProvider for RuntimeNative<S>
Source§fn unbond(
&mut self,
unbond_kind: &UnbondKind,
unbond_era: &UnbondEra,
) -> Result<(), Error>
fn unbond( &mut self, unbond_kind: &UnbondKind, unbond_era: &UnbondEra, ) -> Result<(), Error>
Source§fn mint_transfer_direct(
&mut self,
to: Option<AccountHash>,
source: URef,
target: URef,
amount: U512,
id: Option<u64>,
) -> Result<Result<(), Error>, Error>
fn mint_transfer_direct( &mut self, to: Option<AccountHash>, source: URef, target: URef, amount: U512, id: Option<u64>, ) -> Result<Result<(), Error>, Error>
Source§fn mint_into_existing_purse(
&mut self,
amount: U512,
existing_purse: URef,
) -> Result<(), Error>
fn mint_into_existing_purse( &mut self, amount: U512, existing_purse: URef, ) -> Result<(), Error>
amount new token into existing_purse.
Returns unit on success, otherwise an error.Source§fn available_balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
fn available_balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
Source§impl<S> MintProvider for RuntimeNative<S>
impl<S> MintProvider for RuntimeNative<S>
Source§fn transfer_purse_to_account(
&mut self,
source: URef,
target: AccountHash,
amount: U512,
) -> Result<TransferredTo, Error>
fn transfer_purse_to_account( &mut self, source: URef, target: AccountHash, amount: U512, ) -> Result<TransferredTo, Error>
amount from source purse to a target account.
Note: the source should always be a system purse of some kind,
such as the payment purse or an accumulator purse.
The target should be the recipient of a refund or a rewardSource§fn transfer_purse_to_purse(
&mut self,
source: URef,
target: URef,
amount: U512,
) -> Result<(), Error>
fn transfer_purse_to_purse( &mut self, source: URef, target: URef, amount: U512, ) -> Result<(), Error>
amount from source purse to a target purse.
Note: the source should always be a system purse of some kind,
such as the payment purse or an accumulator purse.
The target should be the recipient of a refund or a rewardSource§impl<S> RuntimeProvider for RuntimeNative<S>
impl<S> RuntimeProvider for RuntimeNative<S>
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn is_allowed_session_caller(&self, account_hash: &AccountHash) -> bool
fn is_allowed_session_caller(&self, account_hash: &AccountHash) -> bool
Source§fn is_valid_uref(&self, uref: URef) -> bool
fn is_valid_uref(&self, uref: URef) -> bool
Source§fn get_keys(&mut self, key_tag: &KeyTag) -> Result<BTreeSet<Key>, Error>
fn get_keys(&mut self, key_tag: &KeyTag) -> Result<BTreeSet<Key>, Error>
Source§fn get_keys_by_prefix(&mut self, prefix: &[u8]) -> Result<Vec<Key>, Error>
fn get_keys_by_prefix(&mut self, prefix: &[u8]) -> Result<Vec<Key>, Error>
Source§fn delegator_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn delegator_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn used_reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn used_reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn vesting_schedule_period_millis(&self) -> u64
fn vesting_schedule_period_millis(&self) -> u64
Source§fn allow_auction_bids(&self) -> bool
fn allow_auction_bids(&self) -> bool
Source§fn should_compute_rewards(&self) -> bool
fn should_compute_rewards(&self) -> bool
Source§impl<S> RuntimeProvider for RuntimeNative<S>
impl<S> RuntimeProvider for RuntimeNative<S>
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn refund_handling(&self) -> RefundHandling
fn refund_handling(&self) -> RefundHandling
Source§fn fee_handling(&self) -> FeeHandling
fn fee_handling(&self) -> FeeHandling
Source§fn administrative_accounts(&self) -> BTreeSet<AccountHash>
fn administrative_accounts(&self) -> BTreeSet<AccountHash>
Source§impl<S> RuntimeProvider for RuntimeNative<S>
impl<S> RuntimeProvider for RuntimeNative<S>
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn get_immediate_caller(&self) -> Option<Caller>
fn get_immediate_caller(&self) -> Option<Caller>
Source§fn is_called_from_standard_payment(&self) -> bool
fn is_called_from_standard_payment(&self) -> bool
Source§fn get_system_entity_registry(
&self,
) -> Result<SystemHashRegistry, ProviderError>
fn get_system_entity_registry( &self, ) -> Result<SystemHashRegistry, ProviderError>
Source§fn runtime_footprint_by_account_hash(
&mut self,
account_hash: AccountHash,
) -> Result<Option<RuntimeFootprint>, ProviderError>
fn runtime_footprint_by_account_hash( &mut self, account_hash: AccountHash, ) -> Result<Option<RuntimeFootprint>, ProviderError>
Source§fn get_key(&self, name: &str) -> Option<Key>
fn get_key(&self, name: &str) -> Option<Key>
Key under a name.Source§fn get_approved_spending_limit(&self) -> U512
fn get_approved_spending_limit(&self) -> U512
Source§fn sub_approved_spending_limit(&mut self, amount: U512)
fn sub_approved_spending_limit(&mut self, amount: U512)
amount of tokens has been transferred.Source§fn get_main_purse(&self) -> Option<URef>
fn get_main_purse(&self) -> Option<URef>
Source§fn is_administrator(&self, account_hash: &AccountHash) -> bool
fn is_administrator(&self, account_hash: &AccountHash) -> bool
true if the account hash belongs to an administrator account, otherwise false.Source§fn allow_unrestricted_transfers(&self) -> bool
fn allow_unrestricted_transfers(&self) -> bool
Source§fn is_valid_uref(&self, uref: &URef) -> bool
fn is_valid_uref(&self, uref: &URef) -> bool
Source§impl<S> StorageProvider for RuntimeNative<S>
impl<S> StorageProvider for RuntimeNative<S>
Source§fn read<T: FromBytes + CLTyped>(
&mut self,
uref: URef,
) -> Result<Option<T>, Error>
fn read<T: FromBytes + CLTyped>( &mut self, uref: URef, ) -> Result<Option<T>, Error>
URef.Source§fn write<T: ToBytes + CLTyped>(
&mut self,
uref: URef,
value: T,
) -> Result<(), Error>
fn write<T: ToBytes + CLTyped>( &mut self, uref: URef, value: T, ) -> Result<(), Error>
Source§fn read_bid(&mut self, key: &Key) -> Result<Option<BidKind>, Error>
fn read_bid(&mut self, key: &Key) -> Result<Option<BidKind>, Error>
casper_types::system::auction::Bid at account hash derived from given public keySource§fn write_bid(&mut self, key: Key, bid_kind: BidKind) -> Result<(), Error>
fn write_bid(&mut self, key: Key, bid_kind: BidKind) -> Result<(), Error>
BidKind at given key.Source§fn read_unbond(&mut self, bid_addr: BidAddr) -> Result<Option<Unbond>, Error>
fn read_unbond(&mut self, bid_addr: BidAddr) -> Result<Option<Unbond>, Error>
Unbonds at bid address.Source§impl<S> StorageProvider for RuntimeNative<S>
impl<S> StorageProvider for RuntimeNative<S>
Source§impl<S> StorageProvider for RuntimeNative<S>
impl<S> StorageProvider for RuntimeNative<S>
Source§fn new_uref<T: CLTyped + ToBytes>(&mut self, value: T) -> Result<URef, Error>
fn new_uref<T: CLTyped + ToBytes>(&mut self, value: T) -> Result<URef, Error>
URef.Source§fn read<T: CLTyped + FromBytes>(
&mut self,
uref: URef,
) -> Result<Option<T>, Error>
fn read<T: CLTyped + FromBytes>( &mut self, uref: URef, ) -> Result<Option<T>, Error>
URef.Source§impl<S> SystemProvider for RuntimeNative<S>
impl<S> SystemProvider for RuntimeNative<S>
Auto Trait Implementations§
impl<S> Freeze for RuntimeNative<S>
impl<S> !RefUnwindSafe for RuntimeNative<S>
impl<S> !Send for RuntimeNative<S>
impl<S> !Sync for RuntimeNative<S>
impl<S> Unpin for RuntimeNative<S>
impl<S> !UnwindSafe for RuntimeNative<S>
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<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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more