File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -204,9 +204,12 @@ pub(crate) trait Cache {
204204 fn blocks_disconnected ( & mut self , fork_point : & ValidatedBlockHeader ) ;
205205}
206206
207+ /// The maximum number of [`ValidatedBlockHeader`]s stored in a [`HeaderCache`].
208+ pub const HEADER_CACHE_LIMIT : u32 = 6 * 24 * 7 ;
209+
207210/// Bounded cache of block headers keyed by block hash.
208211///
209- /// Retains only the last `ANTI_REORG_DELAY * 2` block headers based on height.
212+ /// Retains only the latest [`HEADER_CACHE_LIMIT`] block headers based on height.
210213pub struct HeaderCache ( std:: collections:: HashMap < BlockHash , ValidatedBlockHeader > ) ;
211214
212215impl HeaderCache {
@@ -225,7 +228,7 @@ impl Cache for HeaderCache {
225228 self . 0 . insert ( block_hash, block_header) ;
226229
227230 // Remove headers older than a week.
228- let cutoff_height = block_header. height . saturating_sub ( 6 * 24 * 7 ) ;
231+ let cutoff_height = block_header. height . saturating_sub ( HEADER_CACHE_LIMIT ) ;
229232 self . 0 . retain ( |_, header| header. height >= cutoff_height) ;
230233 }
231234
You can’t perform that action at this time.
0 commit comments