pub trait CallManager: 'static {
    type Machine: Machine;

Show 27 methods // Required methods fn new( machine: Self::Machine, engine: Engine, gas_limit: u64, origin: u64, origin_address: Address, receiver: Option<u64>, receiver_address: Address, nonce: u64, gas_premium: TokenAmount, ) -> Self; fn call_actor<K>( &mut self, from: u64, to: Address, entrypoint: Entrypoint, params: Option<Block>, value: &TokenAmount, gas_limit: Option<Gas>, read_only: bool, ) -> Result<InvocationResult, ExecutionError> where K: Kernel<CallManager = Self>; fn with_transaction( &mut self, f: impl FnOnce(&mut Self) -> Result<InvocationResult, ExecutionError>, ) -> Result<InvocationResult, ExecutionError>; fn finish(self) -> (Result<FinishRet, ExecutionError>, Self::Machine); fn machine(&self) -> &Self::Machine; fn machine_mut(&mut self) -> &mut Self::Machine; fn engine(&self) -> &Engine; fn gas_tracker(&self) -> &GasTracker; fn gas_premium(&self) -> &TokenAmount; fn origin(&self) -> u64; fn next_actor_address(&self) -> Address; fn create_actor( &mut self, code_id: Cid<64>, actor_id: u64, delegated_address: Option<Address>, ) -> Result<(), ExecutionError>; fn get_call_stack(&self) -> &[(u64, &'static str)]; fn resolve_address( &self, address: &Address, ) -> Result<Option<u64>, ExecutionError>; fn set_actor( &mut self, id: u64, state: ActorState, ) -> Result<(), ExecutionError>; fn get_actor(&self, id: u64) -> Result<Option<ActorState>, ExecutionError>; fn delete_actor(&mut self, id: u64) -> Result<(), ExecutionError>; fn transfer( &mut self, from: u64, to: u64, value: &TokenAmount, ) -> Result<(), ExecutionError>; fn nonce(&self) -> u64; fn invocation_count(&self) -> u64; fn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter; fn append_event(&mut self, evt: StampedEvent); // Provided methods fn price_list(&self) -> &PriceList { ... } fn context(&self) -> &MachineContext { ... } fn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore { ... } fn externs(&self) -> &<Self::Machine as Machine>::Externs { ... } fn charge_gas(&self, charge: GasCharge) -> Result<GasTimer, ExecutionError> { ... }
}
Expand description

The CallManager manages a single call stack.

When a top-level message is executed:

  1. The crate::executor::Executor creates a CallManager for that message, giving itself to the CallManager.
  2. The crate::executor::Executor calls the specified actor/entrypoint using CallManager::call_actor().
  3. The CallManager then constructs a Kernel and executes the actual actor code on that kernel.
  4. If an actor calls another actor, the Kernel will:
    1. Detach the CallManager from itself.
    2. Call CallManager::call_actor() to execute the new message.
    3. Re-attach the CallManager.
    4. Return.

Required Associated Types§

source

type Machine: Machine

The underlying Machine on top of which this CallManager executes.

Required Methods§

source

fn new( machine: Self::Machine, engine: Engine, gas_limit: u64, origin: u64, origin_address: Address, receiver: Option<u64>, receiver_address: Address, nonce: u64, gas_premium: TokenAmount, ) -> Self

Construct a new call manager.

source

fn call_actor<K>( &mut self, from: u64, to: Address, entrypoint: Entrypoint, params: Option<Block>, value: &TokenAmount, gas_limit: Option<Gas>, read_only: bool, ) -> Result<InvocationResult, ExecutionError>
where K: Kernel<CallManager = Self>,

Calls an actor at the given address and entrypoint. The type parameter K specifies the the kernel on top of which the target actor should execute.

source

fn with_transaction( &mut self, f: impl FnOnce(&mut Self) -> Result<InvocationResult, ExecutionError>, ) -> Result<InvocationResult, ExecutionError>

Execute some operation (usually a call_actor) within a transaction.

source

fn finish(self) -> (Result<FinishRet, ExecutionError>, Self::Machine)

Finishes execution, returning the gas used, machine, and exec trace if requested.

source

fn machine(&self) -> &Self::Machine

Returns a reference to the machine.

source

fn machine_mut(&mut self) -> &mut Self::Machine

Returns a mutable reference to the machine.

source

fn engine(&self) -> &Engine

Returns a reference to the engine

source

fn gas_tracker(&self) -> &GasTracker

Returns a reference to the gas tracker.

source

fn gas_premium(&self) -> &TokenAmount

Returns the gas premium paid by the currently executing message.

source

fn origin(&self) -> u64

Getter for origin actor.

source

fn next_actor_address(&self) -> Address

Get the actor address (f2) that will should be assigned to the next actor created.

This method doesn’t have any side-effects and will continue to return the same address until create_actor is called next.

source

fn create_actor( &mut self, code_id: Cid<64>, actor_id: u64, delegated_address: Option<Address>, ) -> Result<(), ExecutionError>

Create a new actor with the given code CID, actor ID, and delegated address. This method does not register the actor with the init actor. It just creates it in the state-tree.

It handles all appropriate gas charging for creating new actors.

source

fn get_call_stack(&self) -> &[(u64, &'static str)]

source

fn resolve_address( &self, address: &Address, ) -> Result<Option<u64>, ExecutionError>

Resolve an address into an actor ID, charging gas as appropriate.

source

fn set_actor( &mut self, id: u64, state: ActorState, ) -> Result<(), ExecutionError>

Sets an actor in the state-tree, charging gas as appropriate. Use create_actor if you want to create a new actor.

source

fn get_actor(&self, id: u64) -> Result<Option<ActorState>, ExecutionError>

Looks up an actor in the state-tree, charging gas as appropriate.

source

fn delete_actor(&mut self, id: u64) -> Result<(), ExecutionError>

Deletes an actor from the state-tree, charging gas as appropriate.

source

fn transfer( &mut self, from: u64, to: u64, value: &TokenAmount, ) -> Result<(), ExecutionError>

Transfers tokens from one actor to another, charging gas as appropriate.

source

fn nonce(&self) -> u64

Getter for message nonce.

source

fn invocation_count(&self) -> u64

Gets the total invocations done on this call stack.

source

fn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter

Limit memory usage throughout a message execution.

source

fn append_event(&mut self, evt: StampedEvent)

Appends an event to the event accumulator.

Provided Methods§

source

fn price_list(&self) -> &PriceList

Returns the current price list.

source

fn context(&self) -> &MachineContext

Returns the machine context.

source

fn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore

Returns the blockstore.

source

fn externs(&self) -> &<Self::Machine as Machine>::Externs

Returns the externs.

source

fn charge_gas(&self, charge: GasCharge) -> Result<GasTimer, ExecutionError>

Charge gas.

Object Safety§

This trait is not object safe.

Implementors§