MCPcopy Create free account
hub / github.com/casper-network/casper-node / Component

Interface Component

node/src/components.rs:125–149  ·  view source on GitHub ↗

Core Component. Every component process a set of events it defines itself Its inputs are `Event`s, allowing it to perform work whenever an event is received, outputting `Effect`s each time it is called. # Error and halting states Components in general are expected to be able to handle every input (`Event`) in every state. Invalid inputs are supposed to be discarded, and the machine is expected

Source from the content-addressed store, hash-verified

123/// Components place restrictions on reactor events (`REv`s), indicating what kind of effects they
124/// need to be able to produce to operate.
125pub(crate) trait Component<REv> {
126 /// Event associated with `Component`.
127 ///
128 /// The event type that is handled by the component.
129 type Event;
130
131 /// Name of the component.
132 fn name(&self) -> &str;
133
134 /// Activate/deactivate a failpoint.
135 fn activate_failpoint(&mut self, _activation: &FailpointActivation) {
136 // Default is to ignore failpoints.
137 }
138
139 /// Processes an event, outputting zero or more effects.
140 ///
141 /// This function must not ever perform any blocking or CPU intensive work, as it is expected
142 /// to return very quickly -- it will usually be called from an `async` function context.
143 fn handle_event(
144 &mut self,
145 effect_builder: EffectBuilder<REv>,
146 rng: &mut NodeRng,
147 event: Self::Event,
148 ) -> Effects<Self::Event>;
149}
150
151pub(crate) trait InitializedComponent<REv>: Component<REv> {
152 fn state(&self) -> &ComponentState;

Callers

nothing calls this directly

Implementers 15

upgrade_watcher.rsnode/src/components/upgrade_watcher.rs
contract_runtime.rsnode/src/components/contract_runtime.r
event_stream_server.rsnode/src/components/event_stream_serve
binary_port.rsnode/src/components/binary_port.rs
fetcher.rsnode/src/components/fetcher.rs
metrics.rsnode/src/components/metrics.rs
transaction_buffer.rsnode/src/components/transaction_buffer
block_accumulator.rsnode/src/components/block_accumulator.
gossiper.rsnode/src/components/gossiper.rs
in_memory_network.rsnode/src/components/in_memory_network.
consensus.rsnode/src/components/consensus.rs
block_synchronizer.rsnode/src/components/block_synchronizer

Calls

no outgoing calls

Tested by

no test coverage detected