forked from ReamLabs/ream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatest_justified.rs
More file actions
33 lines (25 loc) · 974 Bytes
/
Copy pathlatest_justified.rs
File metadata and controls
33 lines (25 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::sync::Arc;
use ream_consensus_lean::checkpoint::Checkpoint;
use redb::{Database, TableDefinition};
use crate::tables::{field::REDBField, ssz_encoder::SSZEncoding};
pub struct LatestJustifiedField {
pub db: Arc<Database>,
}
/// Table definition for the Latest Justified table
///
/// Value: [Checkpoint]
///
/// NOTE: This table enables O(1) access to the latest justified checkpoint, deviates from
/// the original spec which derives it from state dictionary each time it is needed.
///
/// Highest-slot justified checkpoint observed so far; the head walk starts here.
impl REDBField for LatestJustifiedField {
const FIELD_DEFINITION: TableDefinition<'_, &str, SSZEncoding<Checkpoint>> =
TableDefinition::new("lean_latest_justified");
const KEY: &str = "latest_justified_key";
type Value = Checkpoint;
type ValueFieldDefinition = SSZEncoding<Checkpoint>;
fn database(&self) -> Arc<Database> {
self.db.clone()
}
}