pub trait Block:
AsBlock
+ BlockDescriptor
+ BlockHooks
+ Send
+ Sync {
// Required method
fn execute(&mut self, runtime: &dyn BlockRuntime) -> Result<(), BlockError>;
// Provided method
fn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError> { ... }
}Expand description
A block is an autonomous unit of computation in a system.
Required Methods§
Sourcefn execute(&mut self, runtime: &dyn BlockRuntime) -> Result<(), BlockError>
fn execute(&mut self, runtime: &dyn BlockRuntime) -> Result<(), BlockError>
Executes this block’s computation.
Provided Methods§
Sourcefn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError>
fn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError>
Prepares this block for execution.
This is called once before the first call to execute.
This is where to open ports and allocate resources.