|
|
@@ -28,19 +28,29 @@ use crate::{tx::Transaction, util::time::Timestamp, Error, Result};
|
|
|
|
|
|
/// Block related definitions and storage implementations
|
|
|
pub mod block_store;
|
|
|
-pub use block_store::{Block, BlockDifficulty, BlockInfo, BlockStore, BlockStoreOverlay};
|
|
|
+pub use block_store::{
|
|
|
+ Block, BlockDifficulty, BlockInfo, BlockStore, BlockStoreOverlay, SLED_BLOCK_DIFFICULTY_TREE,
|
|
|
+ SLED_BLOCK_ORDER_TREE, SLED_BLOCK_TREE,
|
|
|
+};
|
|
|
|
|
|
/// Header definition and storage implementation
|
|
|
pub mod header_store;
|
|
|
-pub use header_store::{Header, HeaderHash, HeaderStore, HeaderStoreOverlay};
|
|
|
+pub use header_store::{
|
|
|
+ Header, HeaderHash, HeaderStore, HeaderStoreOverlay, SLED_HEADER_TREE, SLED_SYNC_HEADER_TREE,
|
|
|
+};
|
|
|
|
|
|
/// Transactions related storage implementations
|
|
|
pub mod tx_store;
|
|
|
-pub use tx_store::{TxStore, TxStoreOverlay};
|
|
|
+pub use tx_store::{
|
|
|
+ TxStore, TxStoreOverlay, SLED_PENDING_TX_ORDER_TREE, SLED_PENDING_TX_TREE,
|
|
|
+ SLED_TX_LOCATION_TREE, SLED_TX_TREE,
|
|
|
+};
|
|
|
|
|
|
/// Contracts and Wasm storage implementations
|
|
|
pub mod contract_store;
|
|
|
-pub use contract_store::{ContractStore, ContractStoreOverlay};
|
|
|
+pub use contract_store::{
|
|
|
+ ContractStore, ContractStoreOverlay, SLED_BINCODE_TREE, SLED_CONTRACTS_TREE,
|
|
|
+};
|
|
|
|
|
|
/// Structure holding all sled trees that define the concept of Blockchain.
|
|
|
#[derive(Clone)]
|
|
|
@@ -348,7 +358,24 @@ pub struct BlockchainOverlay {
|
|
|
impl BlockchainOverlay {
|
|
|
/// Instantiate a new `BlockchainOverlay` over the given [`Blockchain`] instance.
|
|
|
pub fn new(blockchain: &Blockchain) -> Result<BlockchainOverlayPtr> {
|
|
|
- let overlay = Arc::new(Mutex::new(sled_overlay::SledDbOverlay::new(&blockchain.sled_db)));
|
|
|
+ // Here we configure all our blockchain sled trees to be protected in the overlay
|
|
|
+ let protected_trees = vec![
|
|
|
+ SLED_BLOCK_TREE,
|
|
|
+ SLED_BLOCK_ORDER_TREE,
|
|
|
+ SLED_BLOCK_DIFFICULTY_TREE,
|
|
|
+ SLED_HEADER_TREE,
|
|
|
+ SLED_SYNC_HEADER_TREE,
|
|
|
+ SLED_TX_TREE,
|
|
|
+ SLED_TX_LOCATION_TREE,
|
|
|
+ SLED_PENDING_TX_TREE,
|
|
|
+ SLED_PENDING_TX_ORDER_TREE,
|
|
|
+ SLED_CONTRACTS_TREE,
|
|
|
+ SLED_BINCODE_TREE,
|
|
|
+ ];
|
|
|
+ let overlay = Arc::new(Mutex::new(sled_overlay::SledDbOverlay::new(
|
|
|
+ &blockchain.sled_db,
|
|
|
+ protected_trees,
|
|
|
+ )));
|
|
|
let headers = HeaderStoreOverlay::new(&overlay)?;
|
|
|
let blocks = BlockStoreOverlay::new(&overlay)?;
|
|
|
let transactions = TxStoreOverlay::new(&overlay)?;
|