skoupidi 1 год назад
Родитель
Сommit
6392bc73b0

+ 1 - 4
bin/darkirc/src/crypto/saltbox.rs

@@ -55,8 +55,5 @@ pub fn try_decrypt(salt_box: &ChaChaBox, ciphertext: &[u8]) -> Option<Vec<u8>> {
         return None
     }
 
-    match salt_box.decrypt((&ciphertext[0..24]).into(), &ciphertext[24..]) {
-        Ok(v) => Some(v),
-        Err(_) => None,
-    }
+    salt_box.decrypt((&ciphertext[0..24]).into(), &ciphertext[24..]).ok()
 }

+ 1 - 1
bin/darkirc/src/irc/client.rs

@@ -270,7 +270,7 @@ impl Client {
                         let (event, blob) = (r.clone(), vec![0,1,2]);
                         let (proof, public_inputs): (Proof, Vec<pallas::Base>) = match deserialize_async(&blob).await {
                             Ok(v) => v,
-                            Err(e) => {
+                            Err(_) => {
                                 // TODO: FIXME: This logic should be better written.
                                 // Right now we don't enforce RLN so we can just fall-through.
                                 //error!("[IRC CLIENT] Failed deserializing event ephemeral data: {}", e);

+ 1 - 1
bin/drk/src/main.rs

@@ -1738,7 +1738,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 drk.stop_rpc_client().await
             }
 
-            DaoSubcmd::ProposalImport {} => {
+            DaoSubcmd::ProposalImport => {
                 let mut buf = String::new();
                 stdin().read_to_string(&mut buf)?;
                 let Some(bytes) = base64::decode(buf.trim()) else {

+ 3 - 3
src/contract/money/src/client/transfer_v1/mod.rs

@@ -73,15 +73,15 @@ pub fn select_coins(coins: Vec<OwnCoin>, min_value: u64) -> Result<(Vec<OwnCoin>
 /// * `coins`: Set of `OwnCoin` we're given to use in this builder
 /// * `tree`: Merkle tree of coins used to create inclusion proofs
 /// * `output_spend_hook: Optional contract spend hook to use in
-///    the output, not applicable to the change
+///   the output, not applicable to the change
 /// * `output_user_data: Optional user data to use in the output,
-///    not applicable to the change
+///   not applicable to the change
 /// * `mint_zkbin`: `Mint_V1` zkas circuit ZkBinary
 /// * `mint_pk`: Proving key for the `Mint_V1` zk circuit
 /// * `burn_zkbin`: `Burn_V1` zkas circuit ZkBinary
 /// * `burn_pk`: Proving key for the `Burn_V1` zk circuit
 /// * `half_split`: Flag indicating to split the output coin into
-///    two equal halves.
+///   two equal halves.
 ///
 /// Returns a tuple of:
 ///

+ 1 - 1
src/net/protocol/protocol_address.rs

@@ -299,7 +299,7 @@ impl ProtocolAddress {
         let version = channel.get_version();
         let discover_host = version.connect_recv_addr.host()?;
         // Check the reported address is Ipv6
-        let _ = match discover_host {
+        match discover_host {
             Host::Ipv6(_) => {}
             _ => return None,
         };

+ 3 - 3
src/util/encoding/base32.rs

@@ -26,7 +26,7 @@ const ENCODE_STD: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
 
 /// Encode a byte slice with the given base32 alphabet into a base32 string.
 pub fn encode(padding: bool, data: &[u8]) -> String {
-    let mut ret = Vec::with_capacity((data.len() + 3) / 4 * 5);
+    let mut ret = Vec::with_capacity(data.len().div_ceil(4) * 5);
 
     for chunk in data.chunks(5) {
         let buf = {
@@ -49,7 +49,7 @@ pub fn encode(padding: bool, data: &[u8]) -> String {
 
     if data.len() % 5 != 0 {
         let len = ret.len();
-        let num_extra = 8 - (data.len() % 5 * 8 + 4) / 5;
+        let num_extra = 8 - (data.len() % 5 * 8).div_ceil(5);
         if padding {
             for i in 1..num_extra + 1 {
                 ret[len - i] = b'=';
@@ -85,7 +85,7 @@ pub fn decode(data: &str) -> Option<Vec<u8>> {
     }
 
     let output_length = unpadded_data_len * 5 / 8;
-    let mut ret = Vec::with_capacity((output_length + 4) / 5 * 5);
+    let mut ret = Vec::with_capacity(output_length.div_ceil(5) * 5);
 
     for chunk in data.chunks(8) {
         let buf = {

+ 1 - 1
src/validator/pow.rs

@@ -190,7 +190,7 @@ impl PoWModule {
         let (cut_begin, cut_end) = if length <= RETAINED {
             (0, length)
         } else {
-            let cut_begin = (length - RETAINED + 1) / 2;
+            let cut_begin = (length - RETAINED).div_ceil(2);
             (cut_begin, cut_begin + RETAINED)
         };
         // Sanity check

+ 1 - 1
src/zk/gadget/native_range_check.rs

@@ -151,7 +151,7 @@ impl<const WINDOW_SIZE: usize, const NUM_BITS: usize> NativeRangeCheckChip<WINDO
             .to_le_bits()
             .into_iter()
             .take(NUM_BITS)
-            .chain(std::iter::repeat(false).take(WINDOW_SIZE - (NUM_BITS % WINDOW_SIZE)))
+            .chain(std::iter::repeat_n(false, WINDOW_SIZE - (NUM_BITS % WINDOW_SIZE)))
             .collect();
 
         bits.chunks_exact(WINDOW_SIZE)