From 3f5e883b55b119224a09f6ebb448d3695567d4dd Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Tue, 23 Apr 2019 01:25:11 +0200 Subject: [PATCH] [style] comply new clippy version --- Cargo.lock | 2 ++ lib/modules/blockchain/blockchain-dal/src/readers/block.rs | 2 +- .../blockchain/blockchain-dal/src/writers/fork_tree.rs | 5 +++-- lib/modules/blockchain/blockchain/src/dbex.rs | 2 +- lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs | 4 ++-- lib/modules/blockchain/blockchain/src/fork/fork_algo.rs | 5 ++--- lib/modules/blockchain/blockchain/src/fork/revert_block.rs | 2 +- lib/modules/ws2p-v1-legacy/lib.rs | 2 +- lib/modules/ws2p/ws2p/src/generate_peer.rs | 2 +- lib/tools/network-documents/src/network_peer.rs | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eedfb2d1..87cbd1b2 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 8904dda1..7dd0a84c 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 8981bf20..b4bd8d6d 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 31020219..c7899662 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 350f445b..1c3d7a45 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 66d9795b..224dcb2b 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 febdd0fd..e9aca1d8 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 a501c583..a3e7663e 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 03b027b1..5c358752 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 e53d983a..ea4378cc 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 { -- GitLab