lighthouse-pulse/lighthouse/db/stores/validator_store.rs
2018-09-21 18:52:03 +10:00

35 lines
636 B
Rust

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