@@ -106,7 +106,38 @@ impl Service {
106
106
107
107
let hord_config = self . config . get_hord_config ( ) ;
108
108
109
- if let Some ( ( start_block, end_block) ) = should_sync_hord_db ( & self . config , & self . ctx ) ? {
109
+ let ( tx, rx) = channel ( ) ;
110
+
111
+ let mut moved_event_observer_config = event_observer_config. clone ( ) ;
112
+ let moved_ctx = self . ctx . clone ( ) ;
113
+
114
+ let _ = hiro_system_kit:: thread_named ( "Initial predicate processing" )
115
+ . spawn ( move || {
116
+ if let Some ( mut chainhook_config) =
117
+ moved_event_observer_config. chainhook_config . take ( )
118
+ {
119
+ let mut bitcoin_predicates_ref: Vec < & BitcoinChainhookSpecification > = vec ! [ ] ;
120
+ for bitcoin_predicate in chainhook_config. bitcoin_chainhooks . iter_mut ( ) {
121
+ bitcoin_predicate. enabled = false ;
122
+ bitcoin_predicates_ref. push ( bitcoin_predicate) ;
123
+ }
124
+ while let Ok ( block) = rx. recv ( ) {
125
+ let future = process_block_with_predicates (
126
+ block,
127
+ & bitcoin_predicates_ref,
128
+ & moved_event_observer_config,
129
+ & moved_ctx,
130
+ ) ;
131
+ let res = hiro_system_kit:: nestable_block_on ( future) ;
132
+ if let Err ( _) = res {
133
+ error ! ( moved_ctx. expect_logger( ) , "Initial ingestion failing" ) ;
134
+ }
135
+ }
136
+ }
137
+ } )
138
+ . expect ( "unable to spawn thread" ) ;
139
+
140
+ while let Some ( ( start_block, end_block) ) = should_sync_hord_db ( & self . config , & self . ctx ) ? {
110
141
if start_block == 0 {
111
142
info ! (
112
143
self . ctx. expect_logger( ) ,
@@ -119,44 +150,12 @@ impl Service {
119
150
) ;
120
151
}
121
152
122
- let ( tx, rx) = channel ( ) ;
123
-
124
- let mut moved_event_observer_config = event_observer_config. clone ( ) ;
125
- let moved_ctx = self . ctx . clone ( ) ;
126
-
127
- let _ = hiro_system_kit:: thread_named ( "Initial predicate processing" )
128
- . spawn ( move || {
129
- if let Some ( mut chainhook_config) =
130
- moved_event_observer_config. chainhook_config . take ( )
131
- {
132
- let mut bitcoin_predicates_ref: Vec < & BitcoinChainhookSpecification > =
133
- vec ! [ ] ;
134
- for bitcoin_predicate in chainhook_config. bitcoin_chainhooks . iter_mut ( ) {
135
- bitcoin_predicate. enabled = false ;
136
- bitcoin_predicates_ref. push ( bitcoin_predicate) ;
137
- }
138
- while let Ok ( block) = rx. recv ( ) {
139
- let future = process_block_with_predicates (
140
- block,
141
- & bitcoin_predicates_ref,
142
- & moved_event_observer_config,
143
- & moved_ctx,
144
- ) ;
145
- let res = hiro_system_kit:: nestable_block_on ( future) ;
146
- if let Err ( _) = res {
147
- error ! ( moved_ctx. expect_logger( ) , "Initial ingestion failing" ) ;
148
- }
149
- }
150
- }
151
- } )
152
- . expect ( "unable to spawn thread" ) ;
153
-
154
153
crate :: hord:: perform_hord_db_update (
155
154
start_block,
156
155
end_block,
157
156
& self . config . get_hord_config ( ) ,
158
157
& self . config ,
159
- Some ( tx) ,
158
+ Some ( tx. clone ( ) ) ,
160
159
& self . ctx ,
161
160
)
162
161
. await ?;
0 commit comments