[−][src]Struct casperlabs_engine_core::runtime_context::RuntimeContext
Holds information specific to the deployed contract.
Implementations
impl<'a, R> RuntimeContext<'a, R> where
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>, [src]
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>,
pub fn new(
state: Rc<RefCell<TrackingCopy<R>>>,
named_keys: &'a mut BTreeMap<String, Key>,
access_rights: HashMap<Address, HashSet<AccessRights>>,
args: Vec<CLValue>,
authorization_keys: BTreeSet<PublicKey>,
account: &'a Account,
base_key: Key,
blocktime: BlockTime,
deploy_hash: [u8; 32],
gas_limit: Gas,
gas_counter: Gas,
fn_store_id: u32,
address_generator: Rc<RefCell<AddressGenerator>>,
protocol_version: ProtocolVersion,
correlation_id: CorrelationId,
phase: Phase,
protocol_data: ProtocolData
) -> Self[src]
state: Rc<RefCell<TrackingCopy<R>>>,
named_keys: &'a mut BTreeMap<String, Key>,
access_rights: HashMap<Address, HashSet<AccessRights>>,
args: Vec<CLValue>,
authorization_keys: BTreeSet<PublicKey>,
account: &'a Account,
base_key: Key,
blocktime: BlockTime,
deploy_hash: [u8; 32],
gas_limit: Gas,
gas_counter: Gas,
fn_store_id: u32,
address_generator: Rc<RefCell<AddressGenerator>>,
protocol_version: ProtocolVersion,
correlation_id: CorrelationId,
phase: Phase,
protocol_data: ProtocolData
) -> Self
pub fn authorization_keys(&self) -> &BTreeSet<PublicKey>[src]
pub fn named_keys_get(&self, name: &str) -> Option<&Key>[src]
pub fn named_keys(&self) -> &BTreeMap<String, Key>[src]
pub fn fn_store_id(&self) -> u32[src]
pub fn named_keys_contains_key(&self, name: &str) -> bool[src]
pub fn remove_key(&mut self, name: &str) -> Result<(), Error>[src]
Remove Key from the named_keys map of the current context.
It removes both from the ephemeral map (RuntimeContext::named_keys) but
also persistable map (one that is found in the
TrackingCopy/GlobalState).
pub fn get_caller(&self) -> PublicKey[src]
pub fn get_blocktime(&self) -> BlockTime[src]
pub fn get_deployhash(&self) -> [u8; 32][src]
pub fn access_rights_extend(
&mut self,
access_rights: HashMap<Address, HashSet<AccessRights>>
)[src]
&mut self,
access_rights: HashMap<Address, HashSet<AccessRights>>
)
pub fn account(&self) -> &'a Account[src]
pub fn args(&self) -> &Vec<CLValue>[src]
pub fn address_generator(&self) -> Rc<RefCell<AddressGenerator>>[src]
pub fn state(&self) -> Rc<RefCell<TrackingCopy<R>>>[src]
pub fn gas_limit(&self) -> Gas[src]
pub fn gas_counter(&self) -> Gas[src]
pub fn set_gas_counter(&mut self, new_gas_counter: Gas)[src]
pub fn inc_fn_store_id(&mut self)[src]
pub fn base_key(&self) -> Key[src]
pub fn seed(&self) -> [u8; 32][src]
pub fn protocol_version(&self) -> ProtocolVersion[src]
pub fn correlation_id(&self) -> CorrelationId[src]
pub fn phase(&self) -> Phase[src]
pub fn new_function_address(&mut self) -> Result<[u8; 32], Error>[src]
Generates new function address.
Function address is deterministic. It is a hash of public key, nonce and
fn_store_id, which is a counter that is being incremented after
every function generation. If function address was based only on
account's public key and deploy's nonce, then all function addresses
generated within one deploy would have been the same.
pub fn new_uref(&mut self, value: StoredValue) -> Result<URef, Error>[src]
pub fn put_key(&mut self, name: String, key: Key) -> Result<(), Error>[src]
Puts key to the map of named keys of current context.
pub fn read_ls(&mut self, key: &[u8]) -> Result<Option<CLValue>, Error>[src]
pub fn read_ls_with_seed(
&mut self,
seed: [u8; 32],
key_bytes: &[u8]
) -> Result<Option<CLValue>, Error>[src]
&mut self,
seed: [u8; 32],
key_bytes: &[u8]
) -> Result<Option<CLValue>, Error>
DO NOT EXPOSE THIS VIA THE FFI
pub fn write_ls(
&mut self,
key_bytes: &[u8],
cl_value: CLValue
) -> Result<(), Error>[src]
&mut self,
key_bytes: &[u8],
cl_value: CLValue
) -> Result<(), Error>
pub fn read_gs(&mut self, key: &Key) -> Result<Option<StoredValue>, Error>[src]
pub fn read_gs_direct(
&mut self,
key: &Key
) -> Result<Option<StoredValue>, Error>[src]
&mut self,
key: &Key
) -> Result<Option<StoredValue>, Error>
DO NOT EXPOSE THIS VIA THE FFI
pub fn read_gs_typed<T>(&mut self, key: &Key) -> Result<T, Error> where
T: TryFrom<StoredValue>,
T::Error: Debug, [src]
T: TryFrom<StoredValue>,
T::Error: Debug,
This method is a wrapper over read_gs in the sense that it extracts the type held by a
StoredValue stored in the global state in a type safe manner.
This is useful if you want to get the exact type from global state.
pub fn write_gs(&mut self, key: Key, value: StoredValue) -> Result<(), Error>[src]
pub fn read_account(&mut self, key: &Key) -> Result<Option<StoredValue>, Error>[src]
pub fn write_account(&mut self, key: Key, account: Account) -> Result<(), Error>[src]
pub fn store_function(
&mut self,
contract: StoredValue
) -> Result<[u8; 32], Error>[src]
&mut self,
contract: StoredValue
) -> Result<[u8; 32], Error>
pub fn store_function_at_hash(
&mut self,
contract: StoredValue
) -> Result<[u8; 32], Error>[src]
&mut self,
contract: StoredValue
) -> Result<[u8; 32], Error>
pub fn insert_key(&mut self, name: String, key: Key)[src]
pub fn insert_uref(&mut self, uref: URef)[src]
pub fn effect(&self) -> ExecutionEffect[src]
pub fn validate_key(&self, key: &Key) -> Result<(), Error>[src]
Validates whether key is not forged (whether it can be found in the
named_keys) and whether the version of a key that contract wants
to use, has access rights that are less powerful than access rights'
of the key in the named_keys.
pub fn validate_uref(&self, uref: &URef) -> Result<(), Error>[src]
pub fn deserialize_keys(&self, bytes: Vec<u8>) -> Result<Vec<Key>, Error>[src]
pub fn deserialize_urefs(&self, bytes: Vec<u8>) -> Result<Vec<URef>, Error>[src]
pub fn is_readable(&self, key: &Key) -> bool[src]
Tests whether reading from the key is valid.
pub fn is_addable(&self, key: &Key) -> bool[src]
Tests whether addition to key is valid.
pub fn is_writeable(&self, key: &Key) -> bool[src]
Tests whether writing to key is valid.
pub fn add_gs(&mut self, key: Key, value: StoredValue) -> Result<(), Error>[src]
Adds value to the key. The premise for being able to add value is
that the type of it [value] can be added (is a Monoid). If the
values can't be added, either because they're not a Monoid or if the
value stored under key has different type, then TypeMismatch
errors is returned.
pub fn add_ls(
&mut self,
key_bytes: &[u8],
cl_value: CLValue
) -> Result<(), Error>[src]
&mut self,
key_bytes: &[u8],
cl_value: CLValue
) -> Result<(), Error>
pub fn add_associated_key(
&mut self,
public_key: PublicKey,
weight: Weight
) -> Result<(), Error>[src]
&mut self,
public_key: PublicKey,
weight: Weight
) -> Result<(), Error>
pub fn remove_associated_key(
&mut self,
public_key: PublicKey
) -> Result<(), Error>[src]
&mut self,
public_key: PublicKey
) -> Result<(), Error>
pub fn update_associated_key(
&mut self,
public_key: PublicKey,
weight: Weight
) -> Result<(), Error>[src]
&mut self,
public_key: PublicKey,
weight: Weight
) -> Result<(), Error>
pub fn set_action_threshold(
&mut self,
action_type: ActionType,
threshold: Weight
) -> Result<(), Error>[src]
&mut self,
action_type: ActionType,
threshold: Weight
) -> Result<(), Error>
pub fn upgrade_contract_at_uref(
&mut self,
key: Key,
bytes: Vec<u8>,
named_keys: BTreeMap<String, Key>
) -> Result<(), Error>[src]
&mut self,
key: Key,
bytes: Vec<u8>,
named_keys: BTreeMap<String, Key>
) -> Result<(), Error>
pub fn protocol_data(&self) -> ProtocolData[src]
pub fn get_main_purse(&self) -> Result<URef, Error>[src]
Gets main purse id
Trait Implementations
impl<'a, R> Mint for RuntimeContext<'a, R> where
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>, [src]
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>,
fn mint(&mut self, initial_balance: U512) -> Result<URef, Error>[src]
fn balance(&mut self, purse: URef) -> Result<Option<U512>, Error>[src]
fn transfer(
&mut self,
source: URef,
dest: URef,
amount: U512
) -> Result<(), Error>[src]
&mut self,
source: URef,
dest: URef,
amount: U512
) -> Result<(), Error>
impl<'a, R> RuntimeProvider for RuntimeContext<'a, R> where
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>, [src]
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>,
impl<'a, R> StorageProvider for RuntimeContext<'a, R> where
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>, [src]
R: StateReader<Key, StoredValue>,
R::Error: Into<Error>,
fn new_uref<T: CLTyped + ToBytes>(&mut self, init: T) -> URef[src]
fn write_local<K: ToBytes, V: CLTyped + ToBytes>(&mut self, key: K, value: V)[src]
fn read_local<K: ToBytes, V: CLTyped + FromBytes>(
&mut self,
key: &K
) -> Result<Option<V>, Error>[src]
&mut self,
key: &K
) -> Result<Option<V>, Error>
fn read<T: CLTyped + FromBytes>(
&mut self,
uref: URef
) -> Result<Option<T>, Error>[src]
&mut self,
uref: URef
) -> Result<Option<T>, Error>
fn write<T: CLTyped + ToBytes>(
&mut self,
uref: URef,
value: T
) -> Result<(), Error>[src]
&mut self,
uref: URef,
value: T
) -> Result<(), Error>
fn add<T: CLTyped + ToBytes>(
&mut self,
uref: URef,
value: T
) -> Result<(), Error>[src]
&mut self,
uref: URef,
value: T
) -> Result<(), Error>
Auto Trait Implementations
impl<'a, R> !RefUnwindSafe for RuntimeContext<'a, R>
impl<'a, R> !Send for RuntimeContext<'a, R>
impl<'a, R> !Sync for RuntimeContext<'a, R>
impl<'a, R> Unpin for RuntimeContext<'a, R>
impl<'a, R> !UnwindSafe for RuntimeContext<'a, R>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> FromBits<T> for T
fn from_bits(other: T) -> T
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,