From d42d024d9ca878c2e8c61de0e82682eeb05899eb Mon Sep 17 00:00:00 2001 From: Robert Kelly Date: Tue, 15 May 2018 07:35:41 -0400 Subject: [PATCH 1/2] minor changes --- src/bank.rs | 4 ++-- src/crdt.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bank.rs b/src/bank.rs index f79273122..35aa30aac 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -286,8 +286,8 @@ impl Bank { .entry(tx_sig) { e.get_mut().apply_witness(&Witness::Signature(from)); - if let Some(ref payment) = e.get().final_payment() { - apply_payment(&self.balances, payment); + if let Some(payment) = e.get().final_payment() { + apply_payment(&self.balances, &payment); e.remove_entry(); } }; diff --git a/src/crdt.rs b/src/crdt.rs index f76ca3862..28481e82c 100644 --- a/src/crdt.rs +++ b/src/crdt.rs @@ -3,7 +3,7 @@ //! repair partitions. //! //! This CRDT only supports a very limited set of types. A map of PublicKey -> Versioned Struct. -//! The last version is always picked durring an update. +//! The last version is always picked during an update. //! //! The network is arranged in layers: //! @@ -89,7 +89,7 @@ pub struct Crdt { /// should respond with all the identities that are greater then the /// request's `update_index` in this list local: HashMap, - /// The value of the remote update index that i have last seen + /// The value of the remote update index that I have last seen /// This Node will ask external nodes for updates since the value in this list pub remote: HashMap, pub update_index: u64, @@ -169,7 +169,7 @@ impl Crdt { transmit_index: &mut u64, ) -> Result<()> { let (me, table): (ReplicatedData, Vec) = { - // copy to avoid locking durring IO + // copy to avoid locking during IO let robj = obj.read().expect("'obj' read lock in pub fn broadcast"); info!("broadcast table {}", robj.table.len()); let cloned_table: Vec = robj.table.values().cloned().collect(); @@ -197,7 +197,7 @@ impl Crdt { info!("nodes table {}", nodes.len()); info!("blobs table {}", blobs.len()); - // enumerate all the blobs, those are the indecies + // enumerate all the blobs, those are the indices // transmit them to nodes, starting from a different node let orders: Vec<_> = blobs .iter() @@ -245,7 +245,7 @@ impl Crdt { /// We need to avoid having obj locked while doing any io, such as the `send_to` pub fn retransmit(obj: &Arc>, blob: &SharedBlob, s: &UdpSocket) -> Result<()> { let (me, table): (ReplicatedData, Vec) = { - // copy to avoid locking durring IO + // copy to avoid locking during IO let s = obj.read().expect("'obj' read lock in pub fn retransmit"); (s.table[&s.me].clone(), s.table.values().cloned().collect()) }; @@ -439,7 +439,7 @@ impl Crdt { Protocol::RequestUpdates(v, reqdata) => { trace!("RequestUpdates {}", v); let addr = reqdata.gossip_addr; - // only lock for this call, dont lock durring IO `sock.send_to` or `sock.recv_from` + // only lock for this call, dont lock during IO `sock.send_to` or `sock.recv_from` let (from, ups, data) = obj.read() .expect("'obj' read lock in RequestUpdates") .get_updates_since(v); From a1889c32d43df98cf5225c8675ed4d087ee4ad76 Mon Sep 17 00:00:00 2001 From: Robert Kelly Date: Tue, 15 May 2018 10:24:52 -0400 Subject: [PATCH 2/2] fixed CrdtToSmall typo --- src/crdt.rs | 6 +++--- src/result.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crdt.rs b/src/crdt.rs index 28481e82c..e2303fbbe 100644 --- a/src/crdt.rs +++ b/src/crdt.rs @@ -192,7 +192,7 @@ impl Crdt { }) .collect(); if nodes.len() < 1 { - return Err(Error::CrdtToSmall); + return Err(Error::CrdtTooSmall); } info!("nodes table {}", nodes.len()); @@ -317,7 +317,7 @@ impl Crdt { pub fn window_index_request(&self, ix: u64) -> Result<(SocketAddr, Vec)> { if self.table.len() <= 1 { - return Err(Error::CrdtToSmall); + return Err(Error::CrdtTooSmall); } let mut n = (Self::random() as usize) % self.table.len(); while self.table.values().nth(n).unwrap().id == self.me { @@ -337,7 +337,7 @@ impl Crdt { fn gossip_request(&self) -> Result<(SocketAddr, Protocol)> { let options: Vec<_> = self.table.values().filter(|v| v.id != self.me).collect(); if options.len() < 1 { - return Err(Error::CrdtToSmall); + return Err(Error::CrdtTooSmall); } let n = (Self::random() as usize) % options.len(); let v = options[n].clone(); diff --git a/src/result.rs b/src/result.rs index e8add9c98..562849040 100644 --- a/src/result.rs +++ b/src/result.rs @@ -18,7 +18,7 @@ pub enum Error { BankError(bank::BankError), SendError, Services, - CrdtToSmall, + CrdtTooSmall, GenericError, }