diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-04-19 09:04:05 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-04-19 09:04:31 +0200 |
commit | d4300a10ddd67ceb06f0a2a27d11b556bc6e4dda (patch) | |
tree | 0a3845635ce31be135f64ac755dbe3f898c537d4 /src/rpc/server.cpp | |
parent | 17b51cd5cb9c5e02caf04d25423313392f7f81fb (diff) | |
parent | bee56c78e94417f89b1f48682404e2821b57bdec (diff) |
Merge #21679: rpc: Keep default argument value in correct type
bee56c78e94417f89b1f48682404e2821b57bdec rpc: Check default value type againts argument type (João Barbosa)
f81ef4303e057e85aa24772c865287c17ffa4350 rpc: Keep default argument value in correct type (João Barbosa)
Pull request description:
Store default values of RPC arguments in the corresponding type instead of a string. The value is then serialized when the help output is needed. This change simplifies #20017.
The following examples illustrates how to use the new `RPCArg::Default` and `RPCArg::DefaultHint`:
```diff
- {"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"}
+ {"verbose", RPCArg::Type::BOOL, RPCArg::Default(false), "True for a json object, false for array of transaction ids"}
```
```diff
- {"nblocks", RPCArg::Type::NUM, /* default */ "one month", "Size of the window in number of blocks"}
+ {"nblocks", RPCArg::Type::NUM, RPCArg::DefaultHint("one month"), "Size of the window in number of blocks"}
```
No behavior change is expected.
ACKs for top commit:
LarryRuane:
ACK bee56c78e94417f89b1f48682404e2821b57bdec
MarcoFalke:
ACK bee56c78e94417f89b1f48682404e2821b57bdec 🦅
Tree-SHA512: c47d78c918e996d36631d4ad3c933b270a34c5b446b8d736be94cf4a0a7b8c0e33d954149ec786cf9550639865b79deb6a130ad044de6030f95aac33f524293a
Diffstat (limited to 'src/rpc/server.cpp')
-rw-r--r-- | src/rpc/server.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5d816ba5bb..cf80b08b96 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -135,7 +135,7 @@ static RPCHelpMan help() return RPCHelpMan{"help", "\nList all commands, or get help for a specified command.\n", { - {"command", RPCArg::Type::STR, /* default */ "all commands", "The command to get help on"}, + {"command", RPCArg::Type::STR, RPCArg::DefaultHint{"all commands"}, "The command to get help on"}, }, { RPCResult{RPCResult::Type::STR, "", "The help text"}, |