mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 03:51:22 +00:00
40cf650563
This is a massive commit which restructures the workspace, adds a very basic, untested, validator client and some very basic, non-functioning gRPC endpoints to the beacon-node.
29 lines
794 B
Rust
29 lines
794 B
Rust
pub type DBValue = Vec<u8>;
|
|
|
|
#[derive(Debug)]
|
|
pub struct DBError {
|
|
pub message: String,
|
|
}
|
|
|
|
impl DBError {
|
|
pub fn new(message: String) -> Self {
|
|
Self { message }
|
|
}
|
|
}
|
|
|
|
/// A generic database to be used by the "client' (i.e.,
|
|
/// the lighthouse blockchain client).
|
|
///
|
|
/// The purpose of having this generic trait is to allow the
|
|
/// program to use a persistent on-disk database during production,
|
|
/// but use a transient database during tests.
|
|
pub trait ClientDB: Sync + Send {
|
|
fn get(&self, col: &str, key: &[u8]) -> Result<Option<DBValue>, DBError>;
|
|
|
|
fn put(&self, col: &str, key: &[u8], val: &[u8]) -> Result<(), DBError>;
|
|
|
|
fn exists(&self, col: &str, key: &[u8]) -> Result<bool, DBError>;
|
|
|
|
fn delete(&self, col: &str, key: &[u8]) -> Result<(), DBError>;
|
|
}
|