aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-08-22 08:40:40 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-08-22 08:41:00 -0400
commit52b9797119d5ee20b255efc68931ac7e158e325d (patch)
treefe2d8a5f7c9e473c28ba0a086bafcaba8d6da25b /src/rpc
parent868a8cea15504118237da2f27bc8e79dd8af77f6 (diff)
parentfaebf6271467048dc8a9a0c526a0f8565023a966 (diff)
downloadbitcoin-52b9797119d5ee20b255efc68931ac7e158e325d.tar.xz
Merge #16670: util: Add Join helper to join a list of strings
faebf6271467048dc8a9a0c526a0f8565023a966 rpc: Use Join helper in rpc/util (MarcoFalke) fa8cd6f9c13319baca467864661982a3dfb2320c util: Add Join helper to join a list of strings (MarcoFalke) Pull request description: We have a lot of enumerations in the code and sometimes those enumerations need to be mentioned in the RPC or command line documentation. Previously, each caller would have a couple of lines inline to join the strings or the joined string is hardcoded in the documentation. A helper to join strings would make code such as https://github.com/bitcoin/bitcoin/pull/16629#discussion_r315852446 less verbose and easier to read. Also, warnings commonly accumulate in complex RPCs, since a warning doesn't lead to an early return. A helper to join those warnings would make code such as https://github.com/bitcoin/bitcoin/pull/16394/files#r309324997 less verbose and easier to read. ACKs for top commit: practicalswift: ACK faebf6271467048dc8a9a0c526a0f8565023a966 Tree-SHA512: 80f2db86a05c63b686f510585c1c631250271a8958fd71fafaac91559ffd2ec25d609bf7d53412ba27f87eff5893ac9dd9c2f296fc0c73581556e1d6a734a36f
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/util.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 464537a5b0..22d67c34da 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -4,11 +4,12 @@
#include <key_io.h>
#include <outputtype.h>
-#include <script/signingprovider.h>
#include <rpc/util.h>
#include <script/descriptor.h>
+#include <script/signingprovider.h>
#include <tinyformat.h>
#include <util/strencodings.h>
+#include <util/string.h>
#include <tuple>
@@ -645,11 +646,7 @@ std::string RPCArg::ToString(const bool oneline) const
}
case Type::OBJ:
case Type::OBJ_USER_KEYS: {
- std::string res;
- for (size_t i = 0; i < m_inner.size();) {
- res += m_inner[i].ToStringObj(oneline);
- if (++i < m_inner.size()) res += ",";
- }
+ const std::string res = Join(m_inner, ",", [&](const RPCArg& i) { return i.ToStringObj(oneline); });
if (m_type == Type::OBJ) {
return "{" + res + "}";
} else {