Add basic PoW chain db store
This commit is contained in:
parent
1065554216
commit
d4e6f12ded
@ -4,7 +4,10 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
mod block_store;
|
mod block_store;
|
||||||
|
mod pow_chain_store;
|
||||||
|
|
||||||
pub use self::block_store::BlockStore;
|
pub use self::block_store::BlockStore;
|
||||||
|
pub use self::pow_chain_store::PoWChainStore;
|
||||||
|
|
||||||
const BLOCKS_DB_COLUMN: &str = "blocks";
|
const BLOCKS_DB_COLUMN: &str = "blocks";
|
||||||
|
const POW_CHAIN_DB_COLUMN: &str = "powchain";
|
||||||
|
34
lighthouse/db/stores/pow_chain_store.rs
Normal file
34
lighthouse/db/stores/pow_chain_store.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
use super::{
|
||||||
|
ClientDB,
|
||||||
|
DBError,
|
||||||
|
};
|
||||||
|
use super::POW_CHAIN_DB_COLUMN as DB_COLUMN;
|
||||||
|
|
||||||
|
pub struct PoWChainStore<T>
|
||||||
|
where T: ClientDB
|
||||||
|
{
|
||||||
|
db: Arc<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: ClientDB> PoWChainStore<T> {
|
||||||
|
pub fn new(db: Arc<T>) -> Self {
|
||||||
|
Self {
|
||||||
|
db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn put_block_hash(&self, hash: &[u8])
|
||||||
|
-> Result<(), DBError>
|
||||||
|
{
|
||||||
|
self.db.put(DB_COLUMN, hash, &vec![0])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn block_hash_exists(&self, hash: &[u8])
|
||||||
|
-> Result<bool, DBError>
|
||||||
|
{
|
||||||
|
self.db.exists(DB_COLUMN, hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add tests once a memory-db is implemented
|
Loading…
Reference in New Issue
Block a user