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