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