diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-01-25 19:48:26 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-01-25 20:05:44 +0100 |
commit | fac8caaa6252c6e18301a263d325d63197062639 (patch) | |
tree | 7b4e5d71b0129733cb82148afcbd0452355e165b /src/rpc/util.cpp | |
parent | 39d9bbe4acd7441aa9a61c57b76d887c4225a0e2 (diff) | |
download | bitcoin-fac8caaa6252c6e18301a263d325d63197062639.tar.xz |
doc: Fix rpc docs
Broken in commit 39d9bbe4acd7441aa9a61c57b76d887c4225a0e2
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r-- | src/rpc/util.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index ae2f319f6c..5ef7e26ce8 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -830,16 +830,15 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const return; } case Type::OBJ_DYN: - case Type::OBJ_EMPTY: { - sections.PushSection({indent + maybe_key + "{}", Description("empty JSON object")}); - return; - } case Type::OBJ: { + if (m_inner.empty()) { + sections.PushSection({indent + maybe_key + "{}", Description("empty JSON object")}); + return; + } sections.PushSection({indent + maybe_key + "{", Description("json object")}); for (const auto& i : m_inner) { i.ToSections(sections, OuterType::OBJ, current_indent + 2); } - CHECK_NONFATAL(!m_inner.empty()); if (m_type == Type::OBJ_DYN && m_inner.back().m_type != Type::ELISION) { // If the dictionary keys are dynamic, use three dots for continuation sections.PushSection({indent_next + "...", ""}); @@ -883,7 +882,6 @@ bool RPCResult::MatchesType(const UniValue& result) const return UniValue::VARR == result.getType(); } case Type::OBJ_DYN: - case Type::OBJ_EMPTY: case Type::OBJ: { return UniValue::VOBJ == result.getType(); } @@ -891,6 +889,17 @@ bool RPCResult::MatchesType(const UniValue& result) const CHECK_NONFATAL(false); } +void RPCResult::CheckInnerDoc() const +{ + if (m_type == Type::OBJ) { + // May or may not be empty + return; + } + // Everything else must either be empty or not + const bool inner_needed{m_type == Type::ARR || m_type == Type::ARR_FIXED || m_type == Type::OBJ_DYN}; + CHECK_NONFATAL(inner_needed != m_inner.empty()); +} + std::string RPCArg::ToStringObj(const bool oneline) const { std::string res; |