|
| 1 | +//! Registrations table. |
| 2 | +//! Maps from block height -> registrations made for compressing that block |
| 3 | +
|
| 4 | +use fuel_core_storage::{ |
| 5 | + Mappable, |
| 6 | + blueprint::plain::Plain, |
| 7 | + codec::postcard::Postcard, |
| 8 | + merkle::sparse::MerkleizedTableColumn, |
| 9 | + structured_storage::TableWithBlueprint, |
| 10 | +}; |
| 11 | + |
| 12 | +use super::column::{ |
| 13 | + CompressionColumn, |
| 14 | + MerkleizedColumnOf, |
| 15 | +}; |
| 16 | + |
| 17 | +/// Table that indexes the registrations. |
| 18 | +pub struct Registrations; |
| 19 | + |
| 20 | +impl MerkleizedTableColumn for Registrations { |
| 21 | + type TableColumn = CompressionColumn; |
| 22 | + |
| 23 | + fn table_column() -> Self::TableColumn { |
| 24 | + Self::TableColumn::Registrations |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +impl Mappable for Registrations { |
| 29 | + type Key = Self::OwnedKey; |
| 30 | + type OwnedKey = fuel_core_types::fuel_types::BlockHeight; |
| 31 | + type Value = Self::OwnedValue; |
| 32 | + type OwnedValue = fuel_core_compression::registry::RegistrationsPerTable; |
| 33 | +} |
| 34 | + |
| 35 | +impl TableWithBlueprint for Registrations { |
| 36 | + type Blueprint = Plain<Postcard, Postcard>; |
| 37 | + type Column = MerkleizedColumnOf<Self>; |
| 38 | + |
| 39 | + fn column() -> Self::Column { |
| 40 | + Self::Column::TableColumn(Self::table_column()) |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +#[cfg(test)] |
| 45 | +mod tests { |
| 46 | + use super::*; |
| 47 | + |
| 48 | + fuel_core_storage::basic_storage_tests!( |
| 49 | + Registrations, |
| 50 | + <Registrations as Mappable>::Key::default(), |
| 51 | + <Registrations as Mappable>::Value::default(), |
| 52 | + <Registrations as Mappable>::Value::default() |
| 53 | + ); |
| 54 | +} |
0 commit comments