Skip to content

Commit e35e118

Browse files
author
MarcoFalke
committed
Merge #18508: RPC: Fix more formatting nits
f32ab44 Bugfix: RPC: JSON null is not "None" (Luke Dashjr) 26dcf39 Bugfix: RPC: Don't use a continuation elipsis after an elision elipsis (Luke Dashjr) eca65ca 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 f32ab44 🐰 Tree-SHA512: 34e1c72673790ed11cdee838d64ea5e0ac498de19258df99d54b5322e003060123c65ad27ac2fd4729a1dfe52066a0629602a132b1ef85d4154affd99a065a3f
2 parents f0d6487 + f32ab44 commit e35e118

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/rpc/util.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
606606
switch (m_type) {
607607
case Type::ELISION: {
608608
// If the inner result is empty, use three dots for elision
609-
sections.PushSection({indent_next + "...", m_description});
609+
sections.PushSection({indent + "..." + maybe_separator, m_description});
610610
return;
611611
}
612612
case Type::NONE: {
613-
sections.PushSection({indent + "None", Description("json null")});
613+
sections.PushSection({indent + "null" + maybe_separator, Description("json null")});
614614
return;
615615
}
616616
case Type::STR: {
@@ -643,10 +643,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
643643
for (const auto& i : m_inner) {
644644
i.ToSections(sections, OuterType::ARR, current_indent + 2);
645645
}
646-
if (m_type == Type::ARR) {
646+
CHECK_NONFATAL(!m_inner.empty());
647+
if (m_type == Type::ARR && m_inner.back().m_type != Type::ELISION) {
647648
sections.PushSection({indent_next + "...", ""});
648649
} else {
649-
CHECK_NONFATAL(!m_inner.empty());
650650
// Remove final comma, which would be invalid JSON
651651
sections.m_sections.back().m_left.pop_back();
652652
}
@@ -659,11 +659,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
659659
for (const auto& i : m_inner) {
660660
i.ToSections(sections, OuterType::OBJ, current_indent + 2);
661661
}
662-
if (m_type == Type::OBJ_DYN) {
662+
CHECK_NONFATAL(!m_inner.empty());
663+
if (m_type == Type::OBJ_DYN && m_inner.back().m_type != Type::ELISION) {
663664
// If the dictionary keys are dynamic, use three dots for continuation
664665
sections.PushSection({indent_next + "...", ""});
665666
} else {
666-
CHECK_NONFATAL(!m_inner.empty());
667667
// Remove final comma, which would be invalid JSON
668668
sections.m_sections.back().m_left.pop_back();
669669
}

0 commit comments

Comments
 (0)