Return a Vec from to_blobs() instead of using a mut parameter
This commit is contained in:
parent
8cc030ef84
commit
2aa72cc72e
|
@ -412,7 +412,7 @@ pub fn read_ledger(
|
|||
pub trait Block {
|
||||
/// Verifies the hashes and counts of a slice of transactions are all consistent.
|
||||
fn verify(&self, start_hash: &Hash) -> bool;
|
||||
fn to_blobs(&self, blob_recycler: &packet::BlobRecycler, q: &mut Vec<SharedBlob>);
|
||||
fn to_blobs(&self, blob_recycler: &packet::BlobRecycler) -> Vec<SharedBlob>;
|
||||
fn votes(&self) -> Vec<(Pubkey, Vote, Hash)>;
|
||||
}
|
||||
|
||||
|
@ -433,11 +433,10 @@ impl Block for [Entry] {
|
|||
})
|
||||
}
|
||||
|
||||
fn to_blobs(&self, blob_recycler: &packet::BlobRecycler, q: &mut Vec<SharedBlob>) {
|
||||
for entry in self {
|
||||
let blob = entry.to_blob(blob_recycler, None, None, None);
|
||||
q.push(blob);
|
||||
}
|
||||
fn to_blobs(&self, blob_recycler: &packet::BlobRecycler) -> Vec<SharedBlob> {
|
||||
self.iter()
|
||||
.map(|entry| entry.to_blob(blob_recycler, None, None, None))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn votes(&self) -> Vec<(Pubkey, Vote, Hash)> {
|
||||
|
@ -634,8 +633,7 @@ mod tests {
|
|||
let entries = make_test_entries();
|
||||
|
||||
let blob_recycler = BlobRecycler::default();
|
||||
let mut blob_q = Vec::new();
|
||||
entries.to_blobs(&blob_recycler, &mut blob_q);
|
||||
let blob_q = entries.to_blobs(&blob_recycler);
|
||||
|
||||
assert_eq!(reconstruct_entries_from_blobs(blob_q).unwrap(), entries);
|
||||
}
|
||||
|
|
|
@ -613,11 +613,7 @@ pub fn new_window_from_entries(
|
|||
blob_recycler: &BlobRecycler,
|
||||
) -> SharedWindow {
|
||||
// convert to blobs
|
||||
let mut blobs = Vec::new();
|
||||
ledger_tail.to_blobs(&blob_recycler, &mut blobs);
|
||||
|
||||
// flatten deque to vec
|
||||
let blobs: Vec<_> = blobs.into_iter().collect();
|
||||
let blobs = ledger_tail.to_blobs(&blob_recycler);
|
||||
initialized_window(&node_info, blobs, entry_height)
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ impl WriteStage {
|
|||
//on a valid last id
|
||||
|
||||
trace!("New blobs? {}", entries.len());
|
||||
let mut blobs = Vec::new();
|
||||
entries.to_blobs(blob_recycler, &mut blobs);
|
||||
let blobs = entries.to_blobs(blob_recycler);
|
||||
|
||||
if !blobs.is_empty() {
|
||||
inc_new_counter_info!("write_stage-recv_vote", votes.len());
|
||||
|
|
Loading…
Reference in New Issue