skoupidi 1 anno fa
parent
commit
902620de22

+ 1 - 1
bin/darkfid/src/lib.rs

@@ -139,7 +139,7 @@ impl Darkfid {
     ) -> Result<DarkfidPtr> {
         info!(target: "darkfid::Darkfid::init", "Initializing a Darkfi daemon...");
         // Initialize validator
-        let validator = Validator::new(&sled_db, config).await?;
+        let validator = Validator::new(sled_db, config).await?;
 
         // Initialize P2P network
         let p2p_handler = DarkfidP2pHandler::init(net_settings, ex).await?;

+ 1 - 1
src/contract/dao/src/lib.rs

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-//! Smart contract implementing Anonymous DAOs on DarkFi
+//! Smart contract implementing Anonymous DAOs on DarkFi.
 
 use darkfi_sdk::error::ContractError;
 

+ 0 - 1
src/contract/dao/src/model.rs

@@ -310,7 +310,6 @@ pub struct DaoVoteParamsInput {
     pub signature_public: PublicKey,
 }
 // ANCHOR_END: dao-vote-params-input
-/// Input for a DAO proposal vote
 
 /// State update for `Dao::Vote`
 #[derive(Debug, Clone, SerialEncodable, SerialDecodable)]

+ 1 - 5
src/event_graph/tests.rs

@@ -154,11 +154,7 @@ async fn bootstrap_nodes(
     eg_instances
 }
 
-async fn assert_dags(
-    eg_instances: &Vec<Arc<EventGraph>>,
-    expected_len: usize,
-    rng: &mut ThreadRng,
-) {
+async fn assert_dags(eg_instances: &[Arc<EventGraph>], expected_len: usize, rng: &mut ThreadRng) {
     let random_node = eg_instances.choose(rng).unwrap();
     let last_layer_tips =
         random_node.unreferenced_tips.read().await.last_key_value().unwrap().1.clone();

+ 1 - 1
src/event_graph/util.rs

@@ -80,7 +80,7 @@ pub fn next_rotation_timestamp(starting_timestamp: u64, rotation_period: u64) ->
     // Find out how many rotation periods have occurred since
     // the starting point.
     // Note: when rotation_period = 1, rotations_since_start = days_passed
-    let rotations_since_start = (days_passed + rotation_period - 1) / rotation_period;
+    let rotations_since_start = days_passed.div_ceil(rotation_period);
 
     // Find out the number of days until the next rotation. Panic if result is beyond the range
     // of i64.

+ 2 - 2
src/net/hosts.rs

@@ -83,7 +83,7 @@ use crate::{
 ///
 ///  TODO: Use HostState::Free `age` variable to implement a pruning logic that deletes peers from
 ///  the registry once they have bypassed a certain age threshold.
-
+///
 // An array containing all possible local host strings
 // TODO: This could perhaps be more exhaustive?
 pub const LOCAL_HOST_STRS: [&str; 2] = ["localhost", "localhost.localdomain"];
@@ -830,7 +830,7 @@ impl HostContainer {
             }
         }
 
-        if !tsv.eq("") {
+        if !tsv.is_empty() {
             info!(target: "net::hosts::save_hosts()", "Saving hosts to: {:?}",
                   path);
             if let Err(e) = save_file(&path, &tsv) {

+ 1 - 1
src/net/tests.rs

@@ -182,7 +182,7 @@ async fn get_random_gold_host(
     (entry.clone(), position)
 }
 
-async fn _check_random_hostlist(outbound_instances: &Vec<Arc<P2p>>, rng: &mut ThreadRng) {
+async fn _check_random_hostlist(outbound_instances: &[Arc<P2p>], rng: &mut ThreadRng) {
     let mut urls = HashSet::new();
     let random_node = outbound_instances.choose(rng).unwrap();
     let external_addr = random_node.settings().read().await.external_addrs[0].clone();

+ 0 - 1
src/net/transport/mod.rs

@@ -200,7 +200,6 @@ impl Dialer {
     }
 
     /// Dial an instantiated [`Dialer`]. This creates a connection and returns a stream.
-
     /// The Tor-based Dialer variants can panic: this is intended. There exists validation
     /// for hosts and ports in other parts of the codebase. A panic occurring here
     /// likely indicates a configuration issue on the part of the user. It is preferable

+ 1 - 1
src/sdk/python/src/zkas.rs

@@ -83,7 +83,7 @@ impl ZkBinary {
     }
 
     fn opcodes(&self) -> Vec<ZkOpcode> {
-        return self.0.opcodes.iter().map(|op| ZkOpcode(op.0)).collect()
+        self.0.opcodes.iter().map(|op| ZkOpcode(op.0)).collect()
     }
 }
 

+ 2 - 4
src/sdk/src/crypto/constants/fixed_bases.rs

@@ -58,12 +58,10 @@ pub const FIXED_BASE_WINDOW_SIZE: usize = 3;
 pub const H: usize = 1 << FIXED_BASE_WINDOW_SIZE;
 
 /// Number of windows for a full-width scalar
-pub const NUM_WINDOWS: usize =
-    (L_ORCHARD_SCALAR + FIXED_BASE_WINDOW_SIZE - 1) / FIXED_BASE_WINDOW_SIZE;
+pub const NUM_WINDOWS: usize = L_ORCHARD_SCALAR.div_ceil(FIXED_BASE_WINDOW_SIZE);
 
 /// Number of windows for a short signed scalar
-pub const NUM_WINDOWS_SHORT: usize =
-    (L_VALUE + FIXED_BASE_WINDOW_SIZE - 1) / FIXED_BASE_WINDOW_SIZE;
+pub const NUM_WINDOWS_SHORT: usize = L_VALUE.div_ceil(FIXED_BASE_WINDOW_SIZE);
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 // A sum type for both full-width and short bases. This enables us to use the