Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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
4 changes: 2 additions & 2 deletions src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down
18 changes: 9 additions & 9 deletions src/crdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//!
Expand Down Expand Up @@ -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<PublicKey, u64>,
/// 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<PublicKey, u64>,
pub update_index: u64,
Expand Down Expand Up @@ -169,7 +169,7 @@ impl Crdt {
transmit_index: &mut u64,
) -> Result<()> {
let (me, table): (ReplicatedData, Vec<ReplicatedData>) = {
// 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<ReplicatedData> = robj.table.values().cloned().collect();
Expand All @@ -192,12 +192,12 @@ impl Crdt {
})
.collect();
if nodes.len() < 1 {
return Err(Error::CrdtToSmall);
return Err(Error::CrdtTooSmall);
}

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()
Expand Down Expand Up @@ -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<RwLock<Self>>, blob: &SharedBlob, s: &UdpSocket) -> Result<()> {
let (me, table): (ReplicatedData, Vec<ReplicatedData>) = {
// 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())
};
Expand Down Expand Up @@ -317,7 +317,7 @@ impl Crdt {

pub fn window_index_request(&self, ix: u64) -> Result<(SocketAddr, Vec<u8>)> {
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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum Error {
BankError(bank::BankError),
SendError,
Services,
CrdtToSmall,
CrdtTooSmall,
GenericError,
}

Expand Down