Skip to content

Commit

Permalink
Zero pad data shreds on fetch from blockstore
Browse files Browse the repository at this point in the history
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
  • Loading branch information
Steven Czabaniuk committed May 10, 2021
1 parent 094271b commit b235da8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,16 @@ impl Blockstore {
}

pub fn get_data_shred(&self, slot: Slot, index: u64) -> Result<Option<Vec<u8>>> {
self.data_shred_cf.get_bytes((slot, index))
use crate::shred::SHRED_PAYLOAD_SIZE;
self.data_shred_cf.get_bytes((slot, index)).map(|data| {
data.map(|mut d| {
// For forward compatibility, pad the payload out to
// SHRED_PAYLOAD_SIZE incase the shred was inserted
// with any padding stripped off.
d.resize(cmp::max(d.len(), SHRED_PAYLOAD_SIZE), 0);
d
})
})
}

pub fn get_data_shreds_for_slot(
Expand Down

0 comments on commit b235da8

Please sign in to comment.