mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-02-05 04:36:38 +00:00
Boog900
fdd1689665
Some checks failed
Audit / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Deny / audit (push) Has been cancelled
Doc / build (push) Has been cancelled
Doc / deploy (push) Has been cancelled
* split the DB service abstraction * fix ci * misc changes * init tx-pool DBs * add some comments * move more types to `/types` * add some ops * add config & more ops functions & open function * add read & write svcs * add more docs * add write functions + docs * fix merge * fix test * fix ci * move `TxPoolWriteError` * add more docs * fix toml formatting * fix some docs * fix clippy * review fixes * update docs * fix merge * fix docs * fix tests * fix tests * add back lints * Update storage/txpool/README.md Co-authored-by: hinto-janai <hinto.janai@protonmail.com> --------- Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
138 lines
4 KiB
Rust
138 lines
4 KiB
Rust
//! Database tables.
|
|
//!
|
|
//! # Table marker structs
|
|
//! This module contains all the table definitions used by `cuprate_blockchain`.
|
|
//!
|
|
//! The zero-sized structs here represents the table type;
|
|
//! they all are essentially marker types that implement [`cuprate_database::Table`].
|
|
//!
|
|
//! Table structs are `CamelCase`, and their static string
|
|
//! names used by the actual database backend are `snake_case`.
|
|
//!
|
|
//! For example: [`BlockBlobs`] -> `block_blobs`.
|
|
//!
|
|
//! # Traits
|
|
//! This module also contains a set of traits for
|
|
//! accessing _all_ tables defined here at once.
|
|
|
|
//---------------------------------------------------------------------------------------------------- Import
|
|
use crate::types::{
|
|
Amount, AmountIndex, AmountIndices, BlockBlob, BlockHash, BlockHeight, BlockInfo, KeyImage,
|
|
Output, PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RctOutput, TxBlob, TxHash,
|
|
TxId, UnlockTime,
|
|
};
|
|
|
|
//---------------------------------------------------------------------------------------------------- Tables
|
|
// Notes:
|
|
// - Keep this sorted A-Z (by table name)
|
|
// - Tables are defined in plural to avoid name conflicts with types
|
|
// - If adding/changing a table also edit:
|
|
// - the tests in `src/backend/tests.rs`
|
|
cuprate_database::define_tables! {
|
|
/// Serialized block blobs (bytes).
|
|
///
|
|
/// Contains the serialized version of all blocks.
|
|
0 => BlockBlobs,
|
|
BlockHeight => BlockBlob,
|
|
|
|
/// Block heights.
|
|
///
|
|
/// Contains the height of all blocks.
|
|
1 => BlockHeights,
|
|
BlockHash => BlockHeight,
|
|
|
|
/// Block information.
|
|
///
|
|
/// Contains metadata of all blocks.
|
|
2 => BlockInfos,
|
|
BlockHeight => BlockInfo,
|
|
|
|
/// Set of key images.
|
|
///
|
|
/// Contains all the key images known to be spent.
|
|
///
|
|
/// This table has `()` as the value type, as in,
|
|
/// it is a set of key images.
|
|
3 => KeyImages,
|
|
KeyImage => (),
|
|
|
|
/// Maps an output's amount to the number of outputs with that amount.
|
|
///
|
|
/// For example, if there are 5 outputs with `amount = 123`
|
|
/// then calling `get(123)` on this table will return 5.
|
|
4 => NumOutputs,
|
|
Amount => u64,
|
|
|
|
/// Pre-RCT output data.
|
|
5 => Outputs,
|
|
PreRctOutputId => Output,
|
|
|
|
/// Pruned transaction blobs (bytes).
|
|
///
|
|
/// Contains the pruned portion of serialized transaction data.
|
|
6 => PrunedTxBlobs,
|
|
TxId => PrunedBlob,
|
|
|
|
/// Prunable transaction blobs (bytes).
|
|
///
|
|
/// Contains the prunable portion of serialized transaction data.
|
|
// SOMEDAY: impl when `monero-serai` supports pruning
|
|
7 => PrunableTxBlobs,
|
|
TxId => PrunableBlob,
|
|
|
|
/// Prunable transaction hashes.
|
|
///
|
|
/// Contains the prunable portion of transaction hashes.
|
|
// SOMEDAY: impl when `monero-serai` supports pruning
|
|
8 => PrunableHashes,
|
|
TxId => PrunableHash,
|
|
|
|
// SOMEDAY: impl a properties table:
|
|
// - db version
|
|
// - pruning seed
|
|
// Properties,
|
|
// StorableString => StorableVec,
|
|
|
|
/// RCT output data.
|
|
9 => RctOutputs,
|
|
AmountIndex => RctOutput,
|
|
|
|
/// Transaction blobs (bytes).
|
|
///
|
|
/// Contains the serialized version of all transactions.
|
|
// SOMEDAY: remove when `monero-serai` supports pruning
|
|
10 => TxBlobs,
|
|
TxId => TxBlob,
|
|
|
|
/// Transaction indices.
|
|
///
|
|
/// Contains the indices all transactions.
|
|
11 => TxIds,
|
|
TxHash => TxId,
|
|
|
|
/// Transaction heights.
|
|
///
|
|
/// Contains the block height associated with all transactions.
|
|
12 => TxHeights,
|
|
TxId => BlockHeight,
|
|
|
|
/// Transaction outputs.
|
|
///
|
|
/// Contains the list of `AmountIndex`'s of the
|
|
/// outputs associated with all transactions.
|
|
13 => TxOutputs,
|
|
TxId => AmountIndices,
|
|
|
|
/// Transaction unlock time.
|
|
///
|
|
/// Contains the unlock time of transactions IF they have one.
|
|
/// Transactions without unlock times will not exist in this table.
|
|
14 => TxUnlockTime,
|
|
TxId => UnlockTime,
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------- Tests
|
|
#[cfg(test)]
|
|
mod test {
|
|
// use super::*;
|
|
}
|