diff --git a/lib/modules/blockchain/bc-db-writer/src/blocks.rs b/lib/modules/blockchain/bc-db-writer/src/blocks.rs index 7757e50c91618393bb5e5edc04f90507894e2543..187c62e41086ad5bc2b2e7170b9f5fc389ba724d 100644 --- a/lib/modules/blockchain/bc-db-writer/src/blocks.rs +++ b/lib/modules/blockchain/bc-db-writer/src/blocks.rs @@ -50,7 +50,7 @@ pub fn insert_new_head_block( crate::current_meta_datas::update_current_meta_datas(db, w, &dal_block.block)?; // Update stores linked to MAIN_BLOCKS - crate::store_name::update_store_name(db, w, &dal_block.block)?; + crate::current_frame::update_current_frame(db, w, &dal_block.block)?; if let Some(fork_tree) = fork_tree { // Insert head block in fork tree diff --git a/lib/modules/blockchain/bc-db-writer/src/current_frame.rs b/lib/modules/blockchain/bc-db-writer/src/current_frame.rs index 60c59719ea7bcb312942159523933fc2f0d68341..28b6a5bf20b89d3564e8826c848f2fea38c15307 100644 --- a/lib/modules/blockchain/bc-db-writer/src/current_frame.rs +++ b/lib/modules/blockchain/bc-db-writer/src/current_frame.rs @@ -24,6 +24,43 @@ use durs_bc_db_reader::constants::*; use durs_bc_db_reader::current_meta_datas::get_current_blockstamp_; use durs_bc_db_reader::current_meta_datas::CurrentMetaDataKey; use durs_bc_db_reader::{DbValue,DbReader}; +use dubp_block_doc::BlockDocument; + +// TODO: revert_current_frame +pub(crate) fn update_current_frame( + _db: &Db, + _w: &mut DbWriter, + _new_current_block: &BlockDocument, +) -> Result<(), DbError> { + unimplemented!(); + //Ok(()) + // 1. dans CURRENT_FRAME_MEMBERS + // pour le WotId du nouveau bloc + // last_block = CurrentBlockNumber + // block_count++ OR 1 si nouvelle clef + // pour les WotId des 0 à 2 blocs sortant (à récupérer via une queue) + // block_count-- Si 0 supprimer la clef + // 2. créer SortedFrameMemberTable : Vec<(bloc_count : u32, WotId)> + // en extraire la valeur médiane MedianFrameMember + // 3. dans CURRENT_META_DATAS + // CurrentFrameMembersSize += diff clef WotId ajoutée/supprimée + // MedianFrameMember = MedianFrameMember + // CurrentFrameFIFO + +} +// fn update_current_frame_fifo +// fn push_in_current_frame_fifo +// update_current_frame_members <- add WotId +// fn pop_in_current_frame_fifo +// 0-2 update_current_frame_members <- rm WotId +// (fn update_current_frame_members) +// fn write_current_frame_fifo_in_store + +// fn update_median_forged_blocks_in_current_frame +// fn get_current_frame durs-bc-db-reader (mais comment on l'initialise au lancement ?) +// chercher rust compute median (en ligne) si pas d'algo sans tri : fn sort_current_frame_members_by_forged_blocks (en itérant/transformant la structure précédente) +// fn compute_median_forged_blocks_in_current_frame (à partir du tableau trié) +// fn update_current_frame_meta_data (sauf fifo) /// Compute the personal difficulty of a member. diff --git a/lib/modules/blockchain/bc-db-writer/src/lib.rs b/lib/modules/blockchain/bc-db-writer/src/lib.rs index 413de1c4457d4fdc81e7f44ea616fab7e2859335..361acabcf8d3e90608d7b1904fcafccfdd09c72b 100644 --- a/lib/modules/blockchain/bc-db-writer/src/lib.rs +++ b/lib/modules/blockchain/bc-db-writer/src/lib.rs @@ -34,7 +34,6 @@ pub mod blocks; pub mod current_frame; pub mod current_meta_datas; pub mod indexes; -pub mod store_name; pub mod writers; pub use durs_dbs_tools::kv_db::{ diff --git a/lib/modules/blockchain/bc-db-writer/src/store_name.rs b/lib/modules/blockchain/bc-db-writer/src/store_name.rs deleted file mode 100644 index dee6273e17f5dfe9e3b9bfe80d974fcb3138536b..0000000000000000000000000000000000000000 --- a/lib/modules/blockchain/bc-db-writer/src/store_name.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2017-2019 The AXIOM TEAM Association. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// 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/>. - -//! "store name" storage: define write requests. - -use crate::{Db, DbWriter}; -use dubp_block_doc::BlockDocument; -use durs_dbs_tools::DbError; - -pub(crate) fn update_store_name( - _db: &Db, - _w: &mut DbWriter, - _new_current_block: &BlockDocument, -) -> Result<(), DbError> { - //unimplemented!() - Ok(()) -}