Skip to content

Commit fa652b2

Browse files
author
MarcoFalke
committed
rpc: Add some doxygen comments to utils
1 parent 2c364fd commit fa652b2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/rpc/util.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,21 @@ UniValue JSONRPCTransactionError(TransactionError terr, const std::string& err_s
165165
}
166166
}
167167

168+
/**
169+
* A pair of strings that can be aligned (through padding) with other Sections
170+
* later on
171+
*/
168172
struct Section {
169173
Section(const std::string& left, const std::string& right)
170174
: m_left{left}, m_right{right} {}
171175
const std::string m_left;
172176
const std::string m_right;
173177
};
174178

179+
/**
180+
* Keeps track of RPCArgs by transforming them into sections for the purpose
181+
* of serializing everything to a single string
182+
*/
175183
struct Sections {
176184
std::vector<Section> m_sections;
177185
size_t m_max_pad{0};
@@ -182,12 +190,20 @@ struct Sections {
182190
m_sections.push_back(s);
183191
}
184192

193+
/**
194+
* Serializing RPCArgs depends on the outer type. Only arrays and
195+
* dictionaries can be nested in json. The top-level outer type is "named
196+
* arguments", a mix between a dictionary and arrays.
197+
*/
185198
enum class OuterType {
186199
ARR,
187200
OBJ,
188201
NAMED_ARG, // Only set on first recursion
189202
};
190203

204+
/**
205+
* Recursive helper to translate an RPCArg into sections
206+
*/
191207
void Push(const RPCArg& arg, const size_t current_indent = 5, const OuterType outer_type = OuterType::NAMED_ARG)
192208
{
193209
const auto indent = std::string(current_indent, ' ');
@@ -241,6 +257,9 @@ struct Sections {
241257
}
242258
}
243259

260+
/**
261+
* Concatenate all sections with proper padding
262+
*/
244263
std::string ToString() const
245264
{
246265
std::string ret;

0 commit comments

Comments
 (0)