mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add blocks_per_file field to StaticFileProvider (#11043)
This commit is contained in:
@ -16,7 +16,7 @@ pub use compression::Compression;
|
||||
pub use segment::{SegmentConfig, SegmentHeader, SegmentRangeInclusive, StaticFileSegment};
|
||||
|
||||
/// Default static file block count.
|
||||
pub const BLOCKS_PER_STATIC_FILE: u64 = 500_000;
|
||||
pub const DEFAULT_BLOCKS_PER_STATIC_FILE: u64 = 500_000;
|
||||
|
||||
/// Highest static file block numbers, per data segment.
|
||||
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
|
||||
@ -64,7 +64,10 @@ impl HighestStaticFiles {
|
||||
|
||||
/// Each static file has a fixed number of blocks. This gives out the range where the requested
|
||||
/// block is positioned. Used for segment filename.
|
||||
pub const fn find_fixed_range(block: BlockNumber) -> SegmentRangeInclusive {
|
||||
let start = (block / BLOCKS_PER_STATIC_FILE) * BLOCKS_PER_STATIC_FILE;
|
||||
SegmentRangeInclusive::new(start, start + BLOCKS_PER_STATIC_FILE - 1)
|
||||
pub const fn find_fixed_range(
|
||||
block: BlockNumber,
|
||||
blocks_per_static_file: u64,
|
||||
) -> SegmentRangeInclusive {
|
||||
let start = (block / blocks_per_static_file) * blocks_per_static_file;
|
||||
SegmentRangeInclusive::new(start, start + blocks_per_static_file - 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user