Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit a6b62a9

Browse files
committed
removes SHRED_PAYLOAD_SIZE
1 parent 4867cdb commit a6b62a9

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

ledger/src/shred.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ const SHRED_DATA_OFFSET: usize = SIZE_OF_COMMON_SHRED_HEADER + SIZE_OF_DATA_SHRE
114114
const OFFSET_OF_SHRED_TYPE: usize = SIZE_OF_SIGNATURE;
115115
const OFFSET_OF_SHRED_SLOT: usize = SIZE_OF_SIGNATURE + SIZE_OF_SHRED_TYPE;
116116
const OFFSET_OF_SHRED_INDEX: usize = OFFSET_OF_SHRED_SLOT + SIZE_OF_SHRED_SLOT;
117-
const_assert_eq!(SHRED_PAYLOAD_SIZE, 1228);
118-
const SHRED_PAYLOAD_SIZE: usize = PACKET_DATA_SIZE - SIZE_OF_NONCE;
119117

120118
pub const MAX_DATA_SHREDS_PER_FEC_BLOCK: u32 = 32;
121119

ledger/src/shred/legacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ impl ShredData {
244244
}
245245

246246
pub(super) fn resize_stored_shred(mut shred: Vec<u8>) -> Result<Vec<u8>, Error> {
247-
// Old shreds might have been padded to super::SHRED_PAYLOAD_SIZE.
248-
if !(SHRED_DATA_OFFSET..=super::SHRED_PAYLOAD_SIZE).contains(&shred.len()) {
247+
// Old shreds might have been extra zero padded.
248+
if !(SHRED_DATA_OFFSET..=ShredCode::SIZE_OF_PAYLOAD).contains(&shred.len()) {
249249
return Err(Error::InvalidPayloadSize(shred.len()));
250250
}
251251
shred.resize(Self::SIZE_OF_PAYLOAD, 0u8);
@@ -254,7 +254,7 @@ impl ShredData {
254254
}
255255

256256
impl ShredCode {
257-
const SIZE_OF_PAYLOAD: usize = super::SHRED_PAYLOAD_SIZE;
257+
const SIZE_OF_PAYLOAD: usize = shred_code::ShredCode::SIZE_OF_PAYLOAD;
258258

259259
pub(super) fn new_from_parity_shard(
260260
slot: Slot,

ledger/src/shred/merkle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl ShredData {
8383
}
8484

8585
impl ShredCode {
86-
const SIZE_OF_PAYLOAD: usize = super::SHRED_PAYLOAD_SIZE;
86+
const SIZE_OF_PAYLOAD: usize = shred_code::ShredCode::SIZE_OF_PAYLOAD;
8787

8888
fn proof_size(&self) -> Result<u8, Error> {
8989
match self.common_header.shred_variant {

ledger/src/shred/shred_code.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ use {
33
common::dispatch,
44
legacy, merkle,
55
traits::{Shred, ShredCode as ShredCodeTrait},
6-
CodingShredHeader, Error, ShredCommonHeader, MAX_DATA_SHREDS_PER_FEC_BLOCK,
6+
CodingShredHeader, Error, ShredCommonHeader, MAX_DATA_SHREDS_PER_FEC_BLOCK, SIZE_OF_NONCE,
77
},
8-
solana_sdk::{clock::Slot, signature::Signature},
8+
solana_sdk::{clock::Slot, packet::PACKET_DATA_SIZE, signature::Signature},
9+
static_assertions::const_assert_eq,
910
};
1011

12+
const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 1228);
13+
1114
#[derive(Clone, Debug, PartialEq)]
1215
pub enum ShredCode {
1316
Legacy(legacy::ShredCode),
1417
Merkle(merkle::ShredCode),
1518
}
1619

1720
impl ShredCode {
21+
pub(super) const SIZE_OF_PAYLOAD: usize = PACKET_DATA_SIZE - SIZE_OF_NONCE;
22+
1823
dispatch!(fn coding_header(&self) -> &CodingShredHeader);
1924

2025
dispatch!(pub(super) fn common_header(&self) -> &ShredCommonHeader);

0 commit comments

Comments
 (0)