Skip to content

Commit d0ed369

Browse files
committed
Merge bitcoin#34049: rpc: Disallow captures in RPCMethodImpl
5a81d73 scripted-diff: rpc: Don't pointlessly capture in RPCMethod lambdas (Anthony Towns) 4e78929 scripted-diff: rpc: Rename RPCHelpMan to RPCMethod (Anthony Towns) Pull request description: When defining `RPCHelpMan` objects, we usually return a lambda, and mostly we define those via `[&](...) { ... }` which explicitly captures any parameters or local variables by reference. If we were to actually use any of those captures (we don't), we would invoke undefined behaviour. So instead, convert all the `[&]` to `[]` to avoid capturing. While we're at it, rename `RPCHelpMan` to `RPCMethod`, reflecting its greater responsibility since bitcoin#19386. ACKs for top commit: maflcko: review ACK 5a81d73 🏣 stickies-v: ACK 5a81d73 rkrux: code review ACK 5a81d73 Tree-SHA512: 72e9232857ba5bf4c346fb963a2028047f7c7e9b420ef58b3108669204bfbb6952342cfcfd2e8a06f813a21545abf7fc8b0ad422f00d7ec9c1134626cd1650e6
2 parents 5deed3d + 5a81d73 commit d0ed369

27 files changed

+577
-577
lines changed

src/qt/test/rpcnestedtests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include <string>
1717
#include <stdexcept>
1818

19-
static RPCHelpMan rpcNestedTest_rpc()
19+
static RPCMethod rpcNestedTest_rpc()
2020
{
21-
return RPCHelpMan{
21+
return RPCMethod{
2222
"rpcNestedTest",
2323
"echo the passed string(s)",
2424
{
@@ -28,7 +28,7 @@ static RPCHelpMan rpcNestedTest_rpc()
2828
},
2929
RPCResult{RPCResult::Type::ANY, "", ""},
3030
RPCExamples{""},
31-
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
31+
[](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue {
3232
return request.params.write(0, 0);
3333
},
3434
};

src/rest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static bool rest_block_filter(const std::any& context, HTTPRequest* req, const s
711711
}
712712

713713
// A bit of a hack - dependency on a function defined in rpc/blockchain.cpp
714-
RPCHelpMan getblockchaininfo();
714+
RPCMethod getblockchaininfo();
715715

716716
static bool rest_chaininfo(const std::any& context, HTTPRequest* req, const std::string& uri_part)
717717
{
@@ -738,7 +738,7 @@ static bool rest_chaininfo(const std::any& context, HTTPRequest* req, const std:
738738
}
739739

740740

741-
RPCHelpMan getdeploymentinfo();
741+
RPCMethod getdeploymentinfo();
742742

743743
static bool rest_deploymentinfo(const std::any& context, HTTPRequest* req, const std::string& str_uri_part)
744744
{

0 commit comments

Comments
 (0)