From b235da83791666314ef0863e0a503717d02c8e2a Mon Sep 17 00:00:00 2001 From: Steven Czabaniuk Date: Mon, 10 May 2021 12:39:21 -0500 Subject: [PATCH] Zero pad data shreds on fetch from blockstore This is a partial backport of #16602 to allow compatibility with that change. --- ledger/src/blockstore.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 0b33fb15ad1df0..49c16714f5b144 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1438,7 +1438,16 @@ impl Blockstore { } pub fn get_data_shred(&self, slot: Slot, index: u64) -> Result>> { - 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(