From 460e66e8094ed74df463ad220b8c9df5af6b567e Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Sun, 8 Sep 2019 21:08:07 +0200 Subject: [PATCH] [ref] bc-db-writer: rearrangement by storage type (blocks, indexes) --- .../bc-db-reader/src/blocks/fork_tree.rs | 2 +- lib/modules-lib/bc-db-reader/src/indexes.rs | 2 +- .../src/{writers/block.rs => blocks.rs} | 12 +++-- .../src/{writers => blocks}/fork_tree.rs | 16 ++----- .../src/{constants.rs => indexes.rs} | 8 +++- .../certification.rs => indexes/certs.rs} | 2 + .../dividend.rs => indexes/dividends.rs} | 2 + .../identity.rs => indexes/identities.rs} | 2 + .../transactions.rs} | 4 +- .../blockchain/bc-db-writer/src/lib.rs | 8 ++-- .../bc-db-writer/src/writers/mod.rs | 20 +------- .../bc-db-writer/src/writers/requests.rs | 48 +++++++++++-------- .../blockchain/blockchain/src/dubp/mod.rs | 8 +--- .../blockchain/src/dunp/receiver.rs | 4 +- .../blockchain/src/fork/fork_algo.rs | 6 +-- .../blockchain/src/fork/revert_block.rs | 2 +- .../blockchain/src/fork/rollback.rs | 6 +-- .../blockchain/src/fork/stackable_blocks.rs | 4 +- .../src/sync/apply/blocks_worker.rs | 2 +- 19 files changed, 76 insertions(+), 82 deletions(-) rename lib/modules/blockchain/bc-db-writer/src/{writers/block.rs => blocks.rs} (95%) rename lib/modules/blockchain/bc-db-writer/src/{writers => blocks}/fork_tree.rs (93%) rename lib/modules/blockchain/bc-db-writer/src/{constants.rs => indexes.rs} (85%) rename lib/modules/blockchain/bc-db-writer/src/{writers/certification.rs => indexes/certs.rs} (98%) rename lib/modules/blockchain/bc-db-writer/src/{writers/dividend.rs => indexes/dividends.rs} (98%) rename lib/modules/blockchain/bc-db-writer/src/{writers/identity.rs => indexes/identities.rs} (99%) rename lib/modules/blockchain/bc-db-writer/src/{writers/transaction.rs => indexes/transactions.rs} (99%) diff --git a/lib/modules-lib/bc-db-reader/src/blocks/fork_tree.rs b/lib/modules-lib/bc-db-reader/src/blocks/fork_tree.rs index 3764e3c9..1d5390ae 100644 --- a/lib/modules-lib/bc-db-reader/src/blocks/fork_tree.rs +++ b/lib/modules-lib/bc-db-reader/src/blocks/fork_tree.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -//! Describe fork tree +//! Blocks fork tree: define entity and read requests. use dubp_common_doc::{BlockHash, BlockNumber, Blockstamp}; use log::error; diff --git a/lib/modules-lib/bc-db-reader/src/indexes.rs b/lib/modules-lib/bc-db-reader/src/indexes.rs index c90f4598..5dcfd4bd 100644 --- a/lib/modules-lib/bc-db-reader/src/indexes.rs +++ b/lib/modules-lib/bc-db-reader/src/indexes.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -//! Blockchain stored indexes. +//! Blockchain stored indexes: definition and read requests. pub mod balance; pub mod certs; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/block.rs b/lib/modules/blockchain/bc-db-writer/src/blocks.rs similarity index 95% rename from lib/modules/blockchain/bc-db-writer/src/writers/block.rs rename to lib/modules/blockchain/bc-db-writer/src/blocks.rs index 8b758502..621deb58 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/block.rs +++ b/lib/modules/blockchain/bc-db-writer/src/blocks.rs @@ -13,6 +13,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Blocks storage: defien write requests. + +pub mod fork_tree; + use crate::DbError; use crate::*; use dubp_block_doc::block::BlockDocumentTrait; @@ -62,10 +66,8 @@ pub fn insert_new_head_block( if let Some(fork_tree) = fork_tree { // Insert head block in fork tree - let removed_blockstamps = crate::writers::fork_tree::insert_new_head_block( - fork_tree, - dal_block.blockstamp(), - )?; + let removed_blockstamps = + crate::blocks::fork_tree::insert_new_head_block(fork_tree, dal_block.blockstamp())?; // Insert head block in ForkBlocks let blockstamp_bytes: Vec<u8> = dal_block.blockstamp().into(); fork_blocks_store.put( @@ -101,7 +103,7 @@ pub fn insert_new_fork_block( ) -> Result<bool, DbError> { let bin_dal_block = durs_dbs_tools::to_bytes(&dal_block)?; let blockstamp_bytes: Vec<u8> = dal_block.blockstamp().into(); - if crate::writers::fork_tree::insert_new_fork_block( + if fork_tree::insert_new_fork_block( fork_tree, dal_block.block.blockstamp(), unwrap!(dal_block.block.previous_hash()), diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/fork_tree.rs b/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs similarity index 93% rename from lib/modules/blockchain/bc-db-writer/src/writers/fork_tree.rs rename to lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs index d7904b64..9835fdfb 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/fork_tree.rs +++ b/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Blocks fork tree: define write requests. + use crate::*; use dubp_common_doc::BlockHash; use durs_bc_db_reader::blocks::fork_tree::ForkTree; @@ -252,17 +254,9 @@ mod test { // Check tree state assert_eq!(*DEFAULT_FORK_WINDOW_SIZE, fork_tree.size()); assert_eq!( - <<<<<<< dev:lib/modules/blockchain/blockchain-dal/src/writers/fork_tree.rs - vec![(TreeNodeId(1), blockstamps[*DEFAULT_FORK_WINDOW_SIZE + 2])], - fork_tree_db.read(|tree| tree.get_sheets())? - ======= - vec![( - TreeNodeId(*DEFAULT_FORK_WINDOW_SIZE + 4), - blockstamps[*DEFAULT_FORK_WINDOW_SIZE + 2] - )], - fork_tree.get_sheets() - >>>>>>> [ref] blockchain: migrate forks & identities in LMDB:lib/modules/blockchain/bc-db-writer/src/writers/fork_tree.rs - ); + vec![(TreeNodeId(1), blockstamps[*DEFAULT_FORK_WINDOW_SIZE + 2])], + fork_tree.get_sheets() + ); Ok(()) } diff --git a/lib/modules/blockchain/bc-db-writer/src/constants.rs b/lib/modules/blockchain/bc-db-writer/src/indexes.rs similarity index 85% rename from lib/modules/blockchain/bc-db-writer/src/constants.rs rename to lib/modules/blockchain/bc-db-writer/src/indexes.rs index 1e7fe021..75410379 100644 --- a/lib/modules/blockchain/bc-db-writer/src/constants.rs +++ b/lib/modules/blockchain/bc-db-writer/src/indexes.rs @@ -13,5 +13,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -/// Currency parameters DB name -pub const CURRENCY_PARAMS_DB_NAME: &str = "params.db"; +//! Blockchain stored indexes: write requests. + +pub mod certs; +pub mod dividends; +pub mod identities; +pub mod transactions; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/certification.rs b/lib/modules/blockchain/bc-db-writer/src/indexes/certs.rs similarity index 98% rename from lib/modules/blockchain/bc-db-writer/src/writers/certification.rs rename to lib/modules/blockchain/bc-db-writer/src/indexes/certs.rs index 62f3ce32..c5648758 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/certification.rs +++ b/lib/modules/blockchain/bc-db-writer/src/indexes/certs.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Certifications stored indexes: write requests. + use crate::{BinFreeStructDb, Db, DbError}; use dubp_common_doc::BlockNumber; use dubp_currency_params::CurrencyParameters; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/dividend.rs b/lib/modules/blockchain/bc-db-writer/src/indexes/dividends.rs similarity index 98% rename from lib/modules/blockchain/bc-db-writer/src/writers/dividend.rs rename to lib/modules/blockchain/bc-db-writer/src/indexes/dividends.rs index 738fc7fe..7a2a819d 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/dividend.rs +++ b/lib/modules/blockchain/bc-db-writer/src/indexes/dividends.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Universal dividends stored indexes: write requests. + use crate::*; use dubp_common_doc::BlockNumber; use dubp_user_docs::documents::transaction::*; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/identity.rs b/lib/modules/blockchain/bc-db-writer/src/indexes/identities.rs similarity index 99% rename from lib/modules/blockchain/bc-db-writer/src/writers/identity.rs rename to lib/modules/blockchain/bc-db-writer/src/indexes/identities.rs index 85a0b6c4..eaa5ff5e 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/identity.rs +++ b/lib/modules/blockchain/bc-db-writer/src/indexes/identities.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Identities stored indexes: write requests. + use crate::{BinFreeStructDb, Db, DbError, MsExpirV10Datas}; use dubp_common_doc::traits::Document; use dubp_common_doc::{BlockNumber, Blockstamp}; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/transaction.rs b/lib/modules/blockchain/bc-db-writer/src/indexes/transactions.rs similarity index 99% rename from lib/modules/blockchain/bc-db-writer/src/writers/transaction.rs rename to lib/modules/blockchain/bc-db-writer/src/indexes/transactions.rs index d704c085..c6fdeb76 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/transaction.rs +++ b/lib/modules/blockchain/bc-db-writer/src/indexes/transactions.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +//! Transactions stored indexes: write requests. + use dubp_user_docs::documents::transaction::*; use durs_common_tools::fatal_error; @@ -495,7 +497,7 @@ mod tests { // Open currencys_db in memory mode let currency_dbs = CurrencyV10DBs::open(None); // Create first g1 UD for cgeek and tortue - writers::dividend::create_du( + crate::indexes::dividends::create_du( ¤cy_dbs.du_db, ¤cy_dbs.balances_db, &SourceAmount(TxAmount(1000), TxBase(0)), diff --git a/lib/modules/blockchain/bc-db-writer/src/lib.rs b/lib/modules/blockchain/bc-db-writer/src/lib.rs index ff9b7352..ac012016 100644 --- a/lib/modules/blockchain/bc-db-writer/src/lib.rs +++ b/lib/modules/blockchain/bc-db-writer/src/lib.rs @@ -32,10 +32,8 @@ extern crate log; #[macro_use] extern crate serde_derive; -/// Define crate constants -pub mod constants; - -/// Contains all write databases functions +pub mod blocks; +pub mod indexes; pub mod writers; pub use durs_dbs_tools::kv_db::{ @@ -47,7 +45,7 @@ pub use durs_dbs_tools::{ }; pub use durs_dbs_tools::{BinFreeStructDb, DbError}; -use crate::writers::transaction::DbTxV10; +use crate::indexes::transactions::DbTxV10; use dubp_common_doc::{BlockNumber, Blockstamp}; use dubp_indexes::sindex::UniqueIdUTXOv10; use dubp_user_docs::documents::transaction::*; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/mod.rs b/lib/modules/blockchain/bc-db-writer/src/writers/mod.rs index 7c96d4d4..86e98a4a 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/mod.rs +++ b/lib/modules/blockchain/bc-db-writer/src/writers/mod.rs @@ -13,23 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -/// Block writer functions -pub mod block; +//! DELETION IN PROGRESS -/// Certification apply functions -pub mod certification; - -/// Dividend apply functions -pub mod dividend; - -/// Fork tree writer functions -pub mod fork_tree; - -/// Identities writer functions -pub mod identity; - -/// Databases write requests +/// DELETION IN PROGRESS pub mod requests; - -/// Transaction apply functions -pub mod transaction; diff --git a/lib/modules/blockchain/bc-db-writer/src/writers/requests.rs b/lib/modules/blockchain/bc-db-writer/src/writers/requests.rs index 2f3ee12c..1ee88957 100644 --- a/lib/modules/blockchain/bc-db-writer/src/writers/requests.rs +++ b/lib/modules/blockchain/bc-db-writer/src/writers/requests.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use crate::writers::transaction::DbTxV10; +use crate::indexes::transactions::DbTxV10; use crate::*; use dubp_block_doc::block::{BlockDocument, BlockDocumentTrait}; use dubp_common_doc::Blockstamp; @@ -71,14 +71,14 @@ impl BlocksDBsWriteQuery { || dal_block.blockstamp().id.0 + fork_window_size as u32 >= sync_target.expect("safe unwrap").id.0 { - super::block::insert_new_head_block(db, Some(fork_tree), dal_block)?; + crate::blocks::insert_new_head_block(db, Some(fork_tree), dal_block)?; } else { - super::block::insert_new_head_block(db, None, dal_block)?; + crate::blocks::insert_new_head_block(db, None, dal_block)?; } } BlocksDBsWriteQuery::RevertBlock(dal_block) => { trace!("BlocksDBsWriteQuery::WriteBlock..."); - super::block::remove_block(db, dal_block.block.number())?; + crate::blocks::remove_block(db, dal_block.block.number())?; trace!("BlocksDBsWriteQuery::WriteBlock...finish"); } } @@ -138,7 +138,7 @@ impl WotsDBsWriteQuery { ref idty_doc, ref ms_created_block_id, ) => { - writers::identity::create_identity( + crate::indexes::identities::create_identity( currency_params, &db, &databases.ms_db, @@ -150,7 +150,7 @@ impl WotsDBsWriteQuery { )?; } WotsDBsWriteQuery::RevertCreateIdentity(ref pubkey) => { - writers::identity::revert_create_identity(&db, &databases.ms_db, pubkey)?; + crate::indexes::identities::revert_create_identity(&db, &databases.ms_db, pubkey)?; } WotsDBsWriteQuery::RenewalIdentity( ref pubkey, @@ -159,7 +159,7 @@ impl WotsDBsWriteQuery { ms_created_block_id, ) => { trace!("WotsDBsWriteQuery::RenewalIdentity..."); - writers::identity::renewal_identity( + crate::indexes::identities::renewal_identity( currency_params, &db, &databases.ms_db, @@ -177,7 +177,7 @@ impl WotsDBsWriteQuery { ref current_bc_time, ms_created_block_id, ) => { - writers::identity::renewal_identity( + crate::indexes::identities::renewal_identity( currency_params, &db, &databases.ms_db, @@ -189,16 +189,20 @@ impl WotsDBsWriteQuery { )?; } WotsDBsWriteQuery::ExcludeIdentity(ref pubkey, ref blockstamp) => { - writers::identity::exclude_identity(&db, pubkey, blockstamp, false)?; + crate::indexes::identities::exclude_identity(&db, pubkey, blockstamp, false)?; } WotsDBsWriteQuery::RevertExcludeIdentity(ref pubkey, ref blockstamp) => { - writers::identity::exclude_identity(&db, pubkey, blockstamp, true)?; + crate::indexes::identities::exclude_identity(&db, pubkey, blockstamp, true)?; } WotsDBsWriteQuery::RevokeIdentity(ref pubkey, ref blockstamp, ref explicit) => { - writers::identity::revoke_identity(&db, pubkey, blockstamp, *explicit, false)?; + crate::indexes::identities::revoke_identity( + &db, pubkey, blockstamp, *explicit, false, + )?; } WotsDBsWriteQuery::RevertRevokeIdentity(ref pubkey, ref blockstamp, ref explicit) => { - writers::identity::revoke_identity(&db, pubkey, blockstamp, *explicit, true)?; + crate::indexes::identities::revoke_identity( + &db, pubkey, blockstamp, *explicit, true, + )?; } WotsDBsWriteQuery::CreateCert( ref source_pubkey, @@ -208,7 +212,7 @@ impl WotsDBsWriteQuery { ref median_time, ) => { trace!("WotsDBsWriteQuery::CreateCert..."); - writers::certification::write_certification( + crate::indexes::certs::write_certification( currency_params, &db, &databases.certs_db, @@ -222,7 +226,7 @@ impl WotsDBsWriteQuery { } WotsDBsWriteQuery::RevertCert(ref compact_doc, ref source, ref target) => { trace!("WotsDBsWriteQuery::CreateCert..."); - writers::certification::revert_write_cert( + crate::indexes::certs::revert_write_cert( &db, &databases.certs_db, *compact_doc, @@ -232,10 +236,10 @@ impl WotsDBsWriteQuery { trace!("WotsDBsWriteQuery::CreateCert...finish"); } WotsDBsWriteQuery::ExpireCerts(ref created_block_id) => { - super::certification::expire_certs(&databases.certs_db, *created_block_id)?; + crate::indexes::certs::expire_certs(&databases.certs_db, *created_block_id)?; } WotsDBsWriteQuery::RevertExpireCert(ref source, ref target, ref created_block_id) => { - super::certification::revert_expire_cert( + crate::indexes::certs::revert_expire_cert( &databases.certs_db, *source, *target, @@ -269,13 +273,17 @@ impl CurrencyDBsWriteQuery { ) -> Result<(), DbError> { match *self { CurrencyDBsWriteQuery::WriteTx(ref tx_doc) => { - super::transaction::apply_and_write_tx(blockstamp, &databases, tx_doc.deref())?; + crate::indexes::transactions::apply_and_write_tx( + blockstamp, + &databases, + tx_doc.deref(), + )?; } CurrencyDBsWriteQuery::RevertTx(ref dal_tx) => { - super::transaction::revert_tx(blockstamp, &databases, dal_tx.deref())?; + crate::indexes::transactions::revert_tx(blockstamp, &databases, dal_tx.deref())?; } CurrencyDBsWriteQuery::CreateUD(ref du_amount, ref block_id, ref members) => { - super::dividend::create_du( + crate::indexes::dividends::create_du( &databases.du_db, &databases.balances_db, du_amount, @@ -285,7 +293,7 @@ impl CurrencyDBsWriteQuery { )?; } CurrencyDBsWriteQuery::RevertUD(ref du_amount, ref block_id, ref members) => { - super::dividend::create_du( + crate::indexes::dividends::create_du( &databases.du_db, &databases.balances_db, du_amount, diff --git a/lib/modules/blockchain/blockchain/src/dubp/mod.rs b/lib/modules/blockchain/blockchain/src/dubp/mod.rs index f155897a..13c3b485 100644 --- a/lib/modules/blockchain/blockchain/src/dubp/mod.rs +++ b/lib/modules/blockchain/blockchain/src/dubp/mod.rs @@ -138,12 +138,8 @@ pub fn check_and_apply_block( expire_certs: None, }; - if durs_bc_db_writer::writers::block::insert_new_fork_block( - &bc.db, - &mut bc.fork_tree, - dal_block, - ) - .expect("durs_bc_db_writer::writers::block::insert_new_fork_block() : DbError") + if durs_bc_db_writer::blocks::insert_new_fork_block(&bc.db, &mut bc.fork_tree, dal_block) + .expect("durs_bc_db_writer::writers::block::insert_new_fork_block() : DbError") { Ok(CheckAndApplyBlockReturn::ForkBlock) } else { diff --git a/lib/modules/blockchain/blockchain/src/dunp/receiver.rs b/lib/modules/blockchain/blockchain/src/dunp/receiver.rs index 5d15e943..0bba3941 100644 --- a/lib/modules/blockchain/blockchain/src/dunp/receiver.rs +++ b/lib/modules/blockchain/blockchain/src/dunp/receiver.rs @@ -131,11 +131,11 @@ pub fn receive_blocks(bc: &mut BlockchainModule, blocks: Vec<BlockDocument>) { } // Save databases if save_blocks_dbs { + durs_bc_db_writer::blocks::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) + .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); bc.db .save() .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); - durs_bc_db_writer::writers::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) - .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); } if save_wots_dbs { bc.wot_databases.save_dbs(); diff --git a/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs b/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs index 9a840704..0ab1c839 100644 --- a/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs +++ b/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs @@ -119,7 +119,7 @@ mod tests { // Insert mock blocks in forks_dbs for block in &main_branch { - durs_bc_db_writer::writers::block::insert_new_head_block( + durs_bc_db_writer::blocks::insert_new_head_block( &db, Some(&mut fork_tree), DbBlock { @@ -186,7 +186,7 @@ mod tests { }; assert_eq!( true, - durs_bc_db_writer::writers::block::insert_new_fork_block( + durs_bc_db_writer::blocks::insert_new_fork_block( &db, &mut fork_tree, DbBlock { @@ -265,7 +265,7 @@ mod tests { for block in blocks { assert_eq!( true, - durs_bc_db_writer::writers::block::insert_new_fork_block( + durs_bc_db_writer::blocks::insert_new_fork_block( db, fork_tree, DbBlock { diff --git a/lib/modules/blockchain/blockchain/src/fork/revert_block.rs b/lib/modules/blockchain/blockchain/src/fork/revert_block.rs index ba6be566..9f9002cc 100644 --- a/lib/modules/blockchain/blockchain/src/fork/revert_block.rs +++ b/lib/modules/blockchain/blockchain/src/fork/revert_block.rs @@ -23,8 +23,8 @@ use dubp_user_docs::documents::transaction::{TxAmount, TxBase}; use dup_crypto::keys::*; use durs_bc_db_reader::blocks::DbBlock; use durs_bc_db_reader::indexes::sources::SourceAmount; +use durs_bc_db_writer::indexes::transactions::DbTxV10; use durs_bc_db_writer::writers::requests::*; -use durs_bc_db_writer::writers::transaction::DbTxV10; use durs_bc_db_writer::{BinFreeStructDb, DbError, TxV10Datas}; use durs_common_tools::fatal_error; use durs_wot::data::{NewLinkResult, RemLinkResult}; diff --git a/lib/modules/blockchain/blockchain/src/fork/rollback.rs b/lib/modules/blockchain/blockchain/src/fork/rollback.rs index 14deab21..e1614e8b 100644 --- a/lib/modules/blockchain/blockchain/src/fork/rollback.rs +++ b/lib/modules/blockchain/blockchain/src/fork/rollback.rs @@ -138,7 +138,7 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>) if new_branch_is_valid { // update main branch in fork tree - if let Err(err) = durs_bc_db_writer::writers::fork_tree::change_main_branch( + if let Err(err) = durs_bc_db_writer::blocks::fork_tree::change_main_branch( &bc.db, &mut bc.fork_tree, old_current_blockstamp, @@ -148,11 +148,11 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>) } // save dbs + durs_bc_db_writer::blocks::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) + .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); bc.db .save() .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); - durs_bc_db_writer::writers::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) - .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); bc.wot_databases.save_dbs(); bc.currency_databases.save_dbs(true, true); // Send events stackUpValidBlock diff --git a/lib/modules/blockchain/blockchain/src/fork/stackable_blocks.rs b/lib/modules/blockchain/blockchain/src/fork/stackable_blocks.rs index 1247e0b3..2e2ee31b 100644 --- a/lib/modules/blockchain/blockchain/src/fork/stackable_blocks.rs +++ b/lib/modules/blockchain/blockchain/src/fork/stackable_blocks.rs @@ -86,11 +86,11 @@ pub fn apply_stackable_blocks(bc: &mut BlockchainModule) { } } // Save databases + durs_bc_db_writer::blocks::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) + .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); bc.db .save() .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); - durs_bc_db_writer::writers::fork_tree::save_fork_tree(&bc.db, &bc.fork_tree) - .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); bc.wot_databases.save_dbs(); bc.currency_databases.save_dbs(true, true); break 'blockchain; diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs index e70a5162..9b94c146 100644 --- a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs +++ b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs @@ -84,7 +84,7 @@ pub fn execute( println!(); println!("Write indexs in files..."); info!("Save blockchain and forks databases in files..."); - durs_bc_db_writer::writers::fork_tree::save_fork_tree(&db, &fork_tree) + durs_bc_db_writer::blocks::fork_tree::save_fork_tree(&db, &fork_tree) .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); db.save() .unwrap_or_else(|_| fatal_error!("DB corrupted, please reset data.")); -- GitLab