File tree 1 file changed +17
-1
lines changed
components/chainhook-sdk/src/hord/db
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ pub fn find_lazy_block_at_block_height(
254
254
blocks_db : & DB ,
255
255
ctx : & Context ,
256
256
) -> Option < LazyBlock > {
257
- let mut attempt = 0 ;
257
+ let mut attempt = 1 ;
258
258
// let mut read_options = rocksdb::ReadOptions::default();
259
259
// read_options.fill_cache(true);
260
260
// read_options.set_verify_checksums(false);
@@ -265,6 +265,22 @@ pub fn find_lazy_block_at_block_height(
265
265
match blocks_db. get ( block_height. to_be_bytes ( ) ) {
266
266
Ok ( Some ( res) ) => return Some ( LazyBlock :: new ( res) ) ,
267
267
_ => {
268
+ if attempt == 1 {
269
+ ctx. try_log ( |logger| {
270
+ slog:: warn!(
271
+ logger,
272
+ "Attempt to retrieve block {} through iterator" ,
273
+ block_height,
274
+ )
275
+ } ) ;
276
+ let mut iter = blocks_db. iterator ( rocksdb:: IteratorMode :: End ) ;
277
+ let block_height_bytes = block_height. to_be_bytes ( ) ;
278
+ while let Some ( Ok ( ( k, res) ) ) = iter. next ( ) {
279
+ if ( * k) . eq ( & block_height_bytes) {
280
+ return Some ( LazyBlock :: new ( res. to_vec ( ) ) ) ;
281
+ }
282
+ }
283
+ }
268
284
attempt += 1 ;
269
285
backoff = 2.0 * backoff + ( backoff * rng. gen_range ( 0.0 ..1.0 ) ) ;
270
286
let duration = std:: time:: Duration :: from_millis ( ( backoff * 1_000.0 ) as u64 ) ;
You can’t perform that action at this time.
0 commit comments