From e3ced849ee18cbd68012bfabc9c084cfaf436b64 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 17 Aug 2019 23:05:43 -0700 Subject: [PATCH] ircd::m::room: Remove old cruft. --- ircd/m_room.cc | 117 --------------------------------------------- modules/console.cc | 65 ------------------------- 2 files changed, 182 deletions(-) diff --git a/ircd/m_room.cc b/ircd/m_room.cc index 90af36fa4..e3e5d22d1 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -4644,120 +4644,3 @@ ircd::m::room::stats::bytes_json_compressed(const m::room &room) "Not yet implemented." }; } - -//TODO: temp -namespace ircd::m -{ - extern "C" void room_herd(const m::room &, const m::user &, const milliseconds &); - extern "C" size_t dagree_histogram(const m::room &, std::vector &); -} - -void -ircd::m::room_herd(const m::room &room, - const m::user &user, - const milliseconds &timeout) -{ - using closure_prototype = bool (const string_view &, - std::exception_ptr, - const json::object &); - - using prototype = void (const m::room::id &, - const m::user::id &, - const milliseconds &, - const std::function &); - - static mods::import feds__head - { - "federation_federation", "feds__head" - }; - - std::set event_ids; - feds__head(room.room_id, user.user_id, timeout, [&event_ids] - (const string_view &origin, std::exception_ptr eptr, const json::object &event) - { - if(eptr) - return true; - - const json::array prev_events - { - event.at("prev_events") - }; - - for(const json::array prev_event : prev_events) - { - const auto &prev_event_id - { - unquote(prev_event.at(0)) - }; - - event_ids.emplace(prev_event_id); - }; - - return true; - }); - - size_t i(0); - for(const m::event::id &event_id : event_ids) - if(exists(event_id)) - { - m::room::head::modify(event_id, db::op::SET, false); - ++i; - } - - const m::room::head head - { - room - }; - - for(; i + 1 >= 1 && head.count() > 1; --i) - { - const auto eid - { - send(room, user, "ircd.room.revelation", json::object{}) - }; - - ctx::sleep(seconds(2)); - } -} - -size_t -ircd::m::dagree_histogram(const m::room &room, - std::vector &vec) -{ - static const m::event::fetch::opts fopts - { - { db::get::NO_CACHE }, - m::event::keys::include - { - "event_id", - "prev_events", - } - }; - - m::room::messages it - { - room, &fopts - }; - - size_t ret{0}; - for(; it; --it) - { - const m::event event{*it}; - const size_t num{degree(event)}; - if(unlikely(num >= vec.size())) - { - log::warning - { - m::log, "Event '%s' had %zu prev events (ignored)", - string_view{event.event_id}, - }; - - continue; - } - - ++vec[num]; - ++ret; - } - - return ret; -} diff --git a/modules/console.cc b/modules/console.cc index 6e0a6c04a..26bc1547f 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -7906,35 +7906,6 @@ console_cmd__room__head__del(opt &out, const string_view &line) return true; } -bool -console_cmd__room__herd(opt &out, const string_view &line) -{ - const params param{line, " ", - { - "room_id", "user_id" - }}; - - const auto &room_id - { - m::room_id(param.at(0)) - }; - - const m::user::id &user_id - { - param.at(1) - }; - - using prototype = void (const m::room &, const m::user &, const milliseconds &); - static mods::import room_herd - { - "m_room", "room_herd" - }; - - room_herd(room_id, user_id, out.timeout); - out << "done" << std::endl; - return true; -} - bool console_cmd__room__head__reset(opt &out, const string_view &line) { @@ -9982,42 +9953,6 @@ console_cmd__room__purge(opt &out, const string_view &line) return true; } -bool -console_cmd__room__dagree(opt &out, const string_view &line) -{ - const params param{line, " ", - { - "room_id", - }}; - - const auto &room_id - { - m::room_id(param.at(0)) - }; - - const m::room room - { - room_id - }; - - using prototype = size_t (const m::room &, std::vector &); - static mods::import dagree_histogram - { - "m_room", "dagree_histogram" - }; - - std::vector v(32, 0); - const size_t count - { - dagree_histogram(room, v) - }; - - for(size_t i(0); i < v.size(); ++i) - out << std::setw(2) << std::right << i << ": " << v.at(i) << std::endl; - - return true; -} - bool console_cmd__room__auth(opt &out, const string_view &line) {