pub struct ActorRuntime<S: Syscalls, BS: Blockstore> {
pub syscalls: S,
pub blockstore: BS,
}Expand description
ActorRuntime provides access to system resources via Syscalls and the Blockstore.
It provides higher level utilities than raw syscalls for actors to use to interact with the IPLD layer and the FVM runtime (e.g. messaging other actors).
Fields§
§syscalls: S§blockstore: BSImplementations§
Source§impl<S: Syscalls + Clone, BS: Blockstore + Clone> ActorRuntime<S, BS>
impl<S: Syscalls + Clone, BS: Blockstore + Clone> ActorRuntime<S, BS>
pub fn new_fvm_runtime() -> ActorRuntime<FvmSyscalls, Blockstore>
Source§impl<S: Syscalls, BS: Blockstore> ActorRuntime<S, BS>
impl<S: Syscalls, BS: Blockstore> ActorRuntime<S, BS>
pub fn new(syscalls: S, blockstore: BS) -> ActorRuntime<S, BS>
Sourcepub fn new_test_runtime() -> ActorRuntime<FakeSyscalls, MemoryBlockstore>
pub fn new_test_runtime() -> ActorRuntime<FakeSyscalls, MemoryBlockstore>
Creates a runtime suitable for tests, using mock syscalls and a memory blockstore.
Creates a runtime suitable for more complex tests, using mock syscalls and a memory blockstore.
Clones of this runtime will reference the same blockstore.
pub fn caller(&self) -> ActorID
Sourcepub fn send(
&self,
to: &Address,
method: MethodNum,
params: Option<IpldBlock>,
value: TokenAmount,
) -> MessagingResult<Response>
pub fn send( &self, to: &Address, method: MethodNum, params: Option<IpldBlock>, value: TokenAmount, ) -> MessagingResult<Response>
Sends a message to an actor.
Sourcepub fn resolve_id(&self, address: &Address) -> MessagingResult<ActorID>
pub fn resolve_id(&self, address: &Address) -> MessagingResult<ActorID>
Attempts to resolve the given address to its ID address form.
Returns MessagingError::AddressNotResolved if the address could not be resolved.
Sourcepub fn resolve_or_init(&self, address: &Address) -> MessagingResult<ActorID>
pub fn resolve_or_init(&self, address: &Address) -> MessagingResult<ActorID>
Resolves an address to an ID address, sending a message to initialize an account there if it doesn’t exist.
If the account cannot be created, this function returns
MessagingError::AddressNotInitialized.
pub fn initialize_account(&self, address: &Address) -> MessagingResult<ActorID>
Sourcepub fn root_cid(&self) -> Result<Cid, ActorError>
pub fn root_cid(&self) -> Result<Cid, ActorError>
Get the root cid of the actor’s state.
Sourcepub fn set_root(&self, cid: &Cid) -> Result<(), ActorError>
pub fn set_root(&self, cid: &Cid) -> Result<(), ActorError>
Set the root cid of the actor’s state.
Sourcepub fn same_address(&self, address_a: &Address, address_b: &Address) -> bool
pub fn same_address(&self, address_a: &Address, address_b: &Address) -> bool
Attempts to compare two addresses, seeing if they would resolve to the same Actor without actually instantiating accounts for them.
If a and b are of the same type, simply do an equality check. Otherwise, attempt to resolve to an ActorID and compare.
pub fn bs(&self) -> &BS
Trait Implementations§
Source§impl<S: Syscalls, BS: Blockstore> Blockstore for ActorRuntime<S, BS>
Convenience impl encapsulating the blockstore functionality.
impl<S: Syscalls, BS: Blockstore> Blockstore for ActorRuntime<S, BS>
Convenience impl encapsulating the blockstore functionality.
Source§fn put_keyed(&self, k: &Cid, block: &[u8]) -> Result<()>
fn put_keyed(&self, k: &Cid, block: &[u8]) -> Result<()>
Source§fn has(&self, k: &Cid<64>) -> Result<bool, Error>
fn has(&self, k: &Cid<64>) -> Result<bool, Error>
Source§fn put<D>(&self, mh_code: Code, block: &Block<D>) -> Result<Cid<64>, Error>
fn put<D>(&self, mh_code: Code, block: &Block<D>) -> Result<Cid<64>, Error>
Source§impl<S: Clone + Syscalls, BS: Clone + Blockstore> Clone for ActorRuntime<S, BS>
impl<S: Clone + Syscalls, BS: Clone + Blockstore> Clone for ActorRuntime<S, BS>
Source§fn clone(&self) -> ActorRuntime<S, BS>
fn clone(&self) -> ActorRuntime<S, BS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more