diff --git a/neon/native/src/server.rs b/neon/native/src/server.rs index 4036b565e89f390a2562774e2392613307e3d2b1..b159b807eb7146624e66b52a9be94ed318d3f1c9 100644 --- a/neon/native/src/server.rs +++ b/neon/native/src/server.rs @@ -450,6 +450,7 @@ impl DbTx { } } +#[allow(clippy::upper_case_acronyms)] #[derive(Deserialize, Serialize)] #[serde(rename_all = "camelCase")] struct HeadWS2Pv1ConfStringified { diff --git a/neon/native/src/wot/write_in_file.rs b/neon/native/src/wot/write_in_file.rs index 746dc40e62a2a714922ccede8b559b41e05a54b1..7f6044403ffda268b1b331245994119bff43ad92 100644 --- a/neon/native/src/wot/write_in_file.rs +++ b/neon/native/src/wot/write_in_file.rs @@ -39,7 +39,7 @@ pub(crate) fn write_and_compress_bytes_in_file( ) -> Result<(), std::io::Error> { let file = File::create(file_path)?; let mut e = ZlibEncoder::new(file, compression); - e.write_all(&datas[..])?; + e.write_all(datas)?; e.finish()?; Ok(()) diff --git a/rust-bins/duniter-launcher/src/duniter_ts_args.rs b/rust-bins/duniter-launcher/src/duniter_ts_args.rs index 6a7e59c9b61a6650fafc4651ce7c65551be216d5..ff76068a9a91f51ff56fd22e861ce9fefb8fad31 100644 --- a/rust-bins/duniter-launcher/src/duniter_ts_args.rs +++ b/rust-bins/duniter-launcher/src/duniter_ts_args.rs @@ -39,8 +39,7 @@ fn gen_webstart_args(args: &DuniterWebstartArgs, duniter_ts_args: &mut Vec<Strin } pub(crate) fn gen_duniter_ts_args(args: &DuniterArgs, duniter_js_exe: String) -> Vec<String> { - let mut duniter_ts_args = Vec::new(); - duniter_ts_args.push(duniter_js_exe); + let mut duniter_ts_args = vec![duniter_js_exe]; if let Some(ref home) = args.home { duniter_ts_args.push("--home".to_owned()); duniter_ts_args.push(home.to_str().expect("invalid home path").to_owned()); diff --git a/rust-bins/duniter-launcher/src/main.rs b/rust-bins/duniter-launcher/src/main.rs index d83279acdf5502df868e42ab92ca72d15ba8fb51..53807347b9759fc4cca9c9c8fb82e05ebd6bde62 100644 --- a/rust-bins/duniter-launcher/src/main.rs +++ b/rust-bins/duniter-launcher/src/main.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/>. +#![allow(clippy::upper_case_acronyms)] #![deny( clippy::unwrap_used, missing_debug_implementations, diff --git a/rust-libs/dubp-wot/src/lib.rs b/rust-libs/dubp-wot/src/lib.rs index 29fb11e06746a49254834abc39736d22b0f12c2b..dbfc71b4b46e4801c83cbe4d777815436691678f 100644 --- a/rust-libs/dubp-wot/src/lib.rs +++ b/rust-libs/dubp-wot/src/lib.rs @@ -67,7 +67,7 @@ mod tests { fn write_bin_file(file_path: &Path, datas: &[u8]) -> Result<(), std::io::Error> { let mut file = std::fs::File::create(file_path)?; - file.write_all(&datas[..])?; + file.write_all(datas)?; Ok(()) } diff --git a/rust-libs/duniter-bc-reader/src/lib.rs b/rust-libs/duniter-bc-reader/src/lib.rs index 68ae0c41f4ce6aedac481819775e2b5b927e7dc9..222795751ff43113b9d185c767179e020887eac2 100644 --- a/rust-libs/duniter-bc-reader/src/lib.rs +++ b/rust-libs/duniter-bc-reader/src/lib.rs @@ -26,5 +26,5 @@ use dubp::crypto::hashs::Hash; use duniter_dbs::{databases::bc_v2::BcV2DbReadable, kv_typed::prelude::*, HashKeyV2}; pub fn tx_exist<BcDb: BcV2DbReadable>(bc_db_ro: &BcDb, hash: Hash) -> KvResult<bool> { - Ok(bc_db_ro.txs_hashs().contains_key(&HashKeyV2(hash))?) + bc_db_ro.txs_hashs().contains_key(&HashKeyV2(hash)) } diff --git a/rust-libs/duniter-dbs/src/lib.rs b/rust-libs/duniter-dbs/src/lib.rs index 048cade01e04b3b134def393e7adc944996db023..9b4229e9109494a583bfb6547e78212009f4e0e0 100644 --- a/rust-libs/duniter-dbs/src/lib.rs +++ b/rust-libs/duniter-dbs/src/lib.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/>. +#![allow(clippy::upper_case_acronyms)] #![deny( clippy::unwrap_used, missing_copy_implementations, diff --git a/rust-libs/duniter-dbs/src/values/block_db.rs b/rust-libs/duniter-dbs/src/values/block_db.rs index d106801bec3948c92ca35f461f55d4b019a40e1a..c288cda97974ec5f519938f1b5bc76a813f8cdd7 100644 --- a/rust-libs/duniter-dbs/src/values/block_db.rs +++ b/rust-libs/duniter-dbs/src/values/block_db.rs @@ -76,8 +76,8 @@ impl kv_typed::prelude::FromBytes for BlockDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } @@ -131,8 +131,7 @@ impl kv_typed::prelude::FromBytes for BlockDbV2 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } @@ -145,7 +144,7 @@ impl ToDumpString for BlockDbV2 { #[cfg(feature = "explorer")] impl ExplorableValue for BlockDbV2 { fn from_explorer_str(source: &str) -> Result<Self, FromExplorerValueErr> { - Ok(serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))?) + serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into())) } fn to_explorer_json(&self) -> KvResult<serde_json::Value> { serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into())) diff --git a/rust-libs/duniter-dbs/src/values/block_head_db.rs b/rust-libs/duniter-dbs/src/values/block_head_db.rs index 73601c00714446e6c307eeb533474a81c170fceb..97c3f6a04481fe4aad4bb1fe7e7bcbd431896835 100644 --- a/rust-libs/duniter-dbs/src/values/block_head_db.rs +++ b/rust-libs/duniter-dbs/src/values/block_head_db.rs @@ -63,8 +63,8 @@ impl kv_typed::prelude::FromBytes for BlockHeadDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/block_meta.rs b/rust-libs/duniter-dbs/src/values/block_meta.rs index 7c23377cbf8074dc584b296d60b8e741793b6700..949a644d963971933e917f129aa9adb09dcd9f30 100644 --- a/rust-libs/duniter-dbs/src/values/block_meta.rs +++ b/rust-libs/duniter-dbs/src/values/block_meta.rs @@ -62,7 +62,7 @@ impl kv_typed::prelude::FromBytes for BlockMetaV2 { type Err = bincode::Error; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(bytes)?) + bincode::deserialize(bytes) } } @@ -75,8 +75,8 @@ impl ToDumpString for BlockMetaV2 { #[cfg(feature = "explorer")] impl ExplorableValue for BlockMetaV2 { fn from_explorer_str(json_str: &str) -> std::result::Result<Self, FromExplorerValueErr> { - Ok(serde_json::from_str(&json_str) - .map_err(|e| FromExplorerValueErr(format!("{}: '{}'", e, json_str).into()))?) + serde_json::from_str(&json_str) + .map_err(|e| FromExplorerValueErr(format!("{}: '{}'", e, json_str).into())) } fn to_explorer_json(&self) -> KvResult<serde_json::Value> { serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into())) diff --git a/rust-libs/duniter-dbs/src/values/block_number_array_db.rs b/rust-libs/duniter-dbs/src/values/block_number_array_db.rs index 8a11d2d73a2e401bbfd8550ca2f01706c46d9f16..e4b5f0c36a7363ea613219cd27e45a35c60f2fd6 100644 --- a/rust-libs/duniter-dbs/src/values/block_number_array_db.rs +++ b/rust-libs/duniter-dbs/src/values/block_number_array_db.rs @@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for BlockNumberArrayV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); //println!("json_str='{}'", &json_str); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/cindex_db.rs b/rust-libs/duniter-dbs/src/values/cindex_db.rs index 20f1a75038a699a5cc136edd4ee0029f1e700fd1..ded4657e56e00a9d7bee54458e0047a8b4ab03f7 100644 --- a/rust-libs/duniter-dbs/src/values/cindex_db.rs +++ b/rust-libs/duniter-dbs/src/values/cindex_db.rs @@ -34,8 +34,8 @@ impl kv_typed::prelude::FromBytes for CIndexDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); //println!("json_str='{}'", &json_str); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/dunp_head.rs b/rust-libs/duniter-dbs/src/values/dunp_head.rs index d977f52bf4c0dc8e6c5bc57f4657df5aee8eefbd..bf42b21a41f07c1d83f67af91c14dda2ff72ddaa 100644 --- a/rust-libs/duniter-dbs/src/values/dunp_head.rs +++ b/rust-libs/duniter-dbs/src/values/dunp_head.rs @@ -103,8 +103,7 @@ impl kv_typed::prelude::FromBytes for DunpHeadDbV1 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } diff --git a/rust-libs/duniter-dbs/src/values/idty_db.rs b/rust-libs/duniter-dbs/src/values/idty_db.rs index 284d81474fdd2a133c45e2b7c4c59ae667e023d7..504f79950fb8b96cda2b12d5af30923ac0110c46 100644 --- a/rust-libs/duniter-dbs/src/values/idty_db.rs +++ b/rust-libs/duniter-dbs/src/values/idty_db.rs @@ -31,7 +31,7 @@ impl kv_typed::prelude::FromBytes for IdtyDbV2 { type Err = bincode::Error; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(bytes)?) + bincode::deserialize(bytes) } } diff --git a/rust-libs/duniter-dbs/src/values/iindex_db.rs b/rust-libs/duniter-dbs/src/values/iindex_db.rs index 337dd6891c004d9d960bef9416151264f042c47c..947494fbd0400b35297077a1495fcd0b72c0929f 100644 --- a/rust-libs/duniter-dbs/src/values/iindex_db.rs +++ b/rust-libs/duniter-dbs/src/values/iindex_db.rs @@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for IIndexDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); //println!("json_str='{}'", &json_str); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/kick_db.rs b/rust-libs/duniter-dbs/src/values/kick_db.rs index af8047750a4ec54ff80932304c138b3015f5e541..b616cdc756df211726b08bd413a00508a975c829 100644 --- a/rust-libs/duniter-dbs/src/values/kick_db.rs +++ b/rust-libs/duniter-dbs/src/values/kick_db.rs @@ -33,8 +33,8 @@ impl kv_typed::prelude::FromBytes for KickDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/mindex_db.rs b/rust-libs/duniter-dbs/src/values/mindex_db.rs index 0f9727b6580bf603802d5d6c38c387f26fd839fe..eb7d42a35d5471c7dc93e5f73f6c78a929d7378b 100644 --- a/rust-libs/duniter-dbs/src/values/mindex_db.rs +++ b/rust-libs/duniter-dbs/src/values/mindex_db.rs @@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for MIndexDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); //println!("json_str='{}'", &json_str); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/peer_card.rs b/rust-libs/duniter-dbs/src/values/peer_card.rs index 1ab3665d52e4fc1b7f4ea9c29a66c0766a477b71..ee08696d7a9afd211e75c4ba62ef9fed8673c810 100644 --- a/rust-libs/duniter-dbs/src/values/peer_card.rs +++ b/rust-libs/duniter-dbs/src/values/peer_card.rs @@ -37,8 +37,7 @@ impl kv_typed::prelude::FromBytes for PeerCardDbV1 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } diff --git a/rust-libs/duniter-dbs/src/values/sindex_db.rs b/rust-libs/duniter-dbs/src/values/sindex_db.rs index 5b8676a0abce3ea8563817517faffa14ee73e516..4d5b9f20477d171e9f96bce5a6fc3a9a4cc16b63 100644 --- a/rust-libs/duniter-dbs/src/values/sindex_db.rs +++ b/rust-libs/duniter-dbs/src/values/sindex_db.rs @@ -54,8 +54,8 @@ impl kv_typed::prelude::FromBytes for SIndexDBV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/tx_db.rs b/rust-libs/duniter-dbs/src/values/tx_db.rs index f5009f85fbffca986f98bd366a0c965095a78196..bcc06d1499ff269ed83624dd2d2fcaacd2d031c0 100644 --- a/rust-libs/duniter-dbs/src/values/tx_db.rs +++ b/rust-libs/duniter-dbs/src/values/tx_db.rs @@ -30,8 +30,7 @@ impl kv_typed::prelude::FromBytes for PendingTxDbV2 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } diff --git a/rust-libs/duniter-dbs/src/values/txs.rs b/rust-libs/duniter-dbs/src/values/txs.rs index 7ca96cc1b446c5197aed1c76a211fba8a949dd34..f150673ef91757568e6420cf52db7af5f5c58a41 100644 --- a/rust-libs/duniter-dbs/src/values/txs.rs +++ b/rust-libs/duniter-dbs/src/values/txs.rs @@ -30,8 +30,7 @@ impl kv_typed::prelude::FromBytes for BlockTxsDbV2 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } @@ -44,7 +43,7 @@ impl ToDumpString for BlockTxsDbV2 { #[cfg(feature = "explorer")] impl ExplorableValue for BlockTxsDbV2 { fn from_explorer_str(source: &str) -> Result<Self, FromExplorerValueErr> { - Ok(serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))?) + serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into())) } fn to_explorer_json(&self) -> KvResult<serde_json::Value> { serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into())) diff --git a/rust-libs/duniter-dbs/src/values/ud_entry_db.rs b/rust-libs/duniter-dbs/src/values/ud_entry_db.rs index a632580f97f00e88a5ce9bb3da23d2ef60ae8f8c..a32efd7749840ca136c10d38b214391252c09050 100644 --- a/rust-libs/duniter-dbs/src/values/ud_entry_db.rs +++ b/rust-libs/duniter-dbs/src/values/ud_entry_db.rs @@ -40,8 +40,8 @@ impl kv_typed::prelude::FromBytes for UdEntryDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/utxo.rs b/rust-libs/duniter-dbs/src/values/utxo.rs index c76a958782359160ad5aad7975a4ccdb50e3be0a..dc5b60e56de686fd24aa56d376df211f82a80392 100644 --- a/rust-libs/duniter-dbs/src/values/utxo.rs +++ b/rust-libs/duniter-dbs/src/values/utxo.rs @@ -121,7 +121,7 @@ impl kv_typed::prelude::FromBytes for BlockUtxosV2Db { type Err = bincode::Error; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(bytes)?) + bincode::deserialize(bytes) } } @@ -137,7 +137,7 @@ impl ExplorableValue for BlockUtxosV2Db { unimplemented!() } fn to_explorer_json(&self) -> KvResult<serde_json::Value> { - Ok(serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into()))?) + serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into())) } } diff --git a/rust-libs/duniter-dbs/src/values/wallet_db.rs b/rust-libs/duniter-dbs/src/values/wallet_db.rs index 80624be95c18f790ab53989503341840bf1ea236..465346100ea9beab5c79e3a67f2677c44b69d960 100644 --- a/rust-libs/duniter-dbs/src/values/wallet_db.rs +++ b/rust-libs/duniter-dbs/src/values/wallet_db.rs @@ -33,8 +33,8 @@ impl kv_typed::prelude::FromBytes for WalletDbV1 { fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes"); - Ok(serde_json::from_str(&json_str) - .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?) + serde_json::from_str(&json_str) + .map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str))) } } diff --git a/rust-libs/duniter-dbs/src/values/wallet_script_with_sa.rs b/rust-libs/duniter-dbs/src/values/wallet_script_with_sa.rs index 03f2105df5e5458afbb6bcb1c2720da12d5db8ea..5d40dd95a54b1c3497008040219cfdfd1c09b6d7 100644 --- a/rust-libs/duniter-dbs/src/values/wallet_script_with_sa.rs +++ b/rust-libs/duniter-dbs/src/values/wallet_script_with_sa.rs @@ -47,6 +47,6 @@ impl ExplorableValue for WalletScriptWithSourceAmountV1Db { unimplemented!() } fn to_explorer_json(&self) -> KvResult<serde_json::Value> { - Ok(serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into()))?) + serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into())) } } diff --git a/rust-libs/modules/gva/bca/src/exec_req_type.rs b/rust-libs/modules/gva/bca/src/exec_req_type.rs index b5b75d083e41bc6d27cb82633f75b506468e566a..6a4b226c71e8006d7b395f1b3f24ee025380ec24 100644 --- a/rust-libs/modules/gva/bca/src/exec_req_type.rs +++ b/rust-libs/modules/gva/bca/src/exec_req_type.rs @@ -69,5 +69,26 @@ pub(super) async fn execute_req_type( }), BcaReqTypeV0::Ping => Ok(BcaRespTypeV0::Pong), BcaReqTypeV0::SendTxs(txs) => send_txs::send_txs(bca_executor, txs).await, + BcaReqTypeV0::Identities(pubkeys) => { + let dbs_reader = bca_executor.dbs_reader(); + Ok(BcaRespTypeV0::Identities( + bca_executor + .dbs_pool + .execute(move |dbs| { + pubkeys + .into_iter() + .map(|pubkey| { + dbs_reader.idty(&dbs.bc_db_ro, pubkey).map(|idty_opt| { + idty_opt.map(|idty| Identity { + is_member: idty.is_member, + username: idty.username, + }) + }) + }) + .collect::<KvResult<ArrayVec<_>>>() + }) + .await??, + )) + } } } diff --git a/rust-libs/modules/gva/bca/src/lib.rs b/rust-libs/modules/gva/bca/src/lib.rs index b1a1dc1a502fe5cc19f67a409b6c9e8b10aab917..0ac1a1c9f7db726ed1e88c84644f78a32aef7f58 100644 --- a/rust-libs/modules/gva/bca/src/lib.rs +++ b/rust-libs/modules/gva/bca/src/lib.rs @@ -37,8 +37,8 @@ use async_io_stream::IoStream; use bincode::Options as _; use dubp::crypto::keys::{ed25519::Ed25519KeyPair, Signator}; use duniter_bca_types::{ - amount::Amount, bincode_opts, BcaReq, BcaReqExecError, BcaReqTypeV0, BcaResp, BcaRespTypeV0, - BcaRespV0, + amount::Amount, bincode_opts, identity::Identity, BcaReq, BcaReqExecError, BcaReqTypeV0, + BcaResp, BcaRespTypeV0, BcaRespV0, }; pub use duniter_dbs::kv_typed::prelude::*; use duniter_dbs::{FileBackend, SharedDbs}; diff --git a/rust-libs/modules/gva/bca/types/src/identity.rs b/rust-libs/modules/gva/bca/types/src/identity.rs new file mode 100644 index 0000000000000000000000000000000000000000..e2302a9bfa7d9520b4a5b41831ff987276776ed8 --- /dev/null +++ b/rust-libs/modules/gva/bca/types/src/identity.rs @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Éloïs SANCHEZ. +// +// 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/>. + +use crate::*; + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct Identity { + pub is_member: bool, + pub username: String, +} diff --git a/rust-libs/modules/gva/bca/types/src/lib.rs b/rust-libs/modules/gva/bca/types/src/lib.rs index 8c9f84501b69ce562c1c7403904c01c2df29959c..4182fb555e9fae5c6c3095c59660a50500d8bd78 100644 --- a/rust-libs/modules/gva/bca/types/src/lib.rs +++ b/rust-libs/modules/gva/bca/types/src/lib.rs @@ -23,11 +23,13 @@ )] pub mod amount; +pub mod identity; pub mod prepare_payment; pub mod rejected_tx; pub mod utxo; use crate::amount::Amount; +use crate::identity::Identity; use crate::prepare_payment::{PrepareSimplePayment, PrepareSimplePaymentResp}; use crate::utxo::Utxo; @@ -74,6 +76,7 @@ pub enum BcaReqTypeV0 { }, Ping, SendTxs(Txs), + Identities(ArrayVec<[PublicKey; 16]>), } // Request types helpers @@ -110,6 +113,7 @@ pub enum BcaRespTypeV0 { PrepareSimplePayment(PrepareSimplePaymentResp), Pong, RejectedTxs(Vec<rejected_tx::RejectedTx>), + Identities(ArrayVec<[Option<Identity>; 16]>), } // Result and error diff --git a/rust-libs/modules/gva/db/src/values/gva_idty_db.rs b/rust-libs/modules/gva/db/src/values/gva_idty_db.rs index df6966b78328a5b54a793654705499e57fa3b764..9bb918af86985f2ec7bd0d589404916cc01476be 100644 --- a/rust-libs/modules/gva/db/src/values/gva_idty_db.rs +++ b/rust-libs/modules/gva/db/src/values/gva_idty_db.rs @@ -33,7 +33,7 @@ impl kv_typed::prelude::FromBytes for GvaIdtyDbV1 { type Err = bincode::Error; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(bytes)?) + bincode::deserialize(bytes) } } diff --git a/rust-libs/modules/gva/db/src/values/gva_tx.rs b/rust-libs/modules/gva/db/src/values/gva_tx.rs index 5bb8deaf788084455c820ee571055eb652edbeb2..258fae77c228769021c44f7c0dd1357ef4d33977 100644 --- a/rust-libs/modules/gva/db/src/values/gva_tx.rs +++ b/rust-libs/modules/gva/db/src/values/gva_tx.rs @@ -35,8 +35,7 @@ impl kv_typed::prelude::FromBytes for GvaTxDbV1 { type Err = CorruptedBytes; fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> { - Ok(bincode::deserialize(&bytes) - .map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?) + bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes))) } } diff --git a/rust-libs/tools/kv_typed/src/lib.rs b/rust-libs/tools/kv_typed/src/lib.rs index 35ff39a9730c1a26e4d422811b819779bb51c630..b2487256d0b82c087994f9be3e99a1d18a5d0ebf 100644 --- a/rust-libs/tools/kv_typed/src/lib.rs +++ b/rust-libs/tools/kv_typed/src/lib.rs @@ -15,6 +15,7 @@ //! Strongly typed key-value storage +#![allow(clippy::upper_case_acronyms, clippy::from_over_into)] #![deny( clippy::unwrap_used, missing_copy_implementations,