@@ -48,7 +48,8 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT
4848 subsidy_interval_(node.config().bitcoin.subsidy_interval_blocks),
4949 initial_subsidy_(node.config().bitcoin.initial_subsidy()),
5050 maximum_backlog_(node.config().node.maximum_concurrency_()),
51- concurrent_(node.config().node.concurrent_validation)
51+ concurrent_(node.config().node.concurrent_validation),
52+ filter_(node.archive().neutrino_enabled())
5253{
5354}
5455
@@ -187,20 +188,24 @@ void chaser_validate::do_bump(height_t) NOEXCEPT
187188
188189 set_position (height);
189190
190- if ((ec == database::error::block_valid) ||
191+ const auto bypass =
192+ (ec == database::error::block_valid) ||
191193 (ec == database::error::block_confirmable) ||
192- is_under_checkpoint (height) || query.is_milestone (link))
194+ is_under_checkpoint (height) || query.is_milestone (link);
195+
196+ if (bypass && !filter_)
193197 {
194198 complete_block (error::success, link, height);
195199 continue ;
196200 }
197201
198- PARALLEL (validate_block, link);
202+ PARALLEL (validate_block, link, bypass );
199203 }
200204}
201205
202206// Unstranded (concurrent by block).
203- void chaser_validate::validate_block (const header_link& link) NOEXCEPT
207+ void chaser_validate::validate_block (const header_link& link,
208+ bool bypass) NOEXCEPT
204209{
205210 if (closed ())
206211 return ;
@@ -218,44 +223,75 @@ void chaser_validate::validate_block(const header_link& link) NOEXCEPT
218223 {
219224 ec = error::validate2;
220225 }
221- else if (!block->populate (ctx))
222- {
223- ec = system::error::relative_time_locked;
224- }
225- else if (!query.populate (*block))
226- {
227- ec = system::error::missing_previous_output;
228- }
229- else if ((ec = block->accept (ctx, subsidy_interval_, initial_subsidy_)))
226+ else if ((ec = populate (bypass, *block, ctx)))
230227 {
231228 if (!query.set_block_unconfirmable (link))
232229 ec = error::validate3;
233230 }
234- else if ((ec = block-> connect ( ctx)))
231+ else if ((ec = validate (bypass, *block, link, ctx)))
235232 {
236233 if (!query.set_block_unconfirmable (link))
237234 ec = error::validate4;
238235 }
239- else if (!query.set_block_valid (link, block-> fees () ))
236+ else if (!query.set_filter_body (link, * block))
240237 {
241238 ec = error::validate5;
242239 }
243- else if (!query. set_prevouts (link, *block))
240+ else
244241 {
245- ec = error::validate6 ;
242+ fire (events::block_validated, ctx. height ) ;
246243 }
247- else if (!query.set_filter_body (link, *block))
244+
245+ // Return to strand to handle result.
246+ POST (complete_block, ec, link, ctx.height );
247+ }
248+
249+ code chaser_validate::populate (bool bypass, const system::chain::block& block,
250+ const system::chain::context& ctx) NOEXCEPT
251+ {
252+ const auto & query = archive ();
253+
254+ // Relative locktime check is unnecessary under bypass, but cheap.
255+ if (!block.populate (ctx))
256+ return system::error::relative_time_locked;
257+
258+ if (bypass)
248259 {
249- // TODO: this should not bypass checkpoint/milestone if enabled.
250- ec = error::validate7 ;
260+ if (!query. populate_without_metadata (block))
261+ return system:: error::missing_previous_output ;
251262 }
252263 else
253264 {
254- fire (events::block_validated, ctx.height );
265+ if (!query.populate (block))
266+ return system::error::missing_previous_output;
255267 }
268+
269+ return error::success;
270+ }
256271
257- // Return to strand to handle result.
258- POST (complete_block, ec, link, ctx.height );
272+ code chaser_validate::validate (bool bypass, const system::chain::block& block,
273+ const database::header_link& link,
274+ const system::chain::context& ctx) NOEXCEPT
275+ {
276+ code ec{};
277+ if (bypass)
278+ return ec;
279+
280+ auto & query = archive ();
281+
282+ if ((ec = block.accept (ctx, subsidy_interval_, initial_subsidy_)))
283+ return ec;
284+
285+ if ((ec = block.connect (ctx)))
286+ return ec;
287+
288+ if (!query.set_block_valid (link, block.fees ()))
289+ return error::validate6;
290+
291+ if (!query.set_prevouts (link, block))
292+ return error::validate7;
293+
294+ return ec;
259295}
260296
261297void chaser_validate::complete_block (const code& ec, const header_link& link,
0 commit comments