Skip to content

Commit 90b8248

Browse files
committed
store: Refactor clear_stale_call_cache
Refactor the code to separate the gymnastics caused by the two separate storage schemes from the overall control loop
1 parent f501334 commit 90b8248

5 files changed

Lines changed: 179 additions & 177 deletions

File tree

graph/src/blockchain/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ impl ChainStore for MockChainStore {
594594
}
595595
async fn clear_stale_call_cache(
596596
&self,
597-
_ttl_days: i32,
598-
_ttl_max_contracts: Option<i64>,
597+
_ttl_days: usize,
598+
_ttl_max_contracts: Option<usize>,
599599
) -> Result<(), Error> {
600600
unimplemented!()
601601
}

graph/src/components/store/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ pub trait ChainStore: ChainHeadStore {
660660
/// Clears stale call cache entries for the given TTL in days.
661661
async fn clear_stale_call_cache(
662662
&self,
663-
ttl_days: i32,
664-
ttl_max_contracts: Option<i64>,
663+
ttl_days: usize,
664+
ttl_max_contracts: Option<usize>,
665665
) -> Result<(), Error>;
666666

667667
/// Return the chain identifier for this store.

node/src/bin/manager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,11 @@ pub enum CallCacheCommand {
619619
#[clap(long, conflicts_with_all = &["from", "to"])]
620620
remove_entire_cache: bool,
621621
/// Remove the cache for contracts that have not been accessed in the last <TTL_DAYS> days
622-
#[clap(long, conflicts_with_all = &["from", "to", "remove-entire-cache"], value_parser = clap::value_parser!(i32).range(1..))]
623-
ttl_days: Option<i32>,
622+
#[clap(long, conflicts_with_all = &["from", "to", "remove-entire-cache"], value_parser = clap::value_parser!(u32).range(1..))]
623+
ttl_days: Option<usize>,
624624
/// Limits the number of contracts to consider for cache removal when using --ttl_days
625-
#[clap(long, conflicts_with_all = &["remove-entire-cache", "to", "from"], requires = "ttl_days", value_parser = clap::value_parser!(i64).range(1..))]
626-
ttl_max_contracts: Option<i64>,
625+
#[clap(long, conflicts_with_all = &["remove-entire-cache", "to", "from"], requires = "ttl_days", value_parser = clap::value_parser!(u64).range(1..))]
626+
ttl_max_contracts: Option<usize>,
627627
/// Starting block number
628628
#[clap(long, short, conflicts_with = "remove-entire-cache", requires = "to")]
629629
from: Option<i32>,

node/src/manager/commands/chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ pub async fn clear_call_cache(
8383

8484
pub async fn clear_stale_call_cache(
8585
chain_store: Arc<ChainStore>,
86-
ttl_days: i32,
87-
ttl_max_contracts: Option<i64>,
86+
ttl_days: usize,
87+
ttl_max_contracts: Option<usize>,
8888
) -> Result<(), Error> {
8989
println!(
9090
"Removing stale entries from the call cache for `{}`",

0 commit comments

Comments
 (0)