Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't clone before borrowing #608

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {

let rando1 = KeyPair::new();
let tx = Transaction::new(&rando0, rando1.pubkey(), 1, last_id);
assert!(bank.process_transaction(&tx.clone()).is_ok());
assert!(bank.process_transaction(&tx).is_ok());

// Finally, return the transaction to the benchmark.
tx
Expand Down
2 changes: 1 addition & 1 deletion 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,
&verified_receiver,
&signal_sender,
&packet_recycler,
Expand Down
4 changes: 2 additions & 2 deletions src/bin/client-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn main() {

let signal = Arc::new(AtomicBool::new(false));
let mut c_threads = vec![];
let validators = converge(&leader, &signal.clone(), num_nodes, &mut c_threads);
let validators = converge(&leader, &signal, num_nodes, &mut c_threads);
assert_eq!(validators.len(), num_nodes);

let mut client = mk_client(&leader);
Expand Down Expand Up @@ -393,7 +393,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,
window.clone(),
spy_gossip,
gossip_send_socket,
Expand Down
16 changes: 8 additions & 8 deletions src/fullnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl FullNode {
let bank = Arc::new(bank);
let mut thread_hdls = vec![];
let rpu = Rpu::new(
&bank.clone(),
&bank,
node.sockets.requests,
node.sockets.respond,
exit.clone(),
Expand All @@ -205,18 +205,18 @@ impl FullNode {
let blob_recycler = BlobRecycler::default();
let crdt = Arc::new(RwLock::new(Crdt::new(node.data)));
let (tpu, blob_receiver) = Tpu::new(
&bank.clone(),
&crdt.clone(),
&bank,
&crdt,
tick_duration,
node.sockets.transaction,
&blob_recycler.clone(),
&blob_recycler,
exit.clone(),
writer,
);
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,
window.clone(),
node.sockets.gossip,
node.sockets.gossip_send,
Expand Down Expand Up @@ -278,7 +278,7 @@ impl FullNode {
let bank = Arc::new(bank);
let mut thread_hdls = vec![];
let rpu = Rpu::new(
&bank.clone(),
&bank,
node.sockets.requests,
node.sockets.respond,
exit.clone(),
Expand All @@ -295,7 +295,7 @@ impl FullNode {
let window = FullNode::new_window(ledger_tail, entry_height, &crdt, &blob_recycler);

let ncp = Ncp::new(
&crdt.clone(),
&crdt,
window.clone(),
node.sockets.gossip,
node.sockets.gossip_send,
Expand All @@ -304,7 +304,7 @@ impl FullNode {

let tvu = Tvu::new(
keypair,
bank.clone(),
&bank,
entry_height,
crdt.clone(),
window.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/ncp.rs
Original file line number Diff line number Diff line change
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,
w,
tn.sockets.gossip,
tn.sockets.gossip_send,
Expand Down
2 changes: 1 addition & 1 deletion src/sigverify_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl SigVerifyStage {
verified_sender: Arc<Mutex<Sender<VerifiedPackets>>>,
) -> JoinHandle<()> {
spawn(move || loop {
if let Err(e) = Self::verifier(&packet_receiver.clone(), &verified_sender.clone()) {
if let Err(e) = Self::verifier(&packet_receiver, &verified_sender) {
match e {
Error::RecvTimeoutError(RecvTimeoutError::Disconnected) => break,
Error::RecvTimeoutError(RecvTimeoutError::Timeout) => (),
Expand Down
2 changes: 1 addition & 1 deletion src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Tpu {
let packet_recycler = PacketRecycler::default();

let (fetch_stage, packet_receiver) =
FetchStage::new(transactions_socket, exit, &packet_recycler.clone());
FetchStage::new(transactions_socket, exit, &packet_recycler);

let (sigverify_stage, verified_receiver) = SigVerifyStage::new(packet_receiver);

Expand Down
19 changes: 12 additions & 7 deletions src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Tvu {
/// * `exit` - The exit signal.
pub fn new(
keypair: KeyPair,
bank: Arc<Bank>,
bank: &Arc<Bank>,
entry_height: u64,
crdt: Arc<RwLock<Crdt>>,
window: Window,
Expand All @@ -83,22 +83,27 @@ impl Tvu {
let (fetch_stage, blob_fetch_receiver) = BlobFetchStage::new_multi_socket(
vec![replicate_socket, repair_socket],
exit,
&blob_recycler.clone(),
&blob_recycler,
);
//TODO
//the packets coming out of blob_receiver need to be sent to the GPU and verified
//then sent to the window, which does the erasure coding reconstruction
let (window_stage, blob_window_receiver) = WindowStage::new(
&crdt.clone(),
&crdt,
window,
entry_height,
retransmit_socket,
&blob_recycler.clone(),
&blob_recycler,
blob_fetch_receiver,
);

let replicate_stage =
ReplicateStage::new(keypair, bank, crdt, blob_recycler, blob_window_receiver);
let replicate_stage = ReplicateStage::new(
keypair,
bank.clone(),
crdt,
blob_recycler,
blob_window_receiver,
);

Tvu {
replicate_stage,
Expand Down Expand Up @@ -225,7 +230,7 @@ pub mod tests {

let tvu = Tvu::new(
target1_kp,
bank.clone(),
&bank,
0,
cref1,
dr_1.1,
Expand Down
2 changes: 1 addition & 1 deletion tests/multinode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn converge(leader: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
let spy_ref = Arc::new(RwLock::new(spy_crdt));
let spy_window = default_window();
let ncp = Ncp::new(
&spy_ref.clone(),
&spy_ref,
spy_window,
spy.sockets.gossip,
spy.sockets.gossip_send,
Expand Down