blocks.rs 793 Bytes
Newer Older
1
// SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
// SPDX-License-Identifier: Apache-2.0
3

4
5
//! Block identification types for token sequences.

6
7
8
use serde::{Deserialize, Serialize};
use uuid::Uuid;

9
/// A global hash type for identifying blocks.
10
11
pub type GlobalHash = u64;

12
/// Represents an active block being built.
13
14
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub enum UniqueBlock {
15
    /// Block identified by UUID (partial/incomplete block).
16
    PartialBlock(Uuid),
17
    /// Block identified by hash (complete block).
18
19
20
21
22
23
24
25
26
    FullBlock(GlobalHash),
}

impl Default for UniqueBlock {
    fn default() -> Self {
        // Generate a random UUID when default is used
        Self::PartialBlock(Uuid::new_v4())
    }
}