[][src]Module casper_node::reactor

Reactor core.

Any long running instance of the node application uses an event-dispatch pattern: Events are generated and stored on an event queue, then processed one-by-one. This process happens inside the reactor*, which also exclusively holds the state of the application besides pending events:

  1. The reactor pops an event off the event queue (called a Scheduler).
  2. The event is dispatched by the reactor. Since the reactor holds mutable state, it can grant any component that processes an event mutable, exclusive access to its state.
  3. Once the (synchronous) event processing has completed, the component returns an effect.
  4. The reactor spawns a task that executes these effects and eventually schedules another event.
  5. meanwhile go to 1.

Reactors

There is no single reactor, but rather a reactor for each application type, since it defines which components are used and how they are wired up. The reactor defines the state by being a struct of components, their initialization through the Reactor::new() and a method Reactor::dispatch_event() to dispatch events to components.

With all these set up, a reactor can be executed using a Runner, either in a step-wise manner using crank or indefinitely using run.

Modules

initializer

Reactor used to initialize a node.

initializer2

Reactor used to initialize a node.

joiner

Reactor used to join the network.

validator

Reactor for validator nodes.

Structs

EventQueueHandle

Event queue handle

Runner

A runner for a reactor.

Enums

QueueKind

Scheduling priority.

Traits

Finalize

A drop-like trait for async compatible drop-and-wait.

Reactor

Reactor core.

Functions

wrap_effects

Converts multiple effects into another by wrapping.

Type Definitions

Scheduler

Event scheduler