events.rs

Overview

This file defines event types related to changes in the blockchain's state, specifically focusing on the lifecycle of blocks within threads. The events represented here indicate key stages such as when a block is finalized, prefinalized, applied, or when a new thread starts processing with a collection of unfinalized block candidates. These events enable other parts of the system to react appropriately to changes in the blockchain state.

The primary components of this file are:

Structs

BlockFinalizedEvent

Represents the event when a block is finalized on a particular thread.

Fields

Accessors

All fields have public getter methods generated by the derive_getters crate, allowing read-only access.

Usage Example

let event = BlockFinalizedEvent {
    thread_identifier: some_thread_id,
    block_height: Some(some_block_height),
};

let thread = event.thread_identifier();
let height = event.block_height();

BlockPrefinalizedEvent

Represents a block reaching the prefinalized state on a thread.

Fields

Accessors

Public getter methods are available for both fields.


BlockAppliedEvent

Indicates that a block has been applied to the state of a thread.

Fields

Accessors

Getter methods provide read access to these fields.


Enum: ChainPulseEvent

A unified enum encapsulating all chain pulse events that can occur related to block processing and thread management.

Variants

StartThread Fields


Associated Functions

Convenience constructors for creating instances of ChainPulseEvent with minimal boilerplate:

Usage Example

let event = ChainPulseEvent::block_finalized(thread_id, Some(block_height));

Implementation Details

Interactions with Other Modules

Diagram

classDiagram
class BlockFinalizedEvent {
-thread_identifier
-block_height
+thread_identifier()
+block_height()
}
class BlockPrefinalizedEvent {
-thread_identifier
-block_height
+thread_identifier()
+block_height()
}
class BlockAppliedEvent {
-thread_identifier
-block_height
+thread_identifier()
+block_height()
}
class ChainPulseEvent {
+block_finalized()
+block_prefinalized()
+block_applied()
+start_thread()
}
ChainPulseEvent o-- BlockFinalizedEvent : contains
ChainPulseEvent o-- BlockPrefinalizedEvent : contains
ChainPulseEvent o-- BlockAppliedEvent : contains
ChainPulseEvent ..> UnfinalizedCandidateBlockCollection : uses in StartThread
ChainPulseEvent ..> ThreadIdentifier
BlockFinalizedEvent ..> ThreadIdentifier
BlockPrefinalizedEvent ..> ThreadIdentifier
BlockAppliedEvent ..> ThreadIdentifier

This diagram illustrates the relationship among the event structs and the ChainPulseEvent enum, showing composition and usage relations with key types.