fuel_core_storage/
column.rs

1//! The module defines the `Column` and default tables used by the current `fuel-core` codebase.
2//! In the future, the `Column` enum should contain only the required tables for the execution.
3//! All other tables should live in the downstream creates in the place where they are really used.
4
5#![allow(deprecated)]
6
7use crate::kv_store::StorageColumn;
8
9use alloc::string::{
10    String,
11    ToString,
12};
13
14/// Database tables column ids to the corresponding [`crate::Mappable`] table.
15#[repr(u32)]
16#[derive(
17    Copy,
18    Clone,
19    Debug,
20    strum_macros::EnumCount,
21    strum_macros::IntoStaticStr,
22    PartialEq,
23    Eq,
24    enum_iterator::Sequence,
25    Hash,
26    num_enum::TryFromPrimitive,
27)]
28pub enum Column {
29    /// The column id of metadata about the blockchain
30    Metadata = 0,
31    /// See [`ContractsRawCode`](crate::tables::ContractsRawCode)
32    ContractsRawCode = 1,
33    /// See [`ContractsState`](crate::tables::ContractsState)
34    ContractsState = 2,
35    /// See [`ContractsLatestUtxo`](crate::tables::ContractsLatestUtxo)
36    ContractsLatestUtxo = 3,
37    /// See [`ContractsAssets`](crate::tables::ContractsAssets)
38    ContractsAssets = 4,
39    /// See [`Coins`](crate::tables::Coins)
40    Coins = 5,
41    /// See [`Transactions`](crate::tables::Transactions)
42    Transactions = 6,
43    /// See [`FuelBlocks`](crate::tables::FuelBlocks)
44    FuelBlocks = 7,
45    /// See [`FuelBlockMerkleData`](crate::tables::merkle::FuelBlockMerkleData)
46    FuelBlockMerkleData = 8,
47    /// See [`FuelBlockMerkleMetadata`](crate::tables::merkle::FuelBlockMerkleMetadata)
48    FuelBlockMerkleMetadata = 9,
49    #[deprecated]
50    /// This column was used by SMT in the past, but is no longer in use.
51    ContractsAssetsMerkleData = 10,
52    #[deprecated]
53    /// This column was used by SMT in the past, but is no longer in use.
54    ContractsAssetsMerkleMetadata = 11,
55    #[deprecated]
56    /// This column was used by SMT in the past, but is no longer in use.
57    ContractsStateMerkleData = 12,
58    #[deprecated]
59    /// This column was used by SMT in the past, but is no longer in use.
60    ContractsStateMerkleMetadata = 13,
61    /// See [`Messages`](crate::tables::Messages)
62    Messages = 14,
63    /// See [`ProcessedTransactions`](crate::tables::ProcessedTransactions)
64    ProcessedTransactions = 15,
65    /// See [`SealedBlockConsensus`](crate::tables::SealedBlockConsensus)
66    FuelBlockConsensus = 16,
67    /// See [`ConsensusParametersVersions`](crate::tables::ConsensusParametersVersions)
68    ConsensusParametersVersions = 17,
69    /// See [`StateTransitionBytecodeVersions`](crate::tables::StateTransitionBytecodeVersions)
70    StateTransitionBytecodeVersions = 18,
71    /// See [`UploadedBytecodes`](crate::tables::UploadedBytecodes)
72    UploadedBytecodes = 19,
73    /// See [`Blobs`](fuel_vm_private::storage::BlobData)
74    Blobs = 20,
75
76    // TODO: Remove this column and use `Metadata` column instead.
77    /// Table for genesis state import progress tracking.
78    GenesisMetadata = 21,
79}
80
81impl Column {
82    /// The total count of variants in the enum.
83    pub const COUNT: usize = <Self as strum::EnumCount>::COUNT;
84
85    /// Returns the `usize` representation of the `Column`.
86    pub fn as_u32(&self) -> u32 {
87        *self as u32
88    }
89}
90
91impl StorageColumn for Column {
92    fn name(&self) -> String {
93        let str: &str = self.into();
94        str.to_string()
95    }
96
97    fn id(&self) -> u32 {
98        self.as_u32()
99    }
100}