block_height.rs

Overview

This file defines the BlockHeight struct, which encapsulates the concept of a block height within a specific thread context in a multi-threaded or sharded system. The BlockHeight struct tracks the position of a block in a sequence, scoped by a ThreadIdentifier. This allows for thread-isolated block height management, ensuring that block heights are meaningful only within their respective threads.

The file provides functionality to obtain the next block height within a thread and to compute a signed distance between two block heights of the same thread. This is useful for comparing progress or ordering within a thread.

Structs and Methods

BlockHeight

pub struct BlockHeight {
    thread_identifier: ThreadIdentifier,
    height: u64,
}

Derives and Traits

Methods

next(&self, thread_identifier: &ThreadIdentifier) -> Self
signed_distance_to(&self, other: &BlockHeight) -> Option<i128>

Implementation Details and Algorithms

Interactions with Other Components

This file is fundamental for any system logic that requires tracking, comparing, or advancing block heights in a multi-threaded or sharded environment.


Structure Diagram

classDiagram
class BlockHeight {
-thread_identifier: ThreadIdentifier
-height: u64
+next()
+signed_distance_to()
+thread_identifier()
+height()
}