Page MenuHomePhabricator

rpc: refactor Ensure* functions
ClosedPublic

Authored by PiRK on Jun 8 2022, 15:24.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC041fad036e3e: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jun 8 2022, 15:24
This revision is now accepted and ready to land.Jun 9 2022, 14:59
This revision was automatically updated to reflect the committed changes.