Skip to content

Commit

Permalink
Fix all remaining clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
garious committed Jul 12, 2018
1 parent 3761d94 commit c2ca123
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 171 deletions.
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
too-many-arguments-threshold = 9
24 changes: 6 additions & 18 deletions benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,8 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {

let verified_setup_len = verified_setup.len();
verified_sender.send(verified_setup).unwrap();
BankingStage::process_packets(
bank.clone(),
&verified_receiver,
&signal_sender,
&packet_recycler,
).unwrap();
BankingStage::process_packets(&bank, &verified_receiver, &signal_sender, &packet_recycler)
.unwrap();

check_txs(verified_setup_len, &signal_receiver, num_src_accounts);

Expand All @@ -163,12 +159,8 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {

let verified_len = verified.len();
verified_sender.send(verified).unwrap();
BankingStage::process_packets(
bank.clone(),
&verified_receiver,
&signal_sender,
&packet_recycler,
).unwrap();
BankingStage::process_packets(&bank, &verified_receiver, &signal_sender, &packet_recycler)
.unwrap();

check_txs(verified_len, &signal_receiver, tx);
});
Expand Down Expand Up @@ -210,12 +202,8 @@ fn bench_banking_stage_single_from(bencher: &mut Bencher) {
.collect();
let verified_len = verified.len();
verified_sender.send(verified).unwrap();
BankingStage::process_packets(
bank.clone(),
&verified_receiver,
&signal_sender,
&packet_recycler,
).unwrap();
BankingStage::process_packets(&bank, &verified_receiver, &signal_sender, &packet_recycler)
.unwrap();

check_txs(verified_len, &signal_receiver, tx);
});
Expand Down
4 changes: 2 additions & 2 deletions src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl BankingStage {
.name("solana-banking-stage".to_string())
.spawn(move || loop {
if let Err(e) = Self::process_packets(
bank.clone(),
&bank.clone(),
&verified_receiver,
&signal_sender,
&packet_recycler,
Expand Down Expand Up @@ -72,7 +72,7 @@ impl BankingStage {
/// Process the incoming packets and send output `Signal` messages to `signal_sender`.
/// Discard packets via `packet_recycler`.
pub fn process_packets(
bank: Arc<Bank>,
bank: &Arc<Bank>,
verified_receiver: &Receiver<Vec<(SharedPackets, Vec<u8>)>>,
signal_sender: &Sender<Signal>,
packet_recycler: &PacketRecycler,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/client-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn converge(
let window = default_window();
let gossip_send_socket = udp_random_bind(8000, 10000, 5).unwrap();
let ncp = Ncp::new(
spy_ref.clone(),
&spy_ref.clone(),
window.clone(),
spy_gossip,
gossip_send_socket,
Expand Down
4 changes: 2 additions & 2 deletions src/blob_fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ impl BlobFetchStage {
pub fn new(
socket: UdpSocket,
exit: Arc<AtomicBool>,
blob_recycler: BlobRecycler,
blob_recycler: &BlobRecycler,
) -> (Self, BlobReceiver) {
Self::new_multi_socket(vec![socket], exit, blob_recycler)
}
pub fn new_multi_socket(
sockets: Vec<UdpSocket>,
exit: Arc<AtomicBool>,
blob_recycler: BlobRecycler,
blob_recycler: &BlobRecycler,
) -> (Self, BlobReceiver) {
let (blob_sender, blob_receiver) = channel();
let thread_hdls: Vec<_> = sockets
Expand Down
2 changes: 1 addition & 1 deletion src/drone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use transaction::Transaction;
pub const TIME_SLICE: u64 = 60;
pub const REQUEST_CAP: u64 = 1_000_000;

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
pub enum DroneRequest {
GetAirdrop {
airdrop_request_amount: u64,
Expand Down
4 changes: 2 additions & 2 deletions src/fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ impl FetchStage {
pub fn new(
socket: UdpSocket,
exit: Arc<AtomicBool>,
packet_recycler: PacketRecycler,
packet_recycler: &PacketRecycler,
) -> (Self, PacketReceiver) {
Self::new_multi_socket(vec![socket], exit, packet_recycler)
}
pub fn new_multi_socket(
sockets: Vec<UdpSocket>,
exit: Arc<AtomicBool>,
packet_recycler: PacketRecycler,
packet_recycler: &PacketRecycler,
) -> (Self, PacketReceiver) {
let (packet_sender, packet_receiver) = channel();
let thread_hdls: Vec<_> = sockets
Expand Down
14 changes: 7 additions & 7 deletions src/fullnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl FullNode {
entry_height,
Some(ledger_tail),
node,
network_entry_point,
&network_entry_point,
exit.clone(),
);
info!(
Expand Down Expand Up @@ -208,7 +208,7 @@ impl FullNode {
let bank = Arc::new(bank);
let mut thread_hdls = vec![];
let rpu = Rpu::new(
bank.clone(),
&bank.clone(),
node.sockets.requests,
node.sockets.respond,
exit.clone(),
Expand All @@ -229,7 +229,7 @@ impl FullNode {
thread_hdls.extend(tpu.thread_hdls());
let window = FullNode::new_window(ledger_tail, entry_height, &crdt, &blob_recycler);
let ncp = Ncp::new(
crdt.clone(),
&crdt.clone(),
window.clone(),
node.sockets.gossip,
node.sockets.gossip_send,
Expand Down Expand Up @@ -285,13 +285,13 @@ impl FullNode {
entry_height: u64,
ledger_tail: Option<Vec<Entry>>,
node: TestNode,
entry_point: NodeInfo,
entry_point: &NodeInfo,
exit: Arc<AtomicBool>,
) -> Self {
let bank = Arc::new(bank);
let mut thread_hdls = vec![];
let rpu = Rpu::new(
bank.clone(),
&bank.clone(),
node.sockets.requests,
node.sockets.respond,
exit.clone(),
Expand All @@ -308,7 +308,7 @@ impl FullNode {
let window = FullNode::new_window(ledger_tail, entry_height, &crdt, &blob_recycler);

let ncp = Ncp::new(
crdt.clone(),
&crdt.clone(),
window.clone(),
node.sockets.gossip,
node.sockets.gossip_send,
Expand Down Expand Up @@ -367,7 +367,7 @@ mod tests {
let bank = Bank::new(&alice);
let exit = Arc::new(AtomicBool::new(false));
let entry = tn.data.clone();
let v = FullNode::new_validator(kp, bank, 0, None, tn, entry, exit);
let v = FullNode::new_validator(kp, bank, 0, None, tn, &entry, exit);
v.close().unwrap();
}
}
6 changes: 3 additions & 3 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ impl Default for MetricsAgent {
impl MetricsAgent {
fn new(writer: Arc<MetricsWriter + Send + Sync>, write_frequency: Duration) -> Self {
let (sender, receiver) = channel::<MetricsCommand>();
thread::spawn(move || Self::run(receiver, writer, write_frequency));
thread::spawn(move || Self::run(&receiver, &writer, write_frequency));
MetricsAgent { sender }
}

fn run(
receiver: Receiver<MetricsCommand>,
writer: Arc<MetricsWriter>,
receiver: &Receiver<MetricsCommand>,
writer: &Arc<MetricsWriter + Send + Sync>,
write_frequency: Duration,
) {
trace!("run: enter");
Expand Down
4 changes: 2 additions & 2 deletions src/ncp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Ncp {

impl Ncp {
pub fn new(
crdt: Arc<RwLock<Crdt>>,
crdt: &Arc<RwLock<Crdt>>,
window: Arc<RwLock<Vec<Option<SharedBlob>>>>,
gossip_listen_socket: UdpSocket,
gossip_send_socket: UdpSocket,
Expand Down Expand Up @@ -93,7 +93,7 @@ mod tests {
let c = Arc::new(RwLock::new(crdt));
let w = Arc::new(RwLock::new(vec![]));
let d = Ncp::new(
c.clone(),
&c.clone(),
w,
tn.sockets.gossip,
tn.sockets.gossip_send,
Expand Down
2 changes: 1 addition & 1 deletion src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use hash::Hash;
use signature::{PublicKey, Signature};

#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
pub enum Request {
GetBalance { key: PublicKey },
GetLastId,
Expand Down
2 changes: 1 addition & 1 deletion src/rpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct Rpu {

impl Rpu {
pub fn new(
bank: Arc<Bank>,
bank: &Arc<Bank>,
requests_socket: UdpSocket,
respond_socket: UdpSocket,
exit: Arc<AtomicBool>,
Expand Down
1 change: 1 addition & 0 deletions src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn batch_size(batches: &[SharedPackets]) -> usize {
.sum()
}

#[cfg_attr(feature = "cargo-clippy", allow(ptr_arg))]
#[cfg(not(feature = "cuda"))]
pub fn ed25519_verify(batches: &Vec<SharedPackets>) -> Vec<Vec<u8>> {
use rayon::prelude::*;
Expand Down
Loading

0 comments on commit c2ca123

Please sign in to comment.