2018-09-21 08:52:03 +00:00
|
|
|
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>
|
|
|
|
{
|
2018-09-22 05:53:31 +00:00
|
|
|
self.db.put(DB_COLUMN, hash, val)
|
2018-09-21 08:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_validator_record_by_index(&self, hash: &[u8])
|
|
|
|
-> Result<bool, DBError>
|
|
|
|
{
|
|
|
|
self.db.exists(DB_COLUMN, hash)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: add tests
|