@@ -42,15 +42,14 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
4242chaser_confirm::chaser_confirm (full_node& node) NOEXCEPT
4343 : chaser(node),
4444 concurrent_ (node.config().node.concurrent_confirmation),
45- threadpool_(1_u32, node.config().node.priority_validation ?
46- network::thread_priority::high : network::thread_priority::normal),
47- strand_(threadpool_.service().get_executor())
45+ threadpool_(one, node.config().node.priority_()),
46+ independent_strand_(threadpool_.service().get_executor())
4847{
4948}
5049
5150code chaser_confirm::start () NOEXCEPT
5251{
53- set_position (archive ().get_fork ());
52+ reset_position (archive ().get_fork ());
5453 SUBSCRIBE_EVENTS (handle_event, _1, _2, _3);
5554 return error::success;
5655}
@@ -106,9 +105,7 @@ bool chaser_confirm::handle_event(const code&, chase event_,
106105 {
107106 if (concurrent_ || mature_)
108107 {
109- // //POST(do_bump, height_t{});
110- boost::asio::post (strand_,
111- BIND (do_bump, height_t {}));
108+ POST (do_bump, height_t {});
112109 }
113110
114111 break ;
@@ -120,27 +117,21 @@ bool chaser_confirm::handle_event(const code&, chase event_,
120117
121118 if (concurrent_ || mature_)
122119 {
123- // //POST(do_validated, std::get<height_t>(value));
124- boost::asio::post (strand_,
125- BIND (do_validated, std::get<height_t >(value)));
120+ POST (do_validated, std::get<height_t >(value));
126121 }
127122
128123 break ;
129124 }
130125 case chase::regressed:
131126 {
132127 BC_ASSERT (std::holds_alternative<height_t >(value));
133- // //POST(do_regressed, std::get<height_t>(value));
134- boost::asio::post (strand_,
135- BIND (do_regressed, std::get<height_t >(value)));
128+ POST (do_regressed, std::get<height_t >(value));
136129 break ;
137130 }
138131 case chase::disorganized:
139132 {
140133 BC_ASSERT (std::holds_alternative<height_t >(value));
141- // //POST(do_regressed, std::get<height_t>(value));
142- boost::asio::post (strand_,
143- BIND (do_regressed, std::get<height_t >(value)));
134+ POST (do_regressed, std::get<height_t >(value));
144135 break ;
145136 }
146137 case chase::stop:
@@ -170,7 +161,7 @@ void chaser_confirm::do_regressed(height_t branch_point) NOEXCEPT
170161 }
171162 }
172163
173- set_position (branch_point);
164+ reset_position (branch_point);
174165}
175166
176167void chaser_confirm::do_validated (height_t height) NOEXCEPT
@@ -244,9 +235,8 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
244235 << ec.message ());
245236 return ;
246237 }
247-
248- // TODO: fees.
249- if (!query.set_block_confirmable (link, {}))
238+
239+ if (!query.set_block_confirmable (link))
250240 {
251241 fault (error::confirm6);
252242 return ;
@@ -283,6 +273,7 @@ void chaser_confirm::do_bump(height_t) NOEXCEPT
283273 return ;
284274 }
285275
276+ update_neutrino (link);
286277 set_position (height);
287278 }
288279}
@@ -617,6 +608,56 @@ bool chaser_confirm::get_is_strong(bool& strong, const uint256_t& fork_work,
617608 return true ;
618609}
619610
611+ // neutrino
612+ // ----------------------------------------------------------------------------
613+
614+ // This can only fail if prevouts are not fully populated.
615+ bool chaser_confirm::update_neutrino (const header_link& link) NOEXCEPT
616+ {
617+ // neutrino_.link is only used for this assertion, should compile away.
618+ BC_ASSERT (archive ().get_height (link) ==
619+ add1 (archive ().get_height (neutrino_.link )));
620+
621+ auto & query = archive ();
622+ if (!query.neutrino_enabled ())
623+ return true ;
624+
625+ data_chunk filter{};
626+ if (!query.get_filter_body (filter, link))
627+ return false ;
628+
629+ neutrino_.link = link;
630+ neutrino_.head = neutrino::compute_filter_header (neutrino_.head , filter);
631+ return query.set_filter_head (link, neutrino_.head );
632+ }
633+
634+ // Expects confirmed height.
635+ // Use for startup and regression, to read current filter header from store.
636+ void chaser_confirm::reset_position (size_t confirmed_height) NOEXCEPT
637+ {
638+ set_position (confirmed_height);
639+
640+ const auto & query = archive ();
641+ if (query.neutrino_enabled ())
642+ {
643+ neutrino_.link = query.to_confirmed (confirmed_height);
644+ query.get_filter_head (neutrino_.head , neutrino_.link );
645+ }
646+ }
647+
648+ // Strand.
649+ // ----------------------------------------------------------------------------
650+
651+ network::asio::strand& chaser_confirm::strand () NOEXCEPT
652+ {
653+ return independent_strand_;
654+ }
655+
656+ bool chaser_confirm::stranded () const NOEXCEPT
657+ {
658+ return independent_strand_.running_in_this_thread ();
659+ }
660+
620661BC_POP_WARNING ()
621662
622663} // namespace node
0 commit comments