Skip to content

Commit 69d5e2d

Browse files
committed
graph: Make IPFS cache methods async
1 parent 2b464d1 commit 69d5e2d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

graph/src/components/link_resolver/ipfs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ impl Cache {
3838
}
3939
}
4040

41-
fn find(&self, path: &ContentPath) -> Option<Vec<u8>> {
41+
async fn find(&self, path: &ContentPath) -> Option<Vec<u8>> {
4242
match self {
4343
Cache::Memory { cache } => cache.lock().unwrap().get(path).cloned(),
4444
}
4545
}
4646

47-
fn insert(&self, path: ContentPath, data: Vec<u8>) {
47+
async fn insert(&self, path: ContentPath, data: Vec<u8>) {
4848
match self {
4949
Cache::Memory { cache } => {
5050
let mut cache = cache.lock().unwrap();
@@ -111,7 +111,7 @@ impl LinkResolverTrait for IpfsResolver {
111111
let max_file_size = self.max_file_size;
112112
let max_cache_file_size = self.max_cache_file_size;
113113

114-
if let Some(data) = self.cache.find(&path) {
114+
if let Some(data) = self.cache.find(&path).await {
115115
trace!(logger, "IPFS cat cache hit"; "hash" => path.to_string());
116116
return Ok(data.to_owned());
117117
}
@@ -132,7 +132,7 @@ impl LinkResolverTrait for IpfsResolver {
132132
.to_vec();
133133

134134
if data.len() <= max_cache_file_size {
135-
self.cache.insert(path.clone(), data.clone());
135+
self.cache.insert(path.clone(), data.clone()).await;
136136
} else {
137137
debug!(
138138
logger,

0 commit comments

Comments
 (0)