mod.rs

Overview

This file defines the ThreadState struct and its associated methods, which manage the state transitions of blockchain blocks in a thread. The struct handles two types of checkpoints: a finalized block that is immutable and a prefinalized block that can be reverted if necessary. The implementation enforces non-clonability of ThreadState to prevent unintended duplication and state inconsistencies.

The primary functionality is to move forward the finalized and prefinalized states by applying new blocks wrapped in cryptographic envelopes (Envelope<GoshBLS, AckiNackiBlock>). This ensures that state progression is cryptographically verified and consistent with the consensus rules.

Structs and Methods

ThreadState

pub struct ThreadState {
    last_finalized: Checkpoint,
    last_prefinalized: Checkpoint,
}

Methods

move_finalized

pub fn move_finalized(self, next_finalized_block: Envelope<GoshBLS, AckiNackiBlock>) -> Self
let updated_state = current_state.move_finalized(next_block_envelope);

move_prefinalized

pub fn move_prefinalized(self, next_prefinalized_block: Envelope<GoshBLS, AckiNackiBlock>) -> Self

Important Implementation Details

Interactions with Other Components

Mermaid Diagram

classDiagram
class ThreadState {
-last_finalized: Checkpoint
-last_prefinalized: Checkpoint
+move_finalized()
+move_prefinalized()
}
ThreadState --> Checkpoint : uses
ThreadState --> Envelope : consumes
Envelope --> GoshBLS : cryptographic wrapper
Envelope --> AckiNackiBlock : contains