diff --git a/blockchain/apply_valid_block.rs b/blockchain/apply_valid_block.rs index 4b5ecfdc3f3041f0b3f4f9b2a6132cf1d4287d92..32f477adb347eda1c8704086ae9624cc0c2ad6a5 100644 --- a/blockchain/apply_valid_block.rs +++ b/blockchain/apply_valid_block.rs @@ -71,8 +71,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wot_db .write(|db| { db.add_node(); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_index.insert(pubkey, wotb_id); wot_dbs_requests.push(WotsDBsWriteQuery::CreateIdentity( wotb_id, @@ -87,8 +86,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(wotb_id, true); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RenewalIdentity( joiner.issuers()[0], wotb_id, @@ -104,8 +102,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(wotb_id, true); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RenewalIdentity( pubkey, wotb_id, @@ -123,8 +120,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(*wot_id, false); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::ExcludeIdentity( exclusion, block.blockstamp(), @@ -140,8 +136,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(*wot_id, false); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevokeIdentity( compact_revoc.issuer, block.blockstamp(), @@ -163,8 +158,7 @@ pub fn apply_valid_block<W: WebOfTrust>( wotb_node_from.0, wotb_node_to.0, result ), } - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::CreateCert( compact_cert.issuer, wotb_node_from, @@ -188,8 +182,7 @@ pub fn apply_valid_block<W: WebOfTrust>( RemLinkResult::Removed(_) => {} _ => panic!("Fail to rem_link {}->{} : {:?}", source.0, target.0, result), } - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); } } if let Some(du_amount) = block.dividend { diff --git a/blockchain/dbex.rs b/blockchain/dbex.rs index a07cc1f29e72d36df4a4e6df3d331565ee50ecb5..9c09b6aa80fe02dd308d7f103f8dcc5e920e0af8 100644 --- a/blockchain/dbex.rs +++ b/blockchain/dbex.rs @@ -95,7 +95,7 @@ pub fn dbex_tx<DC: DuniterConf>(profile: &str, conf: &DC, _csv: bool, query: &DB ¤cy_databases.balances_db, &address, ).expect("get_address_balance : DALError") - .expect("Address not found in balances DB."); + .expect("Address not found in balances DB."); println!( "Balance={},{} Ğ1", (address_balance.0).0 / 100, @@ -151,8 +151,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB db.iter() .map(|(_, idty)| (idty.wot_id, String::from(idty.idty_doc.username()))) .collect() - }) - .expect("Fail to read IdentitiesDB !"); + }).expect("Fail to read IdentitiesDB !"); // Open wot db let wot_db = open_wot_db::<RustyWebOfTrust>(Some(&db_path)).expect("Fail to open WotDB !"); @@ -186,13 +185,10 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB step_max: currency_params.step_max as u32, x_percent: currency_params.x_percent, }, - ) - .expect("Fail to get distance !"), + ).expect("Fail to get distance !"), ) - }) - .collect() - }) - .expect("Fail to read WotDB"); + }).collect() + }).expect("Fail to read WotDB"); let compute_distances_duration = SystemTime::now() .duration_since(compute_distances_begin) .expect("duration_since error"); @@ -235,8 +231,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB .map(|(block_id, dal_block)| (*block_id, dal_block.block.median_time)) .collect(), ) - }) - .expect("Fail to read blockchain db"); + }).expect("Fail to read blockchain db"); // Get expire_dates let min_created_ms_time = current_bc_time - currency_params.ms_validity; let mut expire_dates: Vec<(NodeId, u64)> = wot_databases @@ -255,8 +250,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB } } expire_dates - }) - .expect("Fail to read ms db"); + }).expect("Fail to read ms db"); if *reverse { expire_dates.sort_unstable_by(|(_, d1), (_, d2)| d1.cmp(&d2)); } else { @@ -290,8 +284,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB x_percent: currency_params.x_percent, }, ) - }) - .expect("Fail to read WotDB") + }).expect("Fail to read WotDB") .expect("Fail to get distance !"); let distance_percent: f64 = f64::from(distance_datas.success) / f64::from(distance_datas.sentries) * 100.0; @@ -309,7 +302,7 @@ pub fn dbex_wot<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DB &wot_databases.identities_db, *(wot_reverse_index[&source]), ).expect("get_uid() : DALError") - .expect("Not found source_uid !"); + .expect("Not found source_uid !"); println!("{}: {}", i + 1, source_uid); } } else { diff --git a/blockchain/lib.rs b/blockchain/lib.rs index 410379bfb754e51498063199747fc7b75d2b4010..33df82665db46a718fcccdb22be5ac9692543c95 100644 --- a/blockchain/lib.rs +++ b/blockchain/lib.rs @@ -16,10 +16,19 @@ //! Module managing the Duniter blockchain. #![cfg_attr(feature = "strict", deny(warnings))] -#![cfg_attr(feature = "cargo-clippy", allow(unused_collect, duration_subsec))] +#![cfg_attr( + feature = "cargo-clippy", + allow(unused_collect, duration_subsec) +)] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] @@ -162,10 +171,10 @@ impl BlockchainModule { .expect("Fatal error : fail to read Blockchain DB !"); // Get currency parameters - let currency_params = duniter_dal::currency_params::get_currency_params( - &blocks_databases.blockchain_db, - ).expect("Fatal error : fail to read Blockchain DB !") - .unwrap_or_default(); + let currency_params = + duniter_dal::currency_params::get_currency_params(&blocks_databases.blockchain_db) + .expect("Fatal error : fail to read Blockchain DB !") + .unwrap_or_default(); // Get forks states let forks_states = if let Some(current_blockstamp) = current_blockstamp { @@ -473,15 +482,13 @@ impl BlockchainModule { .map(|req| { req.apply(&self.wot_databases, &self.currency_params) .expect("Fatal error : Fail to apply WotsDBsWriteRequest !"); - }) - .collect::<()>(); + }).collect::<()>(); tx_dbs_queries .iter() .map(|req| { req.apply(&self.currency_databases) .expect("Fatal error : Fail to apply CurrencyDBsWriteRequest !"); - }) - .collect::<()>(); + }).collect::<()>(); save_blocks_dbs = true; if !wot_dbs_queries.is_empty() { save_wots_dbs = true; @@ -519,10 +526,10 @@ impl BlockchainModule { let wot_db = open_wot_db::<RustyWebOfTrust>(Some(&dbs_path)).expect("Fail to open WotDB !"); // Get current block - let mut current_blockstamp = duniter_dal::block::get_current_blockstamp( - &self.blocks_databases, - ).expect("Fatal error : fail to read ForksV10DB !") - .unwrap_or_default(); + let mut current_blockstamp = + duniter_dal::block::get_current_blockstamp(&self.blocks_databases) + .expect("Fatal error : fail to read ForksV10DB !") + .unwrap_or_default(); // Init datas let mut last_get_stackables_blocks = UNIX_EPOCH; @@ -542,7 +549,8 @@ impl BlockchainModule { let now = SystemTime::now(); if now .duration_since(last_request_blocks) - .expect("duration_since error") > Duration::new(20, 0) + .expect("duration_since error") + > Duration::new(20, 0) { last_request_blocks = now; // Request begin blocks @@ -663,7 +671,11 @@ impl BlockchainModule { &mut wotb_index, &wot_db, Some(free_fork_id), - &self.currency_databases.tx_db.read(|db| db.clone()).expect("Fail to read TxDB.") + &self + .currency_databases + .tx_db + .read(|db| db.clone()) + .expect("Fail to read TxDB."), ).expect("Fail to revert block"); } } @@ -682,11 +694,10 @@ impl BlockchainModule { if current_blockstamp != new_current_blockstamp { current_blockstamp = new_current_blockstamp; // Update forks states - self.forks_states = - duniter_dal::block::get_forks( - &self.blocks_databases.forks_db, - current_blockstamp, - ).expect("get_forks() : DALError"); + self.forks_states = duniter_dal::block::get_forks( + &self.blocks_databases.forks_db, + current_blockstamp, + ).expect("get_forks() : DALError"); } } } @@ -713,7 +724,8 @@ impl BlockchainModule { let now = SystemTime::now(); if now .duration_since(last_get_stackables_blocks) - .expect("duration_since error") > Duration::new(20, 0) + .expect("duration_since error") + > Duration::new(20, 0) { last_get_stackables_blocks = now; loop { @@ -752,16 +764,14 @@ impl BlockchainModule { .expect( "Fatal error : Fail to apply WotsDBsWriteRequest !", ); - }) - .collect::<()>(); + }).collect::<()>(); tx_dbs_queries .iter() .map(|req| { req.apply(&self.currency_databases).expect( "Fatal error : Fail to apply CurrencyDBsWriteRequest !", ); - }) - .collect::<()>(); + }).collect::<()>(); // Save databases self.blocks_databases.save_dbs(); if !wot_dbs_queries.is_empty() { diff --git a/blockchain/revert_block.rs b/blockchain/revert_block.rs index 4ac1e0f48bebd0cfdfc1ade1033dd60e41e271cc..eabcb9f5334fa6b22f858706fe7b6f8eba780888 100644 --- a/blockchain/revert_block.rs +++ b/blockchain/revert_block.rs @@ -62,8 +62,7 @@ pub fn revert_block<W: WebOfTrust>( .map(|tx_enum| match *tx_enum { TxDocOrTxHash::TxHash(ref tx_hash) => txs[tx_hash].clone(), TxDocOrTxHash::TxDoc(ref _dal_tx) => panic!("Try to revert not reduce block !"), - }) - .collect(); + }).collect(); // Revert reduce block block.compute_inner_hash(); @@ -109,8 +108,7 @@ pub fn revert_block<W: WebOfTrust>( NewLinkResult::Ok(_) => {} _ => panic!("Fail to add_link {}->{} : {:?}", source.0, target.0, result), } - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertExpireCert( source, target, @@ -134,8 +132,7 @@ pub fn revert_block<W: WebOfTrust>( wotb_node_from.0, wotb_node_to.0, result ), } - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertCert( compact_cert, wotb_node_from, @@ -154,8 +151,7 @@ pub fn revert_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(*wot_id, false); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertRevokeIdentity( compact_revoc.issuer, block.blockstamp(), @@ -172,8 +168,7 @@ pub fn revert_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(*wot_id, false); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertExcludeIdentity( exclusion, block.blockstamp(), @@ -192,8 +187,7 @@ pub fn revert_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(wotb_id, true); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertRenewalIdentity( pubkey, wotb_id, @@ -210,8 +204,7 @@ pub fn revert_block<W: WebOfTrust>( wot_db .write(|db| { db.rem_node(); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_index.remove(&pubkey); wot_dbs_requests.push(WotsDBsWriteQuery::RevertCreateIdentity(pubkey)); } else { @@ -220,8 +213,7 @@ pub fn revert_block<W: WebOfTrust>( wot_db .write(|db| { db.set_enabled(wotb_id, true); - }) - .expect("Fail to write in WotDB"); + }).expect("Fail to write in WotDB"); wot_dbs_requests.push(WotsDBsWriteQuery::RevertRenewalIdentity( joiner.issuers()[0], wotb_id, diff --git a/blockchain/sync.rs b/blockchain/sync.rs index d2ba4d32ef2411c69e907863c0f17948d49c04ad..655227f2179627b93ccc7bd96c29c5eb420e1d19 100644 --- a/blockchain/sync.rs +++ b/blockchain/sync.rs @@ -369,8 +369,7 @@ pub fn sync_ts<DC: DuniterConf>( .forks_db .write(|db| { db.insert(ForkId(0), blockchain_meta_datas); - }) - .expect("Indexing blockchain meta datas : DALError"); + }).expect("Indexing blockchain meta datas : DALError"); // Increment progress bar (last chunk) apply_pb.inc(); @@ -505,8 +504,7 @@ pub fn sync_ts<DC: DuniterConf>( .write(|db| { db.0 = block_doc.currency.clone(); db.1 = block_doc.parameters.unwrap(); - }) - .expect("fail to write in params DB"); + }).expect("fail to write in params DB"); currency_params = CurrencyParameters::from(( block_doc.currency.clone(), block_doc.parameters.unwrap(), diff --git a/blockchain/ts_parsers.rs b/blockchain/ts_parsers.rs index 6fb27f4dffd8e59288a6807daec2d9df9b06776e..030b96e7e9a677c4d9758d40f48bd3c1b4ba2994 100644 --- a/blockchain/ts_parsers.rs +++ b/blockchain/ts_parsers.rs @@ -85,9 +85,9 @@ pub fn parse_ts_block(row: &[sqlite::Value]) -> NetworkBlock { Some(dividend) => Some(dividend as usize), None => None, }; - let json_identities: serde_json::Value = serde_json::from_str( - row[20].as_string().expect("Fail to parse block identities"), - ).expect("Fail to parse block identities (2)"); + let json_identities: serde_json::Value = + serde_json::from_str(row[20].as_string().expect("Fail to parse block identities")) + .expect("Fail to parse block identities (2)"); let mut identities = Vec::new(); for raw_idty in json_identities .as_array() @@ -96,9 +96,9 @@ pub fn parse_ts_block(row: &[sqlite::Value]) -> NetworkBlock { identities .push(parse_compact_identity(¤cy, &raw_idty).expect("Fail to parse block idty")); } - let json_txs: serde_json::Value = serde_json::from_str( - row[18].as_string().expect("Fail to parse block txs"), - ).expect("Fail to parse block txs (2)"); + let json_txs: serde_json::Value = + serde_json::from_str(row[18].as_string().expect("Fail to parse block txs")) + .expect("Fail to parse block txs (2)"); let mut transactions = Vec::new(); for json_tx in json_txs.as_array().expect("Fail to parse block txs (3)") { transactions.push(TxDocOrTxHash::TxDoc(Box::new( @@ -113,9 +113,9 @@ pub fn parse_ts_block(row: &[sqlite::Value]) -> NetworkBlock { Some(previous_header_) => Some(previous_header_.issuer), None => None, }; - let excluded: serde_json::Value = serde_json::from_str( - row[25].as_string().expect("Fail to parse excluded"), - ).expect("Fail to parse excluded (2)"); + let excluded: serde_json::Value = + serde_json::from_str(row[25].as_string().expect("Fail to parse excluded")) + .expect("Fail to parse excluded (2)"); let uncompleted_block_doc = BlockDocument { nonce: row[17].as_integer().expect("Fail to parse nonce") as u64, number: current_header.number, @@ -180,18 +180,17 @@ pub fn parse_ts_block(row: &[sqlite::Value]) -> NetworkBlock { e.as_str().expect("Fail to parse excluded (4)"), ).expect("Fail to parse excluded (5)"), ) - }) - .collect(), + }).collect(), certifications: Vec::new(), transactions, inner_hash_and_nonce_str: String::new(), }; - let revoked: serde_json::Value = serde_json::from_str( - row[24].as_string().expect("Fail to parse revoked"), - ).expect("Fail to parse revoked (2)"); - let certifications: serde_json::Value = serde_json::from_str( - row[19].as_string().expect("Fail to parse certifications"), - ).expect("Fail to parse certifications (2)"); + let revoked: serde_json::Value = + serde_json::from_str(row[24].as_string().expect("Fail to parse revoked")) + .expect("Fail to parse revoked (2)"); + let certifications: serde_json::Value = + serde_json::from_str(row[19].as_string().expect("Fail to parse certifications")) + .expect("Fail to parse certifications (2)"); // return NetworkBlock NetworkBlock::V10(Box::new(NetworkBlockV10 { uncompleted_block_doc, @@ -252,11 +251,10 @@ pub fn parse_memberships( membership_type, raw_memberships.as_array().unwrap(), ).iter() - .map(|m| { - m.clone() - .expect("Fatal error : Fail to parse membership from local DB !") - }) - .collect(), + .map(|m| { + m.clone() + .expect("Fatal error : Fail to parse membership from local DB !") + }).collect(), ); } None @@ -290,8 +288,7 @@ pub fn parse_memberships_from_json_value( } else { Err(MembershipParseError::WrongFormat()) } - }) - .collect() + }).collect() } /// Parse transaction from json value diff --git a/conf/lib.rs b/conf/lib.rs index 5964847e219113abbb896aa2c16aba2000985f60..7ebf86f278e7d2eb19d43fd89d21dc18b257d291 100644 --- a/conf/lib.rs +++ b/conf/lib.rs @@ -18,8 +18,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/core/lib.rs b/core/lib.rs index fcbe70d09e13446a0a4b3d8e5632c4f3dda9199f..783d34762d1bbe78099636f17dca01fa515aa140 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -18,8 +18,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![cfg_attr(feature = "cargo-clippy", allow(implicit_hasher))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] @@ -738,7 +744,6 @@ pub fn init_logger(profile: &str, soft_name: &'static str, cli_args: &ArgMatches log_file_path .to_str() .expect("Fatal error : fail to get log file path !"), - ) - .expect("Fatal error : fail to open log file !"), + ).expect("Fatal error : fail to open log file !"), )]).expect("Fatal error : fail to init logger !"); } diff --git a/crypto/lib.rs b/crypto/lib.rs index 5f43cce266558af94012e3305a84eed8dc2eb16d..c05b5fc79217ec29b634dc90fa6a851124c2d55a 100644 --- a/crypto/lib.rs +++ b/crypto/lib.rs @@ -17,8 +17,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/dal/lib.rs b/dal/lib.rs index bd82d6b27ee3b10db4e5ee3e9c2694cca8e690d0..e116f53534ffb7cb046fddcd1dcc7cb1566f0bd1 100644 --- a/dal/lib.rs +++ b/dal/lib.rs @@ -19,8 +19,14 @@ #![cfg_attr(feature = "cargo-clippy", allow(implicit_hasher))] #![cfg_attr(feature = "exp", allow(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] @@ -455,7 +461,8 @@ pub fn open_db<D: Serialize + DeserializeOwned + Debug + Default + Clone + Send> if file_path.exists() && fs::metadata(file_path) .expect("fail to get file size") - .len() > 0 + .len() + > 0 { let backend = FileBackend::open(db_path.as_path())?; let db = FileDatabase::<D, Bincode>::from_parts(D::default(), backend, Bincode); diff --git a/dal/tools.rs b/dal/tools.rs index 15cad56eb218305c1c486a3fe19a201bf8a2db6f..43950523ac4bbf8c05e19257e10be6311fc0e6d0 100644 --- a/dal/tools.rs +++ b/dal/tools.rs @@ -113,16 +113,16 @@ pub fn compute_distances<T: WebOfTrust + Sync>( step_max, x_percent, }, - ) - .expect("Fatal Error: compute_distance return None !"); + ).expect("Fatal Error: compute_distance return None !"); let mut distance = ((f64::from(distance_datas.success) - / (x_percent * f64::from(distance_datas.sentries))) * 100.0) - as usize; + / (x_percent * f64::from(distance_datas.sentries))) + * 100.0) as usize; distances.push(distance); average_distance += distance; let mut connectivity = ((f64::from(distance_datas.success - distance_datas.success_at_border) - / (x_percent * f64::from(distance_datas.sentries))) * 100.0) as usize; + / (x_percent * f64::from(distance_datas.sentries))) + * 100.0) as usize; connectivities.push(connectivity); average_connectivity += connectivity; } diff --git a/dal/writers/block.rs b/dal/writers/block.rs index d447ad41666b55d09ebb301e736b9c21a422b59a..03c556722c7814e9ebbc790eb59c08b10b8ae4ee 100644 --- a/dal/writers/block.rs +++ b/dal/writers/block.rs @@ -101,8 +101,7 @@ pub fn write( forks_db .write(|db| { db.insert(ForkId(0), blockchain_meta_datas); - }) - .expect("Write blockchain meta datas : DALError"); + }).expect("Write blockchain meta datas : DALError"); } Ok(()) } diff --git a/dal/writers/dividend.rs b/dal/writers/dividend.rs index fb9899b231aa5492ac1344d7ca6a749794b0905e..e5d64193c7dbf4de63ca53b7cb80fcc07d9bc021 100644 --- a/dal/writers/dividend.rs +++ b/dal/writers/dividend.rs @@ -51,7 +51,7 @@ pub fn create_du( db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(*pubkey), )).cloned() - .unwrap_or_default(), + .unwrap_or_default(), ); } members_balances @@ -66,8 +66,7 @@ pub fn create_du( *balance + *du_amount }; (*pubkey, (new_balance, utxos_indexs.clone())) - }) - .collect(); + }).collect(); // Write new members balance balances_db.write(|db| { for (pubkey, (balance, utxos_indexs)) in members_balances { diff --git a/dal/writers/transaction.rs b/dal/writers/transaction.rs index 8d0e240d3b468f5517f11374bb03e3024027864b..634c471d9e7cd51dc88400239a4d1af9bd0c93b3 100644 --- a/dal/writers/transaction.rs +++ b/dal/writers/transaction.rs @@ -141,8 +141,7 @@ pub fn revert_tx(dbs: &CurrencyV10DBs, dal_tx: &DALTxV10) -> Result<(), DALError SourceIndexV10::UTXO(UTXOIndexV10(hash, tx_index)), SourceAmount(tx_amout, tx_amout_base), ), - }) - .collect(); + }).collect(); // Find adress of recreated sources let recreated_adress: HashMap<UTXOConditionsGroup, (SourceAmount, HashSet<UTXOIndexV10>)> = dbs.utxos_db.read(|db| { @@ -257,8 +256,7 @@ pub fn apply_and_write_tx( SourceIndexV10::UTXO(UTXOIndexV10(hash, tx_index)), SourceAmount(tx_amout, tx_amout_base), ), - }) - .collect(); + }).collect(); // Find adress of consumed sources let consumed_adress: HashMap<UTXOConditionsGroup, (SourceAmount, HashSet<UTXOIndexV10>)> = dbs.utxos_db.read(|db| { @@ -482,8 +480,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tx_doc.issuers()[0]), )).cloned() - }) - .expect("Fail to read cgeek new balance") + }).expect("Fail to read cgeek new balance") .expect("Error : cgeek is not referenced in balances_db !"); assert_eq!(cgeek_new_balance.0, SourceAmount(TxAmount(1000), TxBase(0))); let tortue_new_balance = currency_dbs @@ -492,8 +489,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tortue_pubkey), )).cloned() - }) - .expect("Fail to read receiver new balance") + }).expect("Fail to read receiver new balance") .expect("Error : receiver is not referenced in balances_db !"); assert_eq!( tortue_new_balance.0, @@ -508,8 +504,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tx_doc.issuers()[0]), )).cloned() - }) - .expect("Fail to read cgeek new balance") + }).expect("Fail to read cgeek new balance") .expect("Error : cgeek is not referenced in balances_db !"); assert_eq!(cgeek_new_balance.0, SourceAmount(TxAmount(999), TxBase(0))); @@ -520,8 +515,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tortue_pubkey), )).cloned() - }) - .expect("Fail to read receiver new balance") + }).expect("Fail to read receiver new balance") .expect("Error : receiver is not referenced in balances_db !"); assert_eq!( receiver_new_balance.0, @@ -544,8 +538,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tx_doc.issuers()[0]), )).cloned() - }) - .expect("Fail to read cgeek new balance") + }).expect("Fail to read cgeek new balance") .expect("Error : cgeek is not referenced in balances_db !"); assert_eq!(cgeek_new_balance.0, SourceAmount(TxAmount(1000), TxBase(0))); @@ -556,8 +549,7 @@ mod tests { db.get(&UTXOConditionsGroup::Single( TransactionOutputCondition::Sig(tortue_pubkey), )).cloned() - }) - .expect("Fail to read receiver new balance") + }).expect("Fail to read receiver new balance") .expect("Error : receiver is not referenced in balances_db !"); assert_eq!( receiver_new_balance.0, diff --git a/documents/blockchain/v10/documents/mod.rs b/documents/blockchain/v10/documents/mod.rs index ec32ead1118ac403204b81bbbf3658eacb74c598..1cb541650b0479fc316bee80c4a27391db113044 100644 --- a/documents/blockchain/v10/documents/mod.rs +++ b/documents/blockchain/v10/documents/mod.rs @@ -321,8 +321,7 @@ SoKwoa8PFfCDJWZ6dNCv7XstezHcc2BbKiJgVDXv82R5zYR83nis9dShLgWJ5w48noVUHimdngzYQneN 42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r 2D96KZwNUvVtcapQPq2mm7J9isFcDCfykwJpVEZwBc7tCgL4qPyu17BT5ePozAE9HS6Yvj51f62Mp4n9d9dkzJoX 2XiBDpuUdu6zCPWGzHXXy8c4ATSscfFQG9DjmqMZUxDZVt1Dp4m2N5oHYVUfoPdrU9SLk4qxi65RNrfCVnvQtQJk" - ) - .count(), + ).count(), 3 ); @@ -332,8 +331,7 @@ SoKwoa8PFfCDJWZ6dNCv7XstezHcc2BbKiJgVDXv82R5zYR83nis9dShLgWJ5w48noVUHimdngzYQneN " 42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r 2XiBDpuUdu6zCPWGzHXXy8c4ATSscfFQG9DjmqMZUxDZVt1Dp4m2N5oHYVUfoPdrU9SLk4qxi65RNrfCVnvQtQJk" - ) - .count(), + ).count(), 2 ); } diff --git a/documents/lib.rs b/documents/lib.rs index 1ea9914223164135b15c3b245f0ad71d2135ff89..39f8166116c646e562312b2240d88e38df17e1a1 100644 --- a/documents/lib.rs +++ b/documents/lib.rs @@ -18,8 +18,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![cfg_attr(feature = "cargo-clippy", allow(unused_collect))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/message/lib.rs b/message/lib.rs index 1b89f4dc38a45067b16333d1e5b4ace3e468a11f..d95c506b5ab2a7b38c1291c0104ad22c17d48ada 100644 --- a/message/lib.rs +++ b/message/lib.rs @@ -18,8 +18,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/module/lib.rs b/module/lib.rs index 4ee5ec846307429ce4a4a3f1ca6f24e11fc45f50..a11db06413dd4726088e093f385be59ba634601e 100644 --- a/module/lib.rs +++ b/module/lib.rs @@ -19,8 +19,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![cfg_attr(feature = "cargo-clippy", allow(implicit_hasher))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/network/lib.rs b/network/lib.rs index 466f4476365ee92bba234d180f80240d51359130..41c066dae134aed4aaf310ad84f83844bce09b75 100644 --- a/network/lib.rs +++ b/network/lib.rs @@ -17,8 +17,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/src/main.rs b/src/main.rs index eacbede7127d6d3001943d637eac47312c4f8c02..f275ed88608829d3a46d2b772e71e0df34f5ba37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] diff --git a/tui/lib.rs b/tui/lib.rs index 29e0013dd2d717f5690cc2d760108e617d0e62b1..67fa4b46af949ecf2a5d8e3978028d00230eb8c5 100644 --- a/tui/lib.rs +++ b/tui/lib.rs @@ -18,8 +18,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] @@ -449,8 +455,7 @@ impl DuniterModule<DuRsConf, DuniterMessage> for TuiModule { tui_sender .send(TuiMess::TermionEvent( c.expect("error to read stdin event !"), - )) - .expect("Fatal error : tui stdin thread module fail to send message !"); + )).expect("Fatal error : tui stdin thread module fail to send message !"); trace!("Send stdin event to tui main thread."); } }); @@ -527,8 +532,7 @@ impl DuniterModule<DuRsConf, DuniterMessage> for TuiModule { .iter() .map(|h| { tui.heads_cache.insert(h.node_full_id(), h.clone()) - }) - .for_each(drop); + }).for_each(drop); } _ => {} }, @@ -606,7 +610,8 @@ impl DuniterModule<DuRsConf, DuniterMessage> for TuiModule { || now .duration_since(last_draw) .expect("Tui : Fatal error : fail to get duration since last draw !") - .subsec_nanos() > 250_000_000 + .subsec_nanos() + > 250_000_000 { last_draw = now; tui.draw_term( diff --git a/wotb/data/rusty.rs b/wotb/data/rusty.rs index 22cdd86612fa5e8fd2e51d02f17195572e1844a7..35cbaed96401f739d2673e3301cd3785ce9dec9e 100644 --- a/wotb/data/rusty.rs +++ b/wotb/data/rusty.rs @@ -199,8 +199,7 @@ impl WebOfTrust for RustyWebOfTrust { n.enabled && n.issued_count >= sentry_requirement && n.links_source.len() >= sentry_requirement - }) - .map(|(i, _)| NodeId(i)) + }).map(|(i, _)| NodeId(i)) .collect() } @@ -212,8 +211,7 @@ impl WebOfTrust for RustyWebOfTrust { n.enabled && (n.issued_count < sentry_requirement || n.links_source.len() < sentry_requirement) - }) - .map(|(i, _)| NodeId(i)) + }).map(|(i, _)| NodeId(i)) .collect() } } diff --git a/wotb/lib.rs b/wotb/lib.rs index a68352c5b6be9ee1fe94e6bcacead24f6872ae34..d8d324e9552b69f7c2688554470d43f2e88e2c08 100644 --- a/wotb/lib.rs +++ b/wotb/lib.rs @@ -28,8 +28,14 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![deny( - missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, - trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, + missing_docs, + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + trivial_numeric_casts, + unsafe_code, + unstable_features, + unused_import_braces, unused_qualifications )] @@ -491,8 +497,7 @@ mod tests { &wot, &[0b0000_0000, 0b0000_0001, 0b0000_0001, 0b0000_0000], "test.wot" - ) - .unwrap(), + ).unwrap(), () ); diff --git a/wotb/operations/distance.rs b/wotb/operations/distance.rs index 46949ad205c0760554d1ee0f4267bd44196f2c0b..14105d595399b71915c84cb088c6a90fdaa7954c 100644 --- a/wotb/operations/distance.rs +++ b/wotb/operations/distance.rs @@ -93,8 +93,7 @@ impl<T: WebOfTrust + Sync> DistanceCalculator<T> for RustyDistanceCalculator { .filter(|source| !area.contains(source)) .cloned() .collect::<HashSet<_>>() - }) - .reduce(HashSet::new, |mut acc, sources| { + }).reduce(HashSet::new, |mut acc, sources| { for source in sources { acc.insert(source); } diff --git a/ws2p/datas.rs b/ws2p/datas.rs index 0177cf120786960addd972c5046ac558de09ce39..5129f7b7c97697f501ac7ae4f9b6531527b66647 100644 --- a/ws2p/datas.rs +++ b/ws2p/datas.rs @@ -184,8 +184,7 @@ impl WS2PModuleDatas { &endpoint .node_full_id() .expect("WS2P: Fail to get ep.node_full_id() !"), - ) - .expect("WS2P: Fail to get_mut() a ws2p_endpoint !") + ).expect("WS2P: Fail to get_mut() a ws2p_endpoint !") .1 = WS2PConnectionState::NeverTry; } None => { @@ -273,8 +272,7 @@ impl WS2PModuleDatas { .get_mut(&ws2p_full_id) .unwrap_or_else(|| { panic!("Fatal error : no websocket for {} !", ws2p_full_id) - }) - .0 + }).0 .send(Message::text(r)) .expect("WS2P: Fail to send Message in websocket !"); } @@ -306,13 +304,11 @@ impl WS2PModuleDatas { for head in heads { if let Some(head) = NetworkHead::from_json_value(&head) { if head.verify() - && (self.my_head.is_none() - || head.node_full_id() - != self - .my_head - .clone() - .expect("WS2P: Fail to clone my_head") - .node_full_id()) + && (self.my_head.is_none() || head.node_full_id() != self + .my_head + .clone() + .expect("WS2P: Fail to clone my_head") + .node_full_id()) && head.apply(&mut self.heads_cache) { applied_heads.push(head); diff --git a/ws2p/lib.rs b/ws2p/lib.rs index 87ccffe675b9d31326eb1fd753e4da216468676d..f1e34fdfbf14cf079431a177985099eaa31274a3 100644 --- a/ws2p/lib.rs +++ b/ws2p/lib.rs @@ -18,8 +18,13 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] #![deny( - missing_debug_implementations, missing_copy_implementations, trivial_casts, unsafe_code, - unstable_features, unused_import_braces, unused_qualifications + missing_debug_implementations, + missing_copy_implementations, + trivial_casts, + unsafe_code, + unstable_features, + unused_import_braces, + unused_qualifications )] #![recursion_limit = "256"] @@ -462,8 +467,7 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule { } }).to_string(), )) - }) - .collect(); + }).collect(); } DALEvent::RevertBlocks(ref _blocks) => {} _ => {} @@ -650,8 +654,7 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule { new_head.set_uid(uid); } new_head - }) - .collect(), + }).collect(), )); } WS2PSignal::Document(ws2p_full_id, network_doc) => { @@ -727,7 +730,8 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule { } if SystemTime::now() .duration_since(last_ws2p_connections_print) - .unwrap() > Duration::new(5, 0) + .unwrap() + > Duration::new(5, 0) { last_ws2p_connections_print = SystemTime::now(); let mut connected_nodes = Vec::new(); @@ -837,11 +841,10 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule { info!( "Write {} endpoint in {} secs.", ep_full_id, - *DURATION_BEFORE_RECORDING_ENDPOINT - - SystemTime::now() - .duration_since(received_time) - .unwrap() - .as_secs() + *DURATION_BEFORE_RECORDING_ENDPOINT - SystemTime::now() + .duration_since(received_time) + .unwrap() + .as_secs() ); } } diff --git a/ws2p/parsers/identities.rs b/ws2p/parsers/identities.rs index ef62335415055c325cef050850d8957efc949fb9..3de01344f5e9d5d4c1f4c17417b64add3d11b84e 100644 --- a/ws2p/parsers/identities.rs +++ b/ws2p/parsers/identities.rs @@ -20,8 +20,7 @@ pub fn parse_identities(currency: &str, json_datas: &str) -> Option<Vec<Identity .map(|i| { i.clone() .expect("Fatal error : Fail to parse identity from local DB !") - }) - .collect(), + }).collect(), ); } None @@ -51,8 +50,7 @@ pub fn parse_identities_from_json_value( } else { Err(IdentityParseError::WrongFormat()) } - }) - .collect() + }).collect() } pub fn parse_compact_identity( diff --git a/ws2p/parsers/memberships.rs b/ws2p/parsers/memberships.rs index 51704255891f3b2372b25865cb593adc04b05848..1d9c76bdbea1fc8b4dc70c5bdc0760a709fcdccd 100644 --- a/ws2p/parsers/memberships.rs +++ b/ws2p/parsers/memberships.rs @@ -26,11 +26,10 @@ pub fn parse_memberships( membership_type, raw_memberships.as_array().unwrap(), ).iter() - .map(|m| { - m.clone() - .expect("Fatal error : Fail to parse membership from local DB !") - }) - .collect(), + .map(|m| { + m.clone() + .expect("Fatal error : Fail to parse membership from local DB !") + }).collect(), ); } None @@ -63,6 +62,5 @@ pub fn parse_memberships_from_json_value( } else { Err(MembershipParseError::WrongFormat()) } - }) - .collect() + }).collect() } diff --git a/ws2p/ws2p_connection.rs b/ws2p/ws2p_connection.rs index 3a578a968252096887caac9e042ddbea6cea236e..0ecffdf1d01717d8d73656210fe8a1683733b564 100644 --- a/ws2p/ws2p_connection.rs +++ b/ws2p/ws2p_connection.rs @@ -78,7 +78,8 @@ impl Handler for Client { // Spam ? if SystemTime::now() .duration_since(self.last_mess_time) - .unwrap() > Duration::new(*WS2P_SPAM_INTERVAL_IN_MILLI_SECS, 0) + .unwrap() + > Duration::new(*WS2P_SPAM_INTERVAL_IN_MILLI_SECS, 0) { if self.spam_interval { self.spam_counter += 1; @@ -129,12 +130,14 @@ impl Handler for Client { match event { CONNECT => { if self.conn_meta_datas.state != WS2PConnectionState::Established { - let _result = self.conductor_sender.send( - WS2PThreadSignal::WS2PConnectionMessage(WS2PConnectionMessage( - self.conn_meta_datas.node_full_id(), - WS2PConnectionMessagePayload::NegociationTimeout, - )), - ); + let _result = + self.conductor_sender + .send(WS2PThreadSignal::WS2PConnectionMessage( + WS2PConnectionMessage( + self.conn_meta_datas.node_full_id(), + WS2PConnectionMessagePayload::NegociationTimeout, + ), + )); self.ws.close(CloseCode::Away) } else { Ok(()) @@ -530,39 +533,42 @@ impl WS2PConnectionMetaDatas { ) -> WS2PConnectionMessagePayload { match body.get("peer") { Some(peer) => match peer.get("pubkey") { - Some(raw_pubkey) => match ed25519::PublicKey::from_base58( - raw_pubkey.as_str().unwrap_or(""), - ) { - Ok(pubkey) => { - let mut ws2p_endpoints: Vec<NetworkEndpoint> = Vec::new(); - match peer.get("endpoints") { - Some(endpoints) => match endpoints.as_array() { - Some(array_endpoints) => { - for endpoint in array_endpoints { - if let Some(ep) = NetworkEndpoint::parse_from_raw( - endpoint.as_str().unwrap_or(""), - PubKey::Ed25519(pubkey), - 0, - 0, - ) { - if ep.api() == NetworkEndpointApi(String::from("WS2P")) - { - ws2p_endpoints.push(ep); + Some(raw_pubkey) => { + match ed25519::PublicKey::from_base58(raw_pubkey.as_str().unwrap_or("")) { + Ok(pubkey) => { + let mut ws2p_endpoints: Vec< + NetworkEndpoint, + > = Vec::new(); + match peer.get("endpoints") { + Some(endpoints) => match endpoints.as_array() { + Some(array_endpoints) => { + for endpoint in array_endpoints { + if let Some(ep) = NetworkEndpoint::parse_from_raw( + endpoint.as_str().unwrap_or(""), + PubKey::Ed25519(pubkey), + 0, + 0, + ) { + if ep.api() + == NetworkEndpointApi(String::from("WS2P")) + { + ws2p_endpoints.push(ep); + } } } + WS2PConnectionMessagePayload::PeerCard( + body.clone(), + ws2p_endpoints, + ) } - WS2PConnectionMessagePayload::PeerCard( - body.clone(), - ws2p_endpoints, - ) - } + None => WS2PConnectionMessagePayload::WrongFormatMessage, + }, None => WS2PConnectionMessagePayload::WrongFormatMessage, - }, - None => WS2PConnectionMessagePayload::WrongFormatMessage, + } } + Err(_) => WS2PConnectionMessagePayload::WrongFormatMessage, } - Err(_) => WS2PConnectionMessagePayload::WrongFormatMessage, - }, + } None => WS2PConnectionMessagePayload::WrongFormatMessage, }, None => WS2PConnectionMessagePayload::WrongFormatMessage,