aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-04 03:07:57 +0800
committerMarcoFalke <falke.marco@gmail.com>2020-04-04 03:08:05 +0800
commite35e118656e9638cce019d4eeffc5f1b8639d4f5 (patch)
tree29b0b09ed654b4db8ed41be51db6b4013a9aebe3
parentf0d6487e290761a4fb03798240a351b5fddfdb38 (diff)
parentf32ab443a98e622afa601372454310aef1f380be (diff)
downloadbitcoin-e35e118656e9638cce019d4eeffc5f1b8639d4f5.tar.xz
Merge #18508: RPC: Fix more formatting nits
f32ab443a98e622afa601372454310aef1f380be Bugfix: RPC: JSON null is not "None" (Luke Dashjr) 26dcf3958187cbdc9ffc9438a5eebfcaf607f7e9 Bugfix: RPC: Don't use a continuation elipsis after an elision elipsis (Luke Dashjr) eca65caadcddf43b2dace111bd7e4b0a2a9556c2 Bugfix: RPC: Add missing commas and correct indentation of explicit ELISION (Luke Dashjr) Pull request description: 1. listsinceblock had a double ellipsis (elision + continuation); this looks ugly, just one is needed. 2. Elision ellipsis wasn't getting a comma, so was truncated to `".."` by comma-removal code. 3. Elision ellipsis was indented incorrectly (as if it was a subitem). 4. Similarly, type "none" would get truncated to `"Non"`, when it should really be `"null"` anyway. ACKs for top commit: MarcoFalke: ACK f32ab443a98e622afa601372454310aef1f380be 🐰 Tree-SHA512: 34e1c72673790ed11cdee838d64ea5e0ac498de19258df99d54b5322e003060123c65ad27ac2fd4729a1dfe52066a0629602a132b1ef85d4154affd99a065a3f
-rw-r--r--src/rpc/util.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 32e0e1ec27..7e1fb7a59d 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -606,11 +606,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
switch (m_type) {
case Type::ELISION: {
// If the inner result is empty, use three dots for elision
- sections.PushSection({indent_next + "...", m_description});
+ sections.PushSection({indent + "..." + maybe_separator, m_description});
return;
}
case Type::NONE: {
- sections.PushSection({indent + "None", Description("json null")});
+ sections.PushSection({indent + "null" + maybe_separator, Description("json null")});
return;
}
case Type::STR: {
@@ -643,10 +643,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
for (const auto& i : m_inner) {
i.ToSections(sections, OuterType::ARR, current_indent + 2);
}
- if (m_type == Type::ARR) {
+ CHECK_NONFATAL(!m_inner.empty());
+ if (m_type == Type::ARR && m_inner.back().m_type != Type::ELISION) {
sections.PushSection({indent_next + "...", ""});
} else {
- CHECK_NONFATAL(!m_inner.empty());
// Remove final comma, which would be invalid JSON
sections.m_sections.back().m_left.pop_back();
}
@@ -659,11 +659,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
for (const auto& i : m_inner) {
i.ToSections(sections, OuterType::OBJ, current_indent + 2);
}
- if (m_type == Type::OBJ_DYN) {
+ 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 + "...", ""});
} else {
- CHECK_NONFATAL(!m_inner.empty());
// Remove final comma, which would be invalid JSON
sections.m_sections.back().m_left.pop_back();
}