diff --git a/plugins/plugin_mfs_wip.cpp b/plugins/plugin_mfs_wip.cpp index 2ab024f..695568f 100644 --- a/plugins/plugin_mfs_wip.cpp +++ b/plugins/plugin_mfs_wip.cpp @@ -34,7 +34,7 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) } try { - auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1"); + auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I); auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI); auto* os = PLUG_RESOLVE_INSTANCE(ObjectStore2); auto* msnj = PLUG_RESOLVE_INSTANCE(MessageSerializerNJ); @@ -42,7 +42,7 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) // static store, could be anywhere tho // construct with fetched dependencies g_fsb = std::make_unique(*os, "test2_message_store/"); // TODO: use config? - g_mfs = std::make_unique(*cr, *rmm, *os, *g_fsb, *g_fsb, *msnj); + g_mfs = std::make_unique(*cs, *rmm, *os, *g_fsb, *g_fsb, *msnj); // register types PLUG_PROVIDE_INSTANCE(MessageFragmentStore, plugin_name, g_mfs.get()); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93cf2d6..f4d3c4f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,7 @@ add_executable(convert_message_object_store ) target_link_libraries(convert_message_object_store PUBLIC + solanaceae_contact_impl solanaceae_object_store solanaceae_object_store_backend_filesystem solanaceae_message_fragment_store diff --git a/src/convert_frag_to_obj.cpp b/src/convert_frag_to_obj.cpp index 8401890..43e539e 100644 --- a/src/convert_frag_to_obj.cpp +++ b/src/convert_frag_to_obj.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -35,14 +36,14 @@ int main(int argc, const char** argv) { Backends::FilesystemStorage fsb_src(os_src, argv[1]); Backends::FilesystemStorage fsb_dst(os_dst, argv[2]); - Contact3Registry cr; // dummy - RegistryMessageModelImpl rmm(cr); // dummy + ContactStore4Impl cs; // dummy + RegistryMessageModelImpl rmm(cs); // dummy // they only exist for the serializers (for now) // TODO: version - MessageSerializerNJ msnj_src{cr, os_src, {}, {}}; - MessageFragmentStore mfs_src(cr, rmm, os_src, fsb_src, fsb_src, msnj_src); - MessageSerializerNJ msnj_dst{cr, os_dst, {}, {}}; - MessageFragmentStore mfs_dst(cr, rmm, os_dst, fsb_dst, fsb_dst, msnj_dst); + MessageSerializerNJ msnj_src{cs, os_src, {}, {}}; + MessageFragmentStore mfs_src(cs, rmm, os_src, fsb_src, fsb_src, msnj_src); + MessageSerializerNJ msnj_dst{cs, os_dst, {}, {}}; + MessageFragmentStore mfs_dst(cs, rmm, os_dst, fsb_dst, fsb_dst, msnj_dst); // add message fragment store too (adds meta?) diff --git a/src/solanaceae/message_fragment_store/message_fragment_store.cpp b/src/solanaceae/message_fragment_store/message_fragment_store.cpp index c2e1a43..cb3b943 100644 --- a/src/solanaceae/message_fragment_store/message_fragment_store.cpp +++ b/src/solanaceae/message_fragment_store/message_fragment_store.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include #include #include @@ -37,7 +39,7 @@ namespace ObjectStore::Components { // cache the contact for faster lookups struct MessagesContactEntity { - Contact3 e {entt::null}; + Contact4 e {entt::null}; }; } } // ObjectStore::Component @@ -83,8 +85,8 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { return; // we only handle msg with ts } - _potentially_dirty_contacts.emplace(m.registry()->ctx().get()); // always mark dirty here - _touched_contacts.emplace(m.registry()->ctx().get()); + _potentially_dirty_contacts.emplace(m.registry()->ctx().get()); // always mark dirty here + _touched_contacts.emplace(m.registry()->ctx().get()); if (m.any_of()) { // not an actual message, but we probalby need to check and see if we need to load fragments //std::cout << "MFS: new or updated curser\n"; @@ -206,9 +208,9 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) { 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); + const auto msg_reg_contact = m.registry()->ctx().get(); + if (_cs.registry().all_of(msg_reg_contact)) { + fh.emplace(_cs.registry().get(msg_reg_contact).data); } else { // ? rage quit? } @@ -364,10 +366,10 @@ void MessageFragmentStore::loadFragment(Message3Registry& reg, ObjectHandle fh) Message3 dup_msg {entt::null}; { // get comparator from contact - if (reg.ctx().contains()) { - const auto c = reg.ctx().get(); - if (_cr.all_of(c)) { - auto& comp = _cr.get(c).comp; + if (reg.ctx().contains()) { + const auto c = reg.ctx().get(); + if (_cs.registry().all_of(c)) { + auto& comp = _cs.registry().get(c).comp; // walking EVERY existing message OOF // this needs optimizing for (const Message3 other_msg : reg.view()) { @@ -504,13 +506,13 @@ bool MessageFragmentStore::syncFragToStorage(ObjectHandle fh, Message3Registry& } MessageFragmentStore::MessageFragmentStore( - Contact3Registry& cr, + ContactStore4I& cs, RegistryMessageModelI& rmm, ObjectStore2& os, StorageBackendIMeta& sbm, StorageBackendIAtomic& sba, MessageSerializerNJ& scnj -) : _cr(cr), _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _sbm(sbm), _sba(sba), _scnj(scnj) { +) : _cs(cs), _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _sbm(sbm), _sba(sba), _scnj(scnj) { _rmm_sr .subscribe(RegistryMessageModel_Event::message_construct) .subscribe(RegistryMessageModel_Event::message_updated) @@ -867,17 +869,17 @@ bool MessageFragmentStore::onEvent(const ObjectStore::Events::ObjectConstruct& e // TODO: are we sure it is a *new* fragment? - Contact3 frag_contact = entt::null; + Contact4 frag_contact = entt::null; { // get contact const auto& frag_contact_id = e.e.get().id; // TODO: id lookup table, this is very inefficent - for (const auto& [c_it, id_it] : _cr.view().each()) { + for (const auto& [c_it, id_it] : _cs.registry().view().each()) { if (frag_contact_id == id_it.data) { frag_contact = c_it; break; } } - if (!_cr.valid(frag_contact)) { + if (!_cs.registry().valid(frag_contact)) { // unkown contact return false; } @@ -917,23 +919,23 @@ bool MessageFragmentStore::onEvent(const ObjectStore::Events::ObjectUpdate& e) { // its also possible it was tagged as empty e.e.remove(); - Contact3 frag_contact = entt::null; + Contact4 frag_contact = entt::null; { // get contact // probably cached already if (e.e.all_of()) { frag_contact = e.e.get().e; } - if (!_cr.valid(frag_contact)) { + if (!_cs.registry().valid(frag_contact)) { const auto& frag_contact_id = e.e.get().id; // TODO: id lookup table, this is very inefficent - for (const auto& [c_it, id_it] : _cr.view().each()) { + for (const auto& [c_it, id_it] : _cs.registry().view().each()) { if (frag_contact_id == id_it.data) { frag_contact = c_it; break; } } - if (!_cr.valid(frag_contact)) { + if (!_cs.registry().valid(frag_contact)) { // unkown contact return false; } diff --git a/src/solanaceae/message_fragment_store/message_fragment_store.hpp b/src/solanaceae/message_fragment_store/message_fragment_store.hpp index f883920..614e5d2 100644 --- a/src/solanaceae/message_fragment_store/message_fragment_store.hpp +++ b/src/solanaceae/message_fragment_store/message_fragment_store.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include @@ -50,7 +50,7 @@ class MessageFragmentStore : public RegistryMessageModelEventI, public ObjectSto static constexpr const char* version {"3"}; protected: - Contact3Registry& _cr; + ContactStore4I& _cs; RegistryMessageModelI& _rmm; RegistryMessageModelI::SubscriptionReference _rmm_sr; ObjectStore2& _os; @@ -78,21 +78,21 @@ class MessageFragmentStore : public RegistryMessageModelEventI, public ObjectSto struct ECQueueEntry final { ObjectHandle fid; - Contact3 c; + Contact4 c; }; std::deque _event_check_queue; // range changed or fragment loaded. // we only load a limited number of fragments at once, // so we need to keep them dirty until nothing was loaded. - entt::dense_set _potentially_dirty_contacts; + entt::dense_set _potentially_dirty_contacts; // for cleaning up the ctx vars we create - entt::dense_set _touched_contacts; + entt::dense_set _touched_contacts; public: MessageFragmentStore( - Contact3Registry& cr, + ContactStore4I& cr, RegistryMessageModelI& rmm, ObjectStore2& os, StorageBackendIMeta& sbm,