From 6a6de77ae95db48c6ba07686b13b7f1e4b9ebd52 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 28 Feb 2024 23:49:32 +0100 Subject: [PATCH] smaller contact frag fixes --- src/fragment_store/message_fragment_store.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/fragment_store/message_fragment_store.cpp b/src/fragment_store/message_fragment_store.cpp index f026780..bf5c950 100644 --- a/src/fragment_store/message_fragment_store.cpp +++ b/src/fragment_store/message_fragment_store.cpp @@ -174,6 +174,12 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { // assuming ts range exists fts_comp.begin = msg_ts; // extend into the past + if (m.registry()->ctx().contains()) { + // should be the case + m.registry()->ctx().get().erase(fh); + m.registry()->ctx().get().insert(fh); + } + // TODO: check conditions for open here // TODO: mark msg (and frag?) dirty @@ -185,6 +191,12 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { // assuming ts range exists fts_comp.end = msg_ts; // extend into the future + if (m.registry()->ctx().contains()) { + // should be the case + m.registry()->ctx().get().erase(fh); + m.registry()->ctx().get().insert(fh); + } + // TODO: check conditions for open here // TODO: mark msg (and frag?) dirty } @@ -209,6 +221,15 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { new_ts_range.begin = msg_ts; new_ts_range.end = msg_ts; + { + const auto msg_reg_contact = m.registry()->ctx().get(); + if (_cr.all_of(msg_reg_contact)) { + fh.emplace(_cr.get(msg_reg_contact).data); + } else { + // ? rage quit? + } + } + // contact frag if (!m.registry()->ctx().contains()) { m.registry()->ctx().emplace(); @@ -221,15 +242,6 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { } m.registry()->ctx().get().frags.emplace(fh); - { - const auto msg_reg_contact = m.registry()->ctx().get(); - if (_cr.all_of(msg_reg_contact)) { - fh.emplace(_cr.get(msg_reg_contact).data); - } else { - // ? rage quit? - } - } - fuid_open.emplace_back(Message::Components::OpenFragments::OpenFrag{fragment_uid}); std::cout << "MFS: created new fragment " << bin2hex(fragment_uid) << "\n"; @@ -887,6 +899,7 @@ bool MessageFragmentStore::onEvent(const Fragment::Events::FragmentConstruct& e) if (!msg_reg->ctx().contains()) { msg_reg->ctx().emplace(); } + msg_reg->ctx().get().erase(e.e); // TODO: check/update/fragment update msg_reg->ctx().get().insert(e.e); _event_check_queue.push(ECQueueEntry{e.e, frag_contact});