chore: add DUPSORT trait const (#12477)

This commit is contained in:
Matthias Seitz
2024-11-12 18:19:06 +01:00
committed by GitHub
parent e6a6fc4c2e
commit 4a8eb7a0c0
3 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,9 @@ pub trait Table: Send + Sync + Debug + 'static {
/// The table's name.
const NAME: &'static str;
/// Whether the table is also a `DUPSORT` table.
const DUPSORT: bool;
/// Key element of `Table`.
///
/// Sorting should be taken into account when encoding this.

View File

@ -140,6 +140,7 @@ macro_rules! tables {
$value: reth_db_api::table::Value + 'static
{
const NAME: &'static str = table_names::$name;
const DUPSORT: bool = tables!(@bool $($subkey)?);
type Key = $key;
type Value = $value;

View File

@ -14,6 +14,7 @@ pub struct RawTable<T: Table> {
impl<T: Table> Table for RawTable<T> {
const NAME: &'static str = T::NAME;
const DUPSORT: bool = false;
type Key = RawKey<T::Key>;
type Value = RawValue<T::Value>;
@ -28,6 +29,7 @@ pub struct RawDupSort<T: DupSort> {
impl<T: DupSort> Table for RawDupSort<T> {
const NAME: &'static str = T::NAME;
const DUPSORT: bool = true;
type Key = RawKey<T::Key>;
type Value = RawValue<T::Value>;