mirror of
https://github.com/matrix-construct/construct
synced 2025-02-27 06:00:16 +01:00
ircd:Ⓜ️ Update pretty(event)/pretty(event::prev) for version compat; reuse.
This commit is contained in:
parent
e7b66eac3b
commit
8b3a2b89f6
1 changed files with 34 additions and 61 deletions
|
@ -87,44 +87,12 @@ ircd::m::pretty(std::ostream &s,
|
||||||
s << std::endl;
|
s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &auth_events{json::get<"auth_events"_>(event)};
|
const m::event::prev prev
|
||||||
for(const json::array auth_event : auth_events)
|
|
||||||
{
|
{
|
||||||
s << std::setw(16) << std::right << "[auth event]"
|
event
|
||||||
<< " :" << unquote(auth_event[0]);
|
};
|
||||||
|
|
||||||
for(const auto &hash : json::object{auth_event[1]})
|
pretty(s, prev);
|
||||||
s << " " << unquote(hash.first)
|
|
||||||
<< ": " << unquote(hash.second);
|
|
||||||
|
|
||||||
s << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &prev_states{json::get<"prev_state"_>(event)};
|
|
||||||
for(const json::array prev_state : prev_states)
|
|
||||||
{
|
|
||||||
s << std::setw(16) << std::right << "[prev state]"
|
|
||||||
<< " :" << unquote(prev_state[0]);
|
|
||||||
|
|
||||||
for(const auto &hash : json::object{prev_state[1]})
|
|
||||||
s << " " << unquote(hash.first)
|
|
||||||
<< ": " << unquote(hash.second);
|
|
||||||
|
|
||||||
s << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &prev_events{json::get<"prev_events"_>(event)};
|
|
||||||
for(const json::array prev_event : prev_events)
|
|
||||||
{
|
|
||||||
s << std::setw(16) << std::right << "[prev_event]"
|
|
||||||
<< " :" << unquote(prev_event[0]);
|
|
||||||
|
|
||||||
for(const auto &hash : json::object{prev_event[1]})
|
|
||||||
s << " " << unquote(hash.first)
|
|
||||||
<< ": " << unquote(hash.second);
|
|
||||||
|
|
||||||
s << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!contents.empty())
|
if(!contents.empty())
|
||||||
for(const json::object::member &content : contents)
|
for(const json::object::member &content : contents)
|
||||||
|
@ -327,48 +295,53 @@ std::ostream &
|
||||||
ircd::m::pretty(std::ostream &s,
|
ircd::m::pretty(std::ostream &s,
|
||||||
const event::prev &prev)
|
const event::prev &prev)
|
||||||
{
|
{
|
||||||
const auto out{[&s]
|
for(size_t i(0); i < prev.auth_events_count(); ++i)
|
||||||
(const string_view &key, auto&& val)
|
|
||||||
{
|
{
|
||||||
if(json::defined(val))
|
const auto &[event_id, ref_hash]
|
||||||
s << key << " :" << val << std::endl;
|
{
|
||||||
}};
|
prev.auth_events(i)
|
||||||
|
};
|
||||||
|
|
||||||
const auto &auth_events{json::get<"auth_events"_>(prev)};
|
|
||||||
for(const json::array auth_event : auth_events)
|
|
||||||
{
|
|
||||||
s << std::setw(16) << std::right << "[auth event]"
|
s << std::setw(16) << std::right << "[auth event]"
|
||||||
<< " :" << unquote(auth_event[0]);
|
<< " :" << event_id;
|
||||||
|
|
||||||
for(const auto &hash : json::object{auth_event[1]})
|
for(const auto &[algorithm, digest] : ref_hash)
|
||||||
s << " " << unquote(hash.first)
|
s << " " << unquote(algorithm)
|
||||||
<< ": " << unquote(hash.second);
|
<< ": " << unquote(digest);
|
||||||
|
|
||||||
s << std::endl;
|
s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &prev_states{json::get<"prev_state"_>(prev)};
|
for(size_t i(0); i < prev.prev_states_count(); ++i)
|
||||||
for(const json::array prev_state : prev_states)
|
|
||||||
{
|
{
|
||||||
s << std::setw(16) << std::right << "[prev state]"
|
const auto &[event_id, ref_hash]
|
||||||
<< " :" << unquote(prev_state[0]);
|
{
|
||||||
|
prev.prev_states(i)
|
||||||
|
};
|
||||||
|
|
||||||
for(const auto &hash : json::object{prev_state[1]})
|
s << std::setw(16) << std::right << "[prev_state]"
|
||||||
s << " " << unquote(hash.first)
|
<< " :" << event_id;
|
||||||
<< ": " << unquote(hash.second);
|
|
||||||
|
for(const auto &[algorithm, digest] : ref_hash)
|
||||||
|
s << " " << unquote(algorithm)
|
||||||
|
<< ": " << unquote(digest);
|
||||||
|
|
||||||
s << std::endl;
|
s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &prev_events{json::get<"prev_events"_>(prev)};
|
for(size_t i(0); i < prev.prev_events_count(); ++i)
|
||||||
for(const json::array prev_event : prev_events)
|
|
||||||
{
|
{
|
||||||
|
const auto &[event_id, ref_hash]
|
||||||
|
{
|
||||||
|
prev.prev_events(i)
|
||||||
|
};
|
||||||
|
|
||||||
s << std::setw(16) << std::right << "[prev_event]"
|
s << std::setw(16) << std::right << "[prev_event]"
|
||||||
<< " :" << unquote(prev_event[0]);
|
<< " :" << event_id;
|
||||||
|
|
||||||
for(const auto &hash : json::object{prev_event[1]})
|
for(const auto &[algorithm, digest] : ref_hash)
|
||||||
s << " " << unquote(hash.first)
|
s << " " << unquote(algorithm)
|
||||||
<< ": " << unquote(hash.second);
|
<< ": " << unquote(digest);
|
||||||
|
|
||||||
s << std::endl;
|
s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue