Minor shred constant cleanup (#27472)

* Minor shred constant cleanup to eliminate magic number
This commit is contained in:
Brennan Watt 2022-08-30 18:53:05 -07:00 committed by GitHub
parent b5cca0bfa3
commit dfdb422fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -1,18 +1,21 @@
use {
crate::shred::{
common::dispatch,
legacy, merkle,
traits::{Shred, ShredCode as ShredCodeTrait},
CodingShredHeader, Error, ShredCommonHeader, ShredType, DATA_SHREDS_PER_FEC_BLOCK,
MAX_DATA_SHREDS_PER_SLOT, SIZE_OF_NONCE,
crate::{
shred::{
common::dispatch,
legacy, merkle,
traits::{Shred, ShredCode as ShredCodeTrait},
CodingShredHeader, Error, ShredCommonHeader, ShredType, DATA_SHREDS_PER_FEC_BLOCK,
MAX_DATA_SHREDS_PER_SLOT, SIZE_OF_NONCE,
},
shredder::ERASURE_BATCH_SIZE,
},
solana_sdk::{clock::Slot, packet::PACKET_DATA_SIZE, signature::Signature},
static_assertions::const_assert_eq,
};
// See ERASURE_BATCH_SIZE.
const_assert_eq!(MAX_CODE_SHREDS_PER_SLOT, 32_768 * 17);
pub(crate) const MAX_CODE_SHREDS_PER_SLOT: usize = MAX_DATA_SHREDS_PER_SLOT * 17;
pub(crate) const MAX_CODE_SHREDS_PER_SLOT: usize =
MAX_DATA_SHREDS_PER_SLOT * (ERASURE_BATCH_SIZE[1] - 1);
const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 1228);

View File

@ -26,7 +26,7 @@ lazy_static! {
// Maps number of data shreds to the optimal erasure batch size which has the
// same recovery probabilities as a 32:32 erasure batch.
const ERASURE_BATCH_SIZE: [usize; 33] = [
pub(crate) const ERASURE_BATCH_SIZE: [usize; 33] = [
0, 18, 20, 22, 23, 25, 27, 28, 30, // 8
32, 33, 35, 36, 38, 39, 41, 42, // 16
43, 45, 46, 48, 49, 51, 52, 53, // 24