File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -198,13 +198,38 @@ bool CLASS::get_filter_head(hash_digest& out,
198198 return true ;
199199}
200200
201+ TEMPLATE
202+ bool CLASS::set_filter_head (const header_link& link) NOEXCEPT
203+ {
204+ if (!neutrino_enabled ())
205+ return true ;
206+
207+ // The filter body must have been previously stored under the block link.
208+ filter bytes{};
209+ if (!get_filter_body (bytes, link))
210+ return false ;
211+
212+ // If genesis then previous is null_hash otherwise get by confirmed height.
213+ hash_digest previous{};
214+ const auto height = get_height (link);
215+ if (!is_zero (height))
216+ if (!get_filter_head (previous, to_confirmed (sub1 (height))))
217+ return false ;
218+
219+ // Use the previous head and current body to compute the current head.
220+ return set_filter_head (link,
221+ system::neutrino::compute_filter_header (previous, bytes));
222+ }
223+
201224TEMPLATE
202225bool CLASS::set_filter_body (const header_link& link,
203226 const block& block) NOEXCEPT
204227{
205- filter bytes{};
228+ if (!neutrino_enabled ())
229+ return true ;
206230
207- // compute_filter is only false if prevouts are missing.
231+ // Compute the current filter from the block and store under the link.
232+ filter bytes{};
208233 return system::neutrino::compute_filter (bytes, block) &&
209234 set_filter_body (link, bytes);
210235}
Original file line number Diff line number Diff line change @@ -543,6 +543,7 @@ class query
543543 bool get_filter_head (hash_digest& out, const header_link& link) const NOEXCEPT;
544544 bool set_filter_body (const header_link& link, const block& block) NOEXCEPT;
545545 bool set_filter_body (const header_link& link, const filter& body) NOEXCEPT;
546+ bool set_filter_head (const header_link& link) NOEXCEPT;
546547 bool set_filter_head (const header_link& link,
547548 const hash_digest& head) NOEXCEPT;
548549
You can’t perform that action at this time.
0 commit comments