diff --git a/Cargo.lock b/Cargo.lock index eedfb2d1698ebd073d76b70725c5896c96f3065c..87cbd1b2ba97eb1a403c51196eb7a0e4593f6b89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "ansi_term" version = "0.11.0" diff --git a/lib/modules/blockchain/blockchain-dal/src/readers/block.rs b/lib/modules/blockchain/blockchain-dal/src/readers/block.rs index 8904dda156bc27bc2d193ff1fda836ad4f77c302..7dd0a84c9d793bad238288768fc9c38d78201352 100644 --- a/lib/modules/blockchain/blockchain-dal/src/readers/block.rs +++ b/lib/modules/blockchain/blockchain-dal/src/readers/block.rs @@ -67,7 +67,7 @@ pub fn already_have_block( } else if let Some(orphan_blockstamps) = forks_dbs.orphan_blocks_db.read(|db| { if let Some(orphan_blocks) = db.get(&previous_blockstamp) { let orphan_blockstamps: Vec<Blockstamp> = - orphan_blocks.iter().map(|b| b.blockstamp()).collect(); + orphan_blocks.iter().map(DALBlock::blockstamp).collect(); Some(orphan_blockstamps) } else { None diff --git a/lib/modules/blockchain/blockchain-dal/src/writers/fork_tree.rs b/lib/modules/blockchain/blockchain-dal/src/writers/fork_tree.rs index 8981bf20e94249713db61ce47ce6ca85a5696610..b4bd8d6df2ea1593d962ce8c5bf94976acc14d0b 100644 --- a/lib/modules/blockchain/blockchain-dal/src/writers/fork_tree.rs +++ b/lib/modules/blockchain/blockchain-dal/src/writers/fork_tree.rs @@ -13,6 +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::entities::fork_tree::ForkTree; use crate::*; use dubp_documents::*; @@ -32,7 +33,7 @@ pub fn insert_new_head_block( fork_tree.insert_new_node(blockstamp, parent_id_opt, true); })?; - Ok(fork_tree_db.read(|tree| tree.get_removed_blockstamps())?) + Ok(fork_tree_db.read(ForkTree::get_removed_blockstamps)?) } /// Insert new fork block in fork tree only if parent exist in fork tree (orphan block not inserted) @@ -72,7 +73,7 @@ pub fn change_main_branch( let removed_blockstamps = forks_dbs .fork_tree_db - .read(|tree| tree.get_removed_blockstamps())?; + .read(ForkTree::get_removed_blockstamps)?; // Remove too old blocks forks_dbs.fork_blocks_db.write(|db| { diff --git a/lib/modules/blockchain/blockchain/src/dbex.rs b/lib/modules/blockchain/blockchain/src/dbex.rs index 3102021931bc6f6319b4b5d91866a213f54c326c..c78996628c45a537d3278c90f889013fec657f97 100644 --- a/lib/modules/blockchain/blockchain/src/dbex.rs +++ b/lib/modules/blockchain/blockchain/src/dbex.rs @@ -168,7 +168,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB // Get members count let members_count = wot_db - .read(|db| db.get_enabled()) + .read(WebOfTrust::get_enabled) .expect("Fail to read WotDB") .len(); diff --git a/lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs b/lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs index 350f445bfea16e14bd6fb805fb6dee6cb41dbc64..1c3d7a4576a3aa8c83c78dd987efa8cbd4b1b108 100644 --- a/lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs +++ b/lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs @@ -65,7 +65,7 @@ pub fn apply_valid_block<W: WebOfTrust>( // Newcomer let wot_id = NodeId( wot_db - .read(|db| db.size()) + .read(WebOfTrust::size) .expect("Fatal error : fail to read WotDB !"), ); wot_db @@ -195,7 +195,7 @@ pub fn apply_valid_block<W: WebOfTrust>( if let Some(du_amount) = block.dividend { if du_amount > 0 { let members_wot_ids = wot_db - .read(|db| db.get_enabled()) + .read(WebOfTrust::get_enabled) .expect("Fail to read WotDB"); let mut members_pubkeys = Vec::new(); for (pubkey, wot_id) in wot_index { diff --git a/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs b/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs index 66d9795b90787c42e1d3347b381f3bdf351d98bf..224dcb2b59af85132b888dcb536c6bf1ec6a410c 100644 --- a/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs +++ b/lib/modules/blockchain/blockchain/src/fork/fork_algo.rs @@ -14,6 +14,7 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. use dubp_documents::Blockstamp; +use durs_blockchain_dal::entities::fork_tree::ForkTree; use durs_blockchain_dal::{DALError, ForksDBs}; use std::collections::HashSet; @@ -34,9 +35,7 @@ pub fn fork_resolution_algo( .median_time })?; - let mut sheets = forks_dbs - .fork_tree_db - .read(|fork_tree| fork_tree.get_sheets())?; + let mut sheets = forks_dbs.fork_tree_db.read(ForkTree::get_sheets)?; sheets.sort_unstable_by(|s1, s2| s2.1.id.cmp(&s1.1.id)); diff --git a/lib/modules/blockchain/blockchain/src/fork/revert_block.rs b/lib/modules/blockchain/blockchain/src/fork/revert_block.rs index febdd0fd4860c158f8aa72a73a257c0436bc9d44..e9aca1d8313125a7d30cd42ca4c0d1601f741ab6 100644 --- a/lib/modules/blockchain/blockchain/src/fork/revert_block.rs +++ b/lib/modules/blockchain/blockchain/src/fork/revert_block.rs @@ -97,7 +97,7 @@ pub fn revert_block<W: WebOfTrust>( if let Some(du_amount) = block.dividend { if du_amount > 0 { let members_wot_ids = wot_db - .read(|db| db.get_enabled()) + .read(WebOfTrust::get_enabled) .expect("Fail to read WotDB"); let mut members_pubkeys = Vec::new(); for (pubkey, wot_id) in wot_index.iter() { diff --git a/lib/modules/ws2p-v1-legacy/lib.rs b/lib/modules/ws2p-v1-legacy/lib.rs index a501c583bc1b9649db4ebc691e8938c8be96c291..a3e7663e068d2b5ee8ab454e75133c49390b155f 100644 --- a/lib/modules/ws2p-v1-legacy/lib.rs +++ b/lib/modules/ws2p-v1-legacy/lib.rs @@ -711,7 +711,7 @@ impl DursModule<DuRsConf, DursMsg> for WS2PModule { WS2PSignal::Heads(ws2p_full_id, heads) => { trace!("WS2PSignal::Heads({}, {:?})", ws2p_full_id, heads.len()); ws2p_module.send_dal_request(&BlockchainRequest::UIDs( - heads.iter().map(|h| h.pubkey()).collect(), + heads.iter().map(NetworkHead::pubkey).collect(), )); ws2p_module.send_network_event(&NetworkEvent::ReceiveHeads( heads diff --git a/lib/modules/ws2p/ws2p/src/generate_peer.rs b/lib/modules/ws2p/ws2p/src/generate_peer.rs index 03b027b175a087b22f7428c13c021a139b5cafb7..5c3587525d701282907e233db30f65eca9161ec5 100644 --- a/lib/modules/ws2p/ws2p/src/generate_peer.rs +++ b/lib/modules/ws2p/ws2p/src/generate_peer.rs @@ -37,7 +37,7 @@ pub fn _self_peer_update_endpoints( false } }) - .map(|ep| ep.api()) + .map(EndpointEnum::api) .collect(); let mut new_endpoints_bin = Vec::with_capacity(max_eps); let mut new_endpoints_str = Vec::with_capacity(max_eps); diff --git a/lib/tools/network-documents/src/network_peer.rs b/lib/tools/network-documents/src/network_peer.rs index e53d983a94da2678e161990c118e716ae8784096..ea4378cce5b390bb0ff3e0dbfc0c1f3946f5c44d 100644 --- a/lib/tools/network-documents/src/network_peer.rs +++ b/lib/tools/network-documents/src/network_peer.rs @@ -199,7 +199,7 @@ impl PeerCardV11 { algorithm: self.issuer.algo(), pubkey: self.issuer.to_base58(), blockstamp: self.blockstamp.to_string(), - endpoints: self.endpoints.iter().map(|ep| ep.to_string()).collect(), + endpoints: self.endpoints.iter().map(EndpointV2::to_string).collect(), signature: if let Some(sig) = self.sig { Some(sig.to_base64()) } else {