From 7c32640a9ba6d217c11e9ba9f64f04fb6e607249 Mon Sep 17 00:00:00 2001 From: carllin Date: Sat, 16 Nov 2019 02:41:59 -0800 Subject: [PATCH] Set index and set data should write into shred data (#6995) --- ledger/src/shred.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs index 4f9be4f9a..c36428102 100644 --- a/ledger/src/shred.rs +++ b/ledger/src/shred.rs @@ -281,16 +281,26 @@ impl Shred { self.common_header.index } - /// This is not a safe function. It only changes the meta information. - /// Use this only for test code which doesn't care about actual shred pub fn set_index(&mut self, index: u32) { - self.common_header.index = index + self.common_header.index = index; + Self::serialize_obj_into( + &mut 0, + SIZE_OF_COMMON_SHRED_HEADER, + &mut self.payload, + &self.common_header, + ) + .unwrap(); } - /// This is not a safe function. It only changes the meta information. - /// Use this only for test code which doesn't care about actual shred pub fn set_slot(&mut self, slot: Slot) { - self.common_header.slot = slot + self.common_header.slot = slot; + Self::serialize_obj_into( + &mut 0, + SIZE_OF_COMMON_SHRED_HEADER, + &mut self.payload, + &self.common_header, + ) + .unwrap(); } pub fn signature(&self) -> Signature {