diff --git a/src/erasure.rs b/src/erasure.rs index 35c543f090..dbc010fc09 100644 --- a/src/erasure.rs +++ b/src/erasure.rs @@ -153,7 +153,7 @@ pub fn decode_blocks(data: &mut [&mut [u8]], coding: &[&[u8]], erasures: &[i32]) // Generate coding blocks in window from consumed to consumed+NUM_DATA pub fn generate_coding( re: &BlobRecycler, - window: &mut Vec, + window: &mut Vec>, consumed: usize, ) -> Result<()> { let mut data_blobs = Vec::new(); @@ -183,7 +183,7 @@ pub fn generate_coding( let coding_end = consumed + NUM_CODED; for i in coding_start..coding_end { let n = i % window.len(); - window[n] = re.allocate(); + window[n] = Some(re.allocate()); coding_blobs.push( window[n] .clone() diff --git a/src/streamer.rs b/src/streamer.rs index e607ed177c..9d4bbb53be 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -377,9 +377,14 @@ fn broadcast( dq.append(&mut nq); } let mut blobs = dq.into_iter().collect(); - /// appends codes to the list of blobs allowing us to reconstruct the stream + // appends codes to the list of blobs allowing us to reconstruct the stream #[cfg(feature = "erasure")] - erasure::generate_coding(re, blobs, consumed); + { + match erasure::generate_coding(recycler, &mut window.write().unwrap(), *transmit_index as usize) { + Err(_e) => { return Err(Error::GenericError) } + _ => {} + } + } Crdt::broadcast(crdt, &blobs, &sock, transmit_index)?; // keep the cache of blobs that are broadcast {