employ the simple choice for broadcast table of coding blobs: round-robin

This commit is contained in:
Rob Walker
2018-07-25 16:03:40 -07:00
parent a6a2a745ae
commit e0cdcb0973

View File

@ -20,8 +20,6 @@ use counter::Counter;
#[cfg(feature = "erasure")] #[cfg(feature = "erasure")]
use erasure; use erasure;
#[cfg(feature = "erasure")]
use rand::Rng;
use hash::Hash; use hash::Hash;
use packet::{to_blob, Blob, BlobRecycler, SharedBlob, BLOB_SIZE}; use packet::{to_blob, Blob, BlobRecycler, SharedBlob, BLOB_SIZE};
@ -578,13 +576,11 @@ impl Crdt {
#[cfg(feature = "erasure")] #[cfg(feature = "erasure")]
let mut coding_index = None; let mut coding_index = None;
let mut br_idx = *transmit_index as usize % broadcast_table.len();
for idx in *transmit_index..received_index { for idx in *transmit_index..received_index {
let w_idx = idx as usize % window_l.len(); let w_idx = idx as usize % window_l.len();
let br_idx = idx as usize % broadcast_table.len();
assert!(window_l[w_idx].data.is_some());
orders.push((window_l[w_idx].data.clone(), &broadcast_table[br_idx]));
trace!( trace!(
"{:x} broadcast order data w_idx {} br_idx {}", "{:x} broadcast order data w_idx {} br_idx {}",
me.debug_id(), me.debug_id(),
@ -592,6 +588,10 @@ impl Crdt {
br_idx br_idx
); );
orders.push((window_l[w_idx].data.clone(), &broadcast_table[br_idx]));
br_idx += 1;
br_idx %= broadcast_table.len();
#[cfg(feature = "erasure")] #[cfg(feature = "erasure")]
{ {
// remember first place we saw coding // remember first place we saw coding
@ -617,8 +617,6 @@ impl Crdt {
if window_l[w_idx].coding.is_none() { if window_l[w_idx].coding.is_none() {
continue; continue;
} }
let br_idx = thread_rng().gen_range(0, broadcast_table.len());
orders.push((window_l[w_idx].coding.clone(), &broadcast_table[br_idx]));
trace!( trace!(
"{:x} broadcast order coding w_idx: {} br_idx :{}", "{:x} broadcast order coding w_idx: {} br_idx :{}",
@ -626,6 +624,11 @@ impl Crdt {
w_idx, w_idx,
br_idx, br_idx,
); );
orders.push((window_l[w_idx].coding.clone(), &broadcast_table[br_idx]));
br_idx += 1;
br_idx %= broadcast_table.len();
} }
} }
} }