HomePhabricator

[checkqueue] support user-defined return type through std::optional

Description

[checkqueue] support user-defined return type through std::optional

Summary:
The check type function now needs to return a std::optional<R> for some type R,
and the check queue overall will return std::nullopt if all individual checks
return that, or one of the non-nullopt values if there is at least one.

For most tests, we use R=int, but for the actual validation code, we make it return
the ScriptError.

This is a partial backport of core#31112
https://github.com/bitcoin/bitcoin/pull/31112/commits/1ac1c33f3f120bbe0bde4fa948299bc07cac47ee

Note that there is a minor difference in validation.cpp (scriptError vs error) because a nearly identical work on improving the error message was done independently by Bitcoin ABC and Bitcoin Core:

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18876

Details

Provenance
Pieter Wuille <pieter@wuille.net>Authored on Oct 16 2024, 09:53
PiRKCommitted on Wed, Nov 5, 20:46
PiRKPushed on Wed, Nov 5, 20:46
Reviewer
Restricted Project
Differential Revision
D18876: [checkqueue] support user-defined return type through std::optional
Parents
rABCadb30b7ab03d: log: Mitigate disk filling attacks by rate limiting LogPrintf, LogInfo…
Branches
Unknown
Tags
Unknown