You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fad56f7 doc: Properly report optional RPC args (MarcoFalke)
fa09cb6 refactor: Introduce is_top_level_arg (MarcoFalke)
fab92a5 refactor: Remove const to fix performance-move-const-arg clang-tidy errors (MarcoFalke)
Pull request description:
`OMITTED_NAMED_ARG` and `OMITTED` are a confusing burden:
* It puts the burden on developers to pick the right one of the two
* They can be interchanged without introducing a compile failure or other error
* Picking the wrong one is leading to incorrect docs
* They are redundant, because the correct one can already be determined by the surrounding type
Fix all issues by making them an alias of each other; Pick the right one based on the outer type.
ACKs for top commit:
fanquake:
ACK fad56f7
Tree-SHA512: 6e7193a05a852ba1618a9cb3261220c7ad3282bc5595325c04437aa811f529a88e2851e9c7dbf9878389b8aa42e98f8817b7eb0260fbb9e123da0893cbae6ca2
Copy file name to clipboardexpand all lines: src/rpc/util.h
+41-38
Original file line number
Diff line number
Diff line change
@@ -154,21 +154,24 @@ struct RPCArg {
154
154
/** Required arg */
155
155
NO,
156
156
/**
157
+
* The arg is optional for one of two reasons:
158
+
*
157
159
* Optional arg that is a named argument and has a default value of
158
-
* `null`. When possible, the default value should be specified.
159
-
*/
160
-
OMITTED_NAMED_ARG,
161
-
/**
160
+
* `null`.
161
+
*
162
162
* Optional argument with default value omitted because they are
163
-
* implicitly clear. That is, elements in an array or object may not
163
+
* implicitly clear. That is, elements in an array may not
164
164
* exist by default.
165
165
* When possible, the default value should be specified.
166
166
*/
167
167
OMITTED,
168
+
OMITTED_NAMED_ARG, // Deprecated alias for OMITTED, can be removed
168
169
};
170
+
/** Hint for default value */
169
171
using DefaultHint = std::string;
172
+
/** Default constant value */
170
173
using Default = UniValue;
171
-
using Fallback = std::variant<Optional, /* hint for default value */DefaultHint,/* default constant value */ Default>;
174
+
using Fallback = std::variant<Optional, DefaultHint, Default>;
172
175
173
176
const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments)
174
177
const Type m_type;
@@ -178,10 +181,10 @@ struct RPCArg {
178
181
const RPCArgOptions m_opts;
179
182
180
183
RPCArg(
181
-
conststd::string name,
182
-
constType type,
183
-
constFallback fallback,
184
-
conststd::string description,
184
+
std::string name,
185
+
Type type,
186
+
Fallback fallback,
187
+
std::string description,
185
188
RPCArgOptions opts = {})
186
189
: m_names{std::move(name)},
187
190
m_type{std::move(type)},
@@ -193,11 +196,11 @@ struct RPCArg {
193
196
}
194
197
195
198
RPCArg(
196
-
conststd::string name,
197
-
constType type,
198
-
constFallback fallback,
199
-
conststd::string description,
200
-
conststd::vector<RPCArg> inner,
199
+
std::string name,
200
+
Type type,
201
+
Fallback fallback,
202
+
std::string description,
203
+
std::vector<RPCArg> inner,
201
204
RPCArgOptions opts = {})
202
205
: m_names{std::move(name)},
203
206
m_type{std::move(type)},
@@ -234,7 +237,7 @@ struct RPCArg {
234
237
* Return the description string, including the argument type and whether
0 commit comments