@@ -269,51 +269,6 @@ impl BlockDir {
269269 Ok ( decompressed_bytes)
270270 }
271271
272- /// Return the entire contents of the block.
273- ///
274- /// Checks that the hash is correct with the contents.
275- #[ instrument( skip( self , monitor) ) ]
276- pub async fn get_async ( & self , hash : & BlockHash , monitor : Arc < dyn Monitor > ) -> Result < Bytes > {
277- // TODO: Tokio locks on caches
278- if let Some ( hit) = self . cache . write ( ) . expect ( "Lock cache" ) . get ( hash) {
279- monitor. count ( Counter :: BlockContentCacheHit , 1 ) ;
280- self . stats . cache_hit . fetch_add ( 1 , Relaxed ) ;
281- trace ! ( "Block cache hit" ) ;
282- return Ok ( hit. clone ( ) ) ;
283- }
284- monitor. count ( Counter :: BlockContentCacheMiss , 1 ) ;
285- let mut decompressor = Decompressor :: new ( ) ;
286- let block_relpath = block_relpath ( hash) ;
287- let compressed_bytes = self . transport . read ( & block_relpath) . await ?;
288- let decompressed_bytes = decompressor. decompress ( & compressed_bytes) ?;
289- let actual_hash = BlockHash :: hash_bytes ( & decompressed_bytes) ;
290- if actual_hash != * hash {
291- return Err ( Error :: BlockCorrupt { hash : hash. clone ( ) } ) ;
292- }
293- self . cache
294- . write ( )
295- . expect ( "Lock cache" )
296- . put ( hash. clone ( ) , decompressed_bytes. clone ( ) ) ;
297- self . exists
298- . write ( )
299- . expect ( "Lock existence cache" )
300- . put ( hash. clone ( ) , ( ) ) ;
301- self . stats . read_blocks . fetch_add ( 1 , Relaxed ) ;
302- monitor. count ( Counter :: BlockReads , 1 ) ;
303- self . stats
304- . read_block_compressed_bytes
305- . fetch_add ( compressed_bytes. len ( ) , Relaxed ) ;
306- monitor. count ( Counter :: BlockReadCompressedBytes , compressed_bytes. len ( ) ) ;
307- self . stats
308- . read_block_uncompressed_bytes
309- . fetch_add ( decompressed_bytes. len ( ) , Relaxed ) ;
310- monitor. count (
311- Counter :: BlockReadUncompressedBytes ,
312- decompressed_bytes. len ( ) ,
313- ) ;
314- Ok ( decompressed_bytes)
315- }
316-
317272 pub ( crate ) async fn delete_block ( & self , hash : & BlockHash ) -> Result < ( ) > {
318273 self . cache . write ( ) . expect ( "Lock cache" ) . pop ( hash) ;
319274 self . exists . write ( ) . unwrap ( ) . pop ( hash) ;
0 commit comments