Add ValidatorStore
This commit is contained in:
parent
8cbd4f47a0
commit
f0b432d81c
lighthouse/db/stores
@ -5,9 +5,11 @@ use super::{
|
||||
|
||||
mod block_store;
|
||||
mod pow_chain_store;
|
||||
mod validator_store;
|
||||
|
||||
pub use self::block_store::BlockStore;
|
||||
pub use self::pow_chain_store::PoWChainStore;
|
||||
|
||||
const BLOCKS_DB_COLUMN: &str = "blocks";
|
||||
const POW_CHAIN_DB_COLUMN: &str = "powchain";
|
||||
const VALIDATOR_DB_COLUMN: &str = "validator";
|
||||
|
34
lighthouse/db/stores/validator_store.rs
Normal file
34
lighthouse/db/stores/validator_store.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use std::sync::Arc;
|
||||
use super::{
|
||||
ClientDB,
|
||||
DBError,
|
||||
};
|
||||
use super::VALIDATOR_DB_COLUMN as DB_COLUMN;
|
||||
|
||||
pub struct ValidatorStore<T>
|
||||
where T: ClientDB
|
||||
{
|
||||
db: Arc<T>,
|
||||
}
|
||||
|
||||
impl<T: ClientDB> ValidatorStore<T> {
|
||||
pub fn new(db: Arc<T>) -> Self {
|
||||
Self {
|
||||
db,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn put_validator_record_by_index(&self, hash: &[u8], val: &[u8])
|
||||
-> Result<(), DBError>
|
||||
{
|
||||
self.db.put(DB_COLUMN, hash, &vec![0])
|
||||
}
|
||||
|
||||
pub fn get_validator_record_by_index(&self, hash: &[u8])
|
||||
-> Result<bool, DBError>
|
||||
{
|
||||
self.db.exists(DB_COLUMN, hash)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add tests
|
Loading…
Reference in New Issue
Block a user