casper_storage/block_store/
mod.rs

1mod block_provider;
2mod error;
3/// Block store lmdb logic.
4pub mod lmdb;
5/// Block store types.
6pub mod types;
7
8pub use block_provider::{BlockStoreProvider, BlockStoreTransaction, DataReader, DataWriter};
9pub use error::BlockStoreError;
10
11/// Stores raw bytes from the DB along with the flag indicating whether data come from legacy or
12/// current version of the DB.
13#[derive(Debug)]
14pub struct DbRawBytesSpec {
15    is_legacy: bool,
16    raw_bytes: Vec<u8>,
17}
18
19impl DbRawBytesSpec {
20    /// Creates a variant indicating that raw bytes are coming from the legacy database.
21    pub fn new_legacy(raw_bytes: &[u8]) -> Self {
22        Self {
23            is_legacy: true,
24            raw_bytes: raw_bytes.to_vec(),
25        }
26    }
27
28    /// Creates a variant indicating that raw bytes are coming from the current database.
29    pub fn new_current(raw_bytes: &[u8]) -> Self {
30        Self {
31            is_legacy: false,
32            raw_bytes: raw_bytes.to_vec(),
33        }
34    }
35
36    /// Is legacy?
37    pub fn is_legacy(&self) -> bool {
38        self.is_legacy
39    }
40
41    /// Raw bytes.
42    pub fn into_raw_bytes(self) -> Vec<u8> {
43        self.raw_bytes
44    }
45}