Skip to content

Commit

Permalink
node: fix clippy use
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Dec 2, 2023
1 parent 3feaff3 commit d23da88
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 107 deletions.
23 changes: 5 additions & 18 deletions node/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,24 @@ mod fallback;
mod fsm;
mod genesis;

use crate::database::{Candidate, Ledger, Mempool};
use crate::database::Ledger;
use crate::{database, vm, Network};
use crate::{LongLivedService, Message};
use anyhow::{anyhow, bail, Result};
use anyhow::Result;

use dusk_consensus::user::committee::CommitteeSet;
use std::rc::Rc;
use std::sync::Arc;
use tracing::{debug, error, info, warn};
use tracing::{error, info, warn};

use async_trait::async_trait;
use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate};
use dusk_consensus::consensus::Consensus;
use dusk_consensus::contract_state::{
CallParams, Error, Operations, Output, StateRoot,
};
use dusk_consensus::user::provisioners::Provisioners;
use node_data::ledger::{self, to_str, Block, Hash, Header};
use node_data::ledger::{to_str, Block};
use node_data::message::AsyncQueue;
use node_data::message::{Payload, Topics};
use node_data::Serializable;
use tokio::sync::{oneshot, Mutex, RwLock};
use tokio::task::JoinHandle;
use tokio::sync::RwLock;
use tokio::time::{sleep_until, Instant};

use node_data::message::payload::GetBlocks;
use std::any;
use std::time::Duration;

use self::acceptor::{Acceptor, RevertTarget};
use self::consensus::Task;
use self::fsm::SimpleFSM;

pub use acceptor::verify_block_cert;
Expand Down
31 changes: 7 additions & 24 deletions node/src/chain/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,26 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::database::{Candidate, Ledger, Mempool};
use crate::{database, vm, Network};
use crate::{LongLivedService, Message};
use anyhow::{anyhow, bail, Result};
use async_trait::async_trait;
use dusk_bls12_381_sign::PublicKey;
use dusk_consensus::commons::{
ConsensusError, Database, IterCounter, RoundUpdate, StepName,
};
use dusk_consensus::consensus::{self, Consensus};
use dusk_consensus::contract_state::{
CallParams, Error, Operations, Output, StateRoot,
};
use crate::database::{self, Ledger, Mempool};
use crate::{vm, Message, Network};
use anyhow::{anyhow, Result};
use dusk_consensus::commons::{ConsensusError, IterCounter, StepName};
use dusk_consensus::user::committee::{Committee, CommitteeSet};
use dusk_consensus::user::provisioners::Provisioners;
use dusk_consensus::user::sortition;
use hex::ToHex;
use node_data::ledger::{
self, to_str, Block, Hash, Header, Seed, Signature, SpentTransaction,
self, to_str, Block, Seed, Signature, SpentTransaction,
};
use node_data::message::AsyncQueue;
use node_data::message::{Payload, Topics};
use node_data::Serializable;
use std::cell::RefCell;
use std::rc::Rc;
use node_data::message::Payload;
use std::sync::Arc;
use tokio::sync::{oneshot, Mutex, RwLock};
use tokio::task::JoinHandle;
use tokio::sync::{Mutex, RwLock};
use tracing::{error, info, warn};

use dusk_consensus::agreement::verifiers;
use dusk_consensus::config::{self, SELECTION_COMMITTEE_SIZE};
use std::any;
use std::collections::HashMap;

use super::consensus::Task;
use super::genesis;

pub(crate) enum RevertTarget {
LastFinalizedState = 0,
Expand Down
16 changes: 6 additions & 10 deletions node/src/chain/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,24 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::database::{Candidate, Ledger, Mempool};
use crate::{database, vm, Network};
use crate::{LongLivedService, Message};
use anyhow::bail;
use crate::database::{self, Candidate, Mempool};
use crate::{vm, Message, Network};
use async_trait::async_trait;
use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate};
use dusk_consensus::commons::{ConsensusError, RoundUpdate};
use dusk_consensus::consensus::Consensus;
use dusk_consensus::contract_state::{
CallParams, Error, Operations, Output, StateRoot, VerificationOutput,
CallParams, Error, Operations, Output, VerificationOutput,
};
use dusk_consensus::user::provisioners::Provisioners;
use node_data::ledger::{Block, Hash, Transaction};
use node_data::message::payload::{self, GetCandidate};
use node_data::message::payload::GetCandidate;
use node_data::message::AsyncQueue;
use node_data::message::{Payload, Topics};
use node_data::Serializable;
use tokio::sync::{oneshot, Mutex, RwLock};
use tokio::task::JoinHandle;
use tracing::{error, info, trace};
use tracing::{error, info, trace, warn};

use std::sync::Arc;
use std::{any, vec};

/// Consensus Service Task is responsible for running the consensus layer.
///
Expand Down
14 changes: 4 additions & 10 deletions node/src/chain/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::sync::Arc;

use anyhow::{anyhow, bail, Result};
use node_data::{
bls::PublicKey,
ledger::{self, Block, Hash, Header},
};
use tokio::sync::RwLock;
use tracing::{info, warn};
use anyhow::{anyhow, Result};
use node_data::ledger::Block;
use tracing::info;

use crate::{
chain::acceptor,
database::{self, Ledger, Mempool},
database::{self, Ledger},
vm, Network,
};

Expand Down
10 changes: 4 additions & 6 deletions node/src/chain/fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use super::{acceptor::Acceptor, consensus, genesis};
use super::acceptor::Acceptor;
use crate::chain::fallback;
use crate::database::{self, Ledger};
use crate::database;
use crate::{vm, Network};
use dusk_consensus::user::provisioners::{self, Provisioners};
use node_data::ledger::{self, to_str, Block, Hash, Transaction};
use node_data::ledger::{to_str, Block};
use node_data::message::payload::GetBlocks;
use node_data::message::Message;
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use std::ops::Deref;
use std::time::Duration;
use std::{sync::Arc, time::SystemTime};
use tokio::sync::RwLock;
use tracing::{debug, error, info};
use tracing::{error, info, warn};

const MAX_BLOCKS_TO_REQUEST: i16 = 50;
const EXPIRY_TIMEOUT_MILLIS: i16 = 5000;
Expand Down
1 change: 0 additions & 1 deletion node/src/chain/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_consensus::user::provisioners::Provisioners;
use node_data::ledger::{Block, Header};

/// Generates the genesis state for the chain per specified network type
Expand Down
15 changes: 4 additions & 11 deletions node/src/database/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,26 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use super::{Candidate, Ledger, Persist, Register, DB};
use anyhow::{Context, Result};
use anyhow::Result;

use node_data::encoding::*;
use node_data::ledger::{self, SpentTransaction};
use node_data::Serializable;

use crate::database::Mempool;

use dusk_bytes::Serializable as DuskBytesSerializable;

use rocksdb_lib::{
ColumnFamily, ColumnFamilyDescriptor, DBAccess, DBCommon,
DBRawIteratorWithThreadMode, DBWithThreadMode, IteratorMode, MultiThreaded,
OptimisticTransactionDB, OptimisticTransactionOptions, Options,
ReadOptions, SnapshotWithThreadMode, Transaction, TransactionDB,
ColumnFamily, ColumnFamilyDescriptor, DBAccess,
DBRawIteratorWithThreadMode, IteratorMode, OptimisticTransactionDB,
OptimisticTransactionOptions, Options, SnapshotWithThreadMode, Transaction,
WriteOptions,
};

use std::io;
use std::io::Read;
use std::io::Write;
use std::marker::PhantomData;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use std::vec;
use tokio::io::AsyncWriteExt;

use tracing::info;

Expand Down
22 changes: 5 additions & 17 deletions node/src/databroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,18 @@ pub mod conf;
use crate::database::{Candidate, Ledger, Mempool};
use crate::{database, vm, Network};
use crate::{LongLivedService, Message};
use anyhow::{anyhow, bail, Result};
use anyhow::{anyhow, Result};

use dusk_consensus::user::committee::CommitteeSet;
use node_data::message::payload::InvType;
use smallvec::SmallVec;
use std::net::SocketAddr;
use std::sync::Arc;

use async_trait::async_trait;
use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate};
use dusk_consensus::consensus::Consensus;
use dusk_consensus::contract_state::{
CallParams, Error, Operations, Output, StateRoot,
};
use dusk_consensus::user::provisioners::Provisioners;
use node_data::ledger::{self, Block, Hash, Header};
use node_data::message::{self, Payload, Topics};
use node_data::message::{payload, AsyncQueue, Metadata};
use node_data::Serializable;
use tokio::sync::{oneshot, Mutex, RwLock, Semaphore};
use tokio::task::JoinHandle;
use tracing::{debug, info, trace, warn};

use std::any;
use node_data::message::{payload, AsyncQueue};
use node_data::message::{Payload, Topics};
use tokio::sync::{RwLock, Semaphore};
use tracing::{info, warn};

const TOPICS: &[u8] = &[
Topics::GetBlocks as u8,
Expand Down
8 changes: 3 additions & 5 deletions node/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

use crate::database::{Ledger, Mempool};
use crate::{database, vm, LongLivedService, Message, Network};
use anyhow::{anyhow, bail};
use anyhow::anyhow;
use async_trait::async_trait;
use dusk_bytes::Serializable;
use node_data::ledger::Transaction;
use node_data::message::AsyncQueue;
use node_data::message::Payload;
use node_data::message::Topics;
use node_data::message::{AsyncQueue, Payload, Topics};
use std::sync::Arc;
use tokio::sync::RwLock;
use tracing::warn;

const TOPICS: &[u8] = &[Topics::Tx as u8];

Expand Down
5 changes: 2 additions & 3 deletions node/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::net::{IpAddr, SocketAddr};
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;
use std::{any, default};

use crate::{BoxedFilter, Message};
use async_trait::async_trait;
Expand All @@ -18,7 +17,7 @@ use node_data::message::{AsyncQueue, Topics};
use std::sync::atomic::{AtomicU64, Ordering};
use tokio::sync::RwLock;
use tokio::time::{self, Instant};
use tracing::{debug, error, info, trace};
use tracing::{error, info, trace};

mod frame;

Expand Down
2 changes: 0 additions & 2 deletions node/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use async_trait::async_trait;
use dusk_bls12_381_sign::PublicKey as BlsPublicKey;
use dusk_consensus::{
contract_state::CallParams, contract_state::VerificationOutput,
user::provisioners::Provisioners,
Expand Down

0 comments on commit d23da88

Please sign in to comment.