HomePhabricator

rpc: refactor Ensure* functions

Description

rpc: refactor Ensure* functions

Summary:
Add alt Ensure* functions accepting NodeContext and rename the versions accepting a std::any EnsureAny*().

Note that the changes in rest.cpp are not applicable because of the out-of-sequence backport of commit https://github.com/bitcoin/bitcoin/pull/21767/commits/9ecade14252ad1972f668d2d2e4ef44fdfcb944a in D11585

rpc: Add alt Ensure* functions acepting NodeContext

https://github.com/bitcoin/bitcoin/pull/21391/commits/306b1cd3eeb2502904ed4698646d2c86d028aad2

rpc: Add renamed EnsureAny*() functions

The renaming avoids overloading mistakes arising out of the untyped std::any argument.

https://github.com/bitcoin/bitcoin/pull/21391/commits/1570c7ee98612366df031bebef9e0468fb57b8a2

scripted-diff: rest/rpc: Use renamed EnsureAny*()

-BEGIN VERIFY SCRIPT-
sed -i -E 's@Ensure([^(]+)(\((request\.|)context\))@EnsureAny\1\2@g' \
    -- src/rest.cpp src/rpc/*.cpp

-END VERIFY SCRIPT-

https://github.com/bitcoin/bitcoin/pull/21391/commits/6fb65b49f4d393b091479be5a5df5a0a160cf986

rest/rpc: Remove now-unused old Ensure functions

The scripted-diff in the previous commit should have removed all calls
to functions like: Ensure(?!Any)\(const std::any& (context|ctx)\), so we
can remove them now.

https://github.com/bitcoin/bitcoin/pull/21391/commits/038854f31e3511e8bb6e163305cab0a96783d25b

This is a backport of core#21391 [8, 9, 10 & 11/14]

Depends on D11584

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Apr 12 2021, 22:25
PiRKCommitted on Jun 9 2022, 16:19
PiRKPushed on Jun 9 2022, 16:19
Reviewer
Restricted Project
Differential Revision
D11586: rpc: refactor Ensure* functions
Parents
rABCc3bd9bc2d4b6: rest: Pass in NodeContext to rest_block and use it
Branches
Unknown
Tags
Unknown