File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -465,6 +465,11 @@ impl JsonBlockCacheDB {
465465
466466 trace ! ( target: "cache" , "saved json cache" ) ;
467467 }
468+
469+ /// Returns the cache path.
470+ pub fn cache_path ( & self ) -> Option < & Path > {
471+ self . cache_path . as_deref ( )
472+ }
468473}
469474
470475/// The Data the [JsonBlockCacheDB] can read and flush
@@ -678,4 +683,19 @@ mod tests {
678683
679684 let _s = serde_json:: to_string ( & cache) . unwrap ( ) ;
680685 }
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+ }
681701}
You can’t perform that action at this time.
0 commit comments