From c98481c33462bdf8fdcd48ff3660fb023d40ad73 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 5 May 2018 16:49:17 -0700 Subject: [PATCH] modules/console: Improve feds state output. --- modules/console.cc | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/modules/console.cc b/modules/console.cc index 02e0778aa..6cd707d32 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -3597,19 +3597,14 @@ console_cmd__feds__state(opt &out, const string_view &line) "federation_federation", "feds__state" }; - feds__state(room_id, event_id, out.timeout, [&out] + std::forward_list origins; + std::map, std::less<>> grid; + + feds__state(room_id, event_id, out.timeout, [&out, &grid, &origins] (const string_view &origin, std::exception_ptr eptr, const json::object &response) { - out << (eptr? '-' : '+') - << " " - << std::setw(40) << std::left << origin - << " "; - if(eptr) - { - out << what(eptr) << std::endl; return true; - } const json::array &auth_chain { @@ -3621,14 +3616,35 @@ console_cmd__feds__state(opt &out, const string_view &line) response["pdu_ids"] }; - out << size(pdus) - << " " - << size(auth_chain) - << std::endl; + for(const auto &pdu_id : pdus) + { + const auto &event_id{unquote(pdu_id)}; + auto it + { + grid.lower_bound(event_id) + }; + + if(it == end(grid) || it->first != event_id) + it = grid.emplace_hint(it, event_id, std::forward_list{}); + + origins.emplace_front(origin); + it->second.emplace_front(origins.front()); + } return true; }); + for(auto &p : grid) + { + p.second.sort(); + + out << std::setw(64) << std::left << p.first << " : "; + for(const auto &origin : p.second) + out << " " << origin; + + out << std::endl; + } + return true; }