mod.rs

Overview

The mod.rs file implements the Cross-Thread Reference Data Availability Synchronization Service, a concurrency utility designed to manage synchronization of reference data across multiple threads during block production and validation. It facilitates communication between threads by sending and receiving commands related to the preparation and dependency management of cross-thread reference data encapsulated in BlockState instances.

This service ensures that blocks depending on reference data from other threads can await the availability of such data before proceeding, thereby maintaining consistency and correctness in block validation workflows.

Key Components

Enum: Command

Defines the types of messages that can be sent to the synchronization service to perform specific synchronization operations:

Struct: CrossThreadRefDataAvailabilitySynchronizationServiceInterface

This struct acts as the public API interface for clients to send commands to the synchronization service. It encapsulates an instrumented sender channel for sending Command messages to the service's internal processing loop.

Fields

Methods

Struct: CrossThreadRefDataAvailabilitySynchronizationService

This struct represents the actual synchronization service instance. It owns the interface and manages the background thread that runs the core synchronization logic.

Fields

Methods

Implementation Details and Algorithms

Interaction with Other Modules

This file is central to managing the synchronization of reference data across threads in the block production and validation system, facilitating safe and efficient concurrency.


Structure Diagram

classDiagram
class CrossThreadRefDataAvailabilitySynchronizationService {
-interface: CrossThreadRefDataAvailabilitySynchronizationServiceInterface
-_handler: JoinHandle
+new(metrics: Option<BlockProductionMetrics>) Result
+interface() CrossThreadRefDataAvailabilitySynchronizationServiceInterface
}
class CrossThreadRefDataAvailabilitySynchronizationServiceInterface {
-send_tx: InstrumentedSender
+send_cross_thread_ref_data_prepared(block_state: BlockState)
+send_await_cross_thread_ref_data(block_state: BlockState, dependencies: Vec<BlockState>)
}
class Command {
<<enumeration>>
NotifyCrossThreadRefDataPrepared
SetCrossThreadRefDataDependencies
}
CrossThreadRefDataAvailabilitySynchronizationService --> CrossThreadRefDataAvailabilitySynchronizationServiceInterface : owns
CrossThreadRefDataAvailabilitySynchronizationServiceInterface --> Command : sends

This diagram illustrates the ownership and interaction between the service, its interface, and the command messages it processes.