File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -465,6 +465,11 @@ impl JsonBlockCacheDB {
465
465
466
466
trace ! ( target: "cache" , "saved json cache" ) ;
467
467
}
468
+
469
+ /// Returns the cache path.
470
+ pub fn cache_path ( & self ) -> Option < & Path > {
471
+ self . cache_path . as_deref ( )
472
+ }
468
473
}
469
474
470
475
/// The Data the [JsonBlockCacheDB] can read and flush
@@ -678,4 +683,19 @@ mod tests {
678
683
679
684
let _s = serde_json:: to_string ( & cache) . unwrap ( ) ;
680
685
}
686
+
687
+ #[ test]
688
+ fn can_return_cache_path_if_set ( ) {
689
+ // set
690
+ let cache_db = JsonBlockCacheDB :: new (
691
+ Arc :: new ( RwLock :: new ( BlockchainDbMeta :: default ( ) ) ) ,
692
+ Some ( PathBuf :: from ( "/tmp/foo" ) ) ,
693
+ ) ;
694
+ assert_eq ! ( Some ( Path :: new( "/tmp/foo" ) ) , cache_db. cache_path( ) ) ;
695
+
696
+ // unset
697
+ let cache_db =
698
+ JsonBlockCacheDB :: new ( Arc :: new ( RwLock :: new ( BlockchainDbMeta :: default ( ) ) ) , None ) ;
699
+ assert_eq ! ( None , cache_db. cache_path( ) ) ;
700
+ }
681
701
}
You can’t perform that action at this time.
0 commit comments