@@ -12,7 +12,10 @@ use chainhook_sdk::{
12
12
utils:: Context ,
13
13
} ;
14
14
15
- use crate :: config:: { Config , LogConfig } ;
15
+ use crate :: {
16
+ config:: { Config , LogConfig } ,
17
+ db:: find_lazy_block_at_block_height,
18
+ } ;
16
19
17
20
use crate :: db:: {
18
21
find_last_block_inserted, find_latest_inscription_block_height, initialize_ordhook_db,
@@ -107,16 +110,8 @@ pub fn should_sync_ordhook_db(
107
110
}
108
111
} ;
109
112
110
- let mut start_block =
111
- match open_readonly_ordhook_db_conn_rocks_db ( & config. expected_cache_path ( ) , & ctx) {
112
- Ok ( blocks_db) => find_last_block_inserted ( & blocks_db) as u64 ,
113
- Err ( err) => {
114
- ctx. try_log ( |logger| {
115
- warn ! ( logger, "{}" , err) ;
116
- } ) ;
117
- 0
118
- }
119
- } ;
113
+ let blocks_db = open_readonly_ordhook_db_conn_rocks_db ( & config. expected_cache_path ( ) , & ctx) ?;
114
+ let mut start_block = find_last_block_inserted ( & blocks_db) as u64 ;
120
115
121
116
if start_block == 0 {
122
117
let _ = initialize_ordhook_db ( & config. expected_cache_path ( ) , & ctx) ;
@@ -126,7 +121,12 @@ pub fn should_sync_ordhook_db(
126
121
127
122
match find_latest_inscription_block_height ( & inscriptions_db_conn, ctx) ? {
128
123
Some ( height) => {
129
- start_block = start_block. min ( height) ;
124
+ if find_lazy_block_at_block_height ( height as u32 , 3 , false , & blocks_db, & ctx) . is_none ( )
125
+ {
126
+ start_block = start_block. min ( height) ;
127
+ } else {
128
+ start_block = height;
129
+ }
130
130
}
131
131
None => {
132
132
start_block = start_block. min ( config. get_ordhook_config ( ) . first_inscription_height ) ;
0 commit comments