Trait fvm::call_manager::CallManager
source · pub trait CallManager: 'static {
type Machine: Machine;
Show 27 methods
// Required methods
fn new(
machine: Self::Machine,
engine: Engine,
gas_limit: u64,
origin: ActorID,
origin_address: Address,
receiver: Option<ActorID>,
receiver_address: Address,
nonce: u64,
gas_premium: TokenAmount,
) -> Self;
fn call_actor<K: Kernel<CallManager = Self>>(
&mut self,
from: ActorID,
to: Address,
entrypoint: Entrypoint,
params: Option<Block>,
value: &TokenAmount,
gas_limit: Option<Gas>,
read_only: bool,
) -> Result<InvocationResult>;
fn with_transaction(
&mut self,
f: impl FnOnce(&mut Self) -> Result<InvocationResult>,
) -> Result<InvocationResult>;
fn finish(self) -> (Result<FinishRet>, 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) -> ActorID;
fn next_actor_address(&self) -> Address;
fn create_actor(
&mut self,
code_id: Cid,
actor_id: ActorID,
delegated_address: Option<Address>,
) -> Result<()>;
fn get_call_stack(&self) -> &[(ActorID, &'static str)];
fn resolve_address(&self, address: &Address) -> Result<Option<ActorID>>;
fn set_actor(&mut self, id: ActorID, state: ActorState) -> Result<()>;
fn get_actor(&self, id: ActorID) -> Result<Option<ActorState>>;
fn delete_actor(&mut self, id: ActorID) -> Result<()>;
fn transfer(
&mut self,
from: ActorID,
to: ActorID,
value: &TokenAmount,
) -> Result<()>;
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> { ... }
}
Expand description
The CallManager
manages a single call stack.
When a top-level message is executed:
- The
crate::executor::Executor
creates aCallManager
for that message, giving itself to theCallManager
. - The
crate::executor::Executor
calls the specified actor/entrypoint usingCallManager::call_actor()
. - The
CallManager
then constructs aKernel
and executes the actual actor code on that kernel. - If an actor calls another actor, the
Kernel
will:- Detach the
CallManager
from itself. - Call
CallManager::call_actor()
to execute the new message. - Re-attach the
CallManager
. - Return.
- Detach the
Required Associated Types§
sourcetype Machine: Machine
type Machine: Machine
The underlying Machine
on top of which this CallManager
executes.
Required Methods§
sourcefn new(
machine: Self::Machine,
engine: Engine,
gas_limit: u64,
origin: ActorID,
origin_address: Address,
receiver: Option<ActorID>,
receiver_address: Address,
nonce: u64,
gas_premium: TokenAmount,
) -> Self
fn new( machine: Self::Machine, engine: Engine, gas_limit: u64, origin: ActorID, origin_address: Address, receiver: Option<ActorID>, receiver_address: Address, nonce: u64, gas_premium: TokenAmount, ) -> Self
Construct a new call manager.
sourcefn call_actor<K: Kernel<CallManager = Self>>(
&mut self,
from: ActorID,
to: Address,
entrypoint: Entrypoint,
params: Option<Block>,
value: &TokenAmount,
gas_limit: Option<Gas>,
read_only: bool,
) -> Result<InvocationResult>
fn call_actor<K: Kernel<CallManager = Self>>( &mut self, from: ActorID, to: Address, entrypoint: Entrypoint, params: Option<Block>, value: &TokenAmount, gas_limit: Option<Gas>, read_only: bool, ) -> Result<InvocationResult>
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.
sourcefn with_transaction(
&mut self,
f: impl FnOnce(&mut Self) -> Result<InvocationResult>,
) -> Result<InvocationResult>
fn with_transaction( &mut self, f: impl FnOnce(&mut Self) -> Result<InvocationResult>, ) -> Result<InvocationResult>
Execute some operation (usually a call_actor) within a transaction.
sourcefn finish(self) -> (Result<FinishRet>, Self::Machine)
fn finish(self) -> (Result<FinishRet>, Self::Machine)
Finishes execution, returning the gas used, machine, and exec trace if requested.
sourcefn machine_mut(&mut self) -> &mut Self::Machine
fn machine_mut(&mut self) -> &mut Self::Machine
Returns a mutable reference to the machine.
sourcefn gas_tracker(&self) -> &GasTracker
fn gas_tracker(&self) -> &GasTracker
Returns a reference to the gas tracker.
Returns the gas premium paid by the currently executing message.
sourcefn next_actor_address(&self) -> Address
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.
sourcefn create_actor(
&mut self,
code_id: Cid,
actor_id: ActorID,
delegated_address: Option<Address>,
) -> Result<()>
fn create_actor( &mut self, code_id: Cid, actor_id: ActorID, delegated_address: Option<Address>, ) -> Result<()>
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.
fn get_call_stack(&self) -> &[(ActorID, &'static str)]
sourcefn resolve_address(&self, address: &Address) -> Result<Option<ActorID>>
fn resolve_address(&self, address: &Address) -> Result<Option<ActorID>>
Resolve an address into an actor ID, charging gas as appropriate.
sourcefn set_actor(&mut self, id: ActorID, state: ActorState) -> Result<()>
fn set_actor(&mut self, id: ActorID, state: ActorState) -> Result<()>
Sets an actor in the state-tree, charging gas as appropriate. Use create_actor
if you want
to create a new actor.
sourcefn get_actor(&self, id: ActorID) -> Result<Option<ActorState>>
fn get_actor(&self, id: ActorID) -> Result<Option<ActorState>>
Looks up an actor in the state-tree, charging gas as appropriate.
sourcefn delete_actor(&mut self, id: ActorID) -> Result<()>
fn delete_actor(&mut self, id: ActorID) -> Result<()>
Deletes an actor from the state-tree, charging gas as appropriate.
sourcefn transfer(
&mut self,
from: ActorID,
to: ActorID,
value: &TokenAmount,
) -> Result<()>
fn transfer( &mut self, from: ActorID, to: ActorID, value: &TokenAmount, ) -> Result<()>
Transfers tokens from one actor to another, charging gas as appropriate.
sourcefn invocation_count(&self) -> u64
fn invocation_count(&self) -> u64
Gets the total invocations done on this call stack.
sourcefn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter
fn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter
Limit memory usage throughout a message execution.
sourcefn append_event(&mut self, evt: StampedEvent)
fn append_event(&mut self, evt: StampedEvent)
Appends an event to the event accumulator.
Provided Methods§
sourcefn price_list(&self) -> &PriceList
fn price_list(&self) -> &PriceList
Returns the current price list.
sourcefn context(&self) -> &MachineContext
fn context(&self) -> &MachineContext
Returns the machine context.
sourcefn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore
fn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore
Returns the blockstore.
sourcefn charge_gas(&self, charge: GasCharge) -> Result<GasTimer>
fn charge_gas(&self, charge: GasCharge) -> Result<GasTimer>
Charge gas.