Adjust for vector of entries in blobs.

This commit is contained in:
Stephen Akridge 2019-03-18 16:16:06 -07:00 committed by sakridge
parent f1802e592a
commit 682b1b89b3
2 changed files with 14 additions and 8 deletions

View File

@ -612,6 +612,11 @@ impl Blocktree {
Ok(result) Ok(result)
} }
pub fn deserialize_blob_data(data: &[u8]) -> Result<Vec<Entry>> {
let entries = deserialize(data)?;
Ok(entries)
}
fn deserialize_blobs<I>(blob_datas: &[I]) -> Vec<Entry> fn deserialize_blobs<I>(blob_datas: &[I]) -> Vec<Entry>
where where
I: Borrow<[u8]>, I: Borrow<[u8]>,
@ -620,9 +625,8 @@ impl Blocktree {
.iter() .iter()
.flat_map(|blob_data| { .flat_map(|blob_data| {
let serialized_entries_data = &blob_data.borrow()[BLOB_HEADER_SIZE..]; let serialized_entries_data = &blob_data.borrow()[BLOB_HEADER_SIZE..];
let entries: Vec<Entry> = deserialize(serialized_entries_data) Self::deserialize_blob_data(serialized_entries_data)
.expect("Ledger should only contain well formed data"); .expect("Ledger should only contain well formed data")
entries
}) })
.collect() .collect()
} }

View File

@ -8,7 +8,6 @@ use bincode::{deserialize, serialize};
use solana::blocktree::{create_new_tmp_ledger, tmp_copy_blocktree, Blocktree}; use solana::blocktree::{create_new_tmp_ledger, tmp_copy_blocktree, Blocktree};
use solana::cluster_info::{ClusterInfo, Node}; use solana::cluster_info::{ClusterInfo, Node};
use solana::contact_info::ContactInfo; use solana::contact_info::ContactInfo;
use solana::entry::Entry;
use solana::fullnode::{Fullnode, FullnodeConfig}; use solana::fullnode::{Fullnode, FullnodeConfig};
use solana::gossip_service::discover; use solana::gossip_service::discover;
use solana::local_cluster::LocalCluster; use solana::local_cluster::LocalCluster;
@ -82,10 +81,13 @@ fn download_from_replicator(replicator_info: &ContactInfo) {
for b in blobs { for b in blobs {
let br = b.read().unwrap(); let br = b.read().unwrap();
assert!(br.index() == repair_index); assert!(br.index() == repair_index);
let entry: Entry = deserialize(&br.data()[..br.meta.size]).unwrap(); info!("br: {:?}", br);
info!("entry: {:?}", entry); let entries = Blocktree::deserialize_blob_data(&br.data()).unwrap();
assert_ne!(entry.hash, Hash::default()); for entry in &entries {
received_blob = true; info!("entry: {:?}", entry);
assert_ne!(entry.hash, Hash::default());
received_blob = true;
}
} }
break; break;
} }