diff --git a/modules/console.cc b/modules/console.cc index ebd65d9ef..cd271db91 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -14599,128 +14599,6 @@ console_cmd__fed__send(opt &out, const string_view &line) return true; } -bool -console_cmd__fed__sync(opt &out, const string_view &line) -{ - const params param{line, " ", - { - "room_id", "remote", "limit", "event_id", "timeout" - }}; - - const auto &room_id - { - m::room_id(param.at(0)) - }; - - const string_view remote - { - param.at(1, room_id.host()) - }; - - const auto &limit - { - param.at(2, size_t(128)) - }; - - const string_view &event_id - { - param[3] - }; - - const auto timeout - { - param.at(4, out.timeout) - }; - - // Used for out.head, out.content, in.head, but in.content is dynamic - const unique_buffer buf - { - 32_KiB - }; - - m::fed::state::opts stopts; - stopts.remote = remote; - stopts.event_id = event_id; - const mutable_buffer stbuf - { - data(buf), size(buf) / 2 - }; - - m::fed::state strequest - { - room_id, stbuf, std::move(stopts) - }; - - m::fed::backfill::opts bfopts; - bfopts.remote = remote; - bfopts.event_id = event_id; - bfopts.limit = limit; - const mutable_buffer bfbuf - { - buf + size(stbuf) - }; - - m::fed::backfill bfrequest - { - room_id, bfbuf, std::move(bfopts) - }; - - const auto when - { - now() + timeout - }; - - bfrequest.wait_until(when); - strequest.wait_until(when); - - bfrequest.get(); - strequest.get(); - - const json::array &auth_chain - { - json::object{strequest}.get("auth_chain") - }; - - const json::array &pdus - { - json::object{strequest}.get("pdus") - }; - - const json::array &messages - { - json::object{bfrequest}.get("pdus") - }; - - std::vector events; - events.reserve(auth_chain.size() + pdus.size() + messages.size()); - - for(const json::object &event : auth_chain) - events.emplace_back(event); - - for(const json::object &event : pdus) - events.emplace_back(event); - - for(const json::object &event : messages) - events.emplace_back(event); - - std::sort(begin(events), end(events)); - events.erase(std::unique(begin(events), end(events)), end(events)); - - m::vm::opts vmopts; - vmopts.nothrows = -1; - vmopts.debuglog_accept = true; - vmopts.phase.set(m::vm::phase::FETCH_PREV, false); - vmopts.phase.set(m::vm::phase::FETCH_STATE, false); - vmopts.notify_servers = false; - vmopts.node_id = remote; - m::vm::eval - { - events, vmopts - }; - - return true; -} - bool console_cmd__fed__state(opt &out, const string_view &line) {