Compare commits
No commits in common. "c731d51a468e1238ff383419963cebe991d4b1de" and "31c3ed4688de6f80bb160ce5d3168ac6b57cf318" have entirely different histories.
c731d51a46
...
31c3ed4688
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Erik Scholz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -32,12 +32,12 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
}
|
||||
|
||||
try {
|
||||
auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I);
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn = std::make_unique<CRDTNotes>();
|
||||
g_crdtns = std::make_unique<CRDTNotesSync>(*g_crdtn, *cs);
|
||||
g_crdtns = std::make_unique<CRDTNotesSync>(*g_crdtn, *cr);
|
||||
|
||||
// register types
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesSync, plugin_name, g_crdtns.get());
|
||||
|
@ -33,7 +33,7 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
|
||||
try {
|
||||
auto* crdtns = PLUG_RESOLVE_INSTANCE(CRDTNotesSync);
|
||||
auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I);
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
auto* imguic = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiContext, ImGui::GetVersion());
|
||||
auto* imguimemaf = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiMemAllocFunc, ImGui::GetVersion());
|
||||
auto* imguimemff = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiMemFreeFunc, ImGui::GetVersion());
|
||||
@ -45,7 +45,7 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn_imgui = std::make_unique<CRDTNotesImGui>(*crdtns, *cs);
|
||||
g_crdtn_imgui = std::make_unique<CRDTNotesImGui>(*crdtns, *cr);
|
||||
|
||||
// register types
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesImGui, plugin_name, g_crdtn_imgui.get());
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
#include <solanaceae/crdtnotes_toxsync/crdtnotes_toxsync.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
@ -36,14 +37,14 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
|
||||
try {
|
||||
auto* notes_sync = PLUG_RESOLVE_INSTANCE(CRDTNotesEventI);
|
||||
auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I);
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
auto* t = PLUG_RESOLVE_INSTANCE(ToxI);
|
||||
auto* tep = PLUG_RESOLVE_INSTANCE(ToxEventProviderI);
|
||||
auto* tcm = PLUG_RESOLVE_INSTANCE(ToxContactModel2);
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn_ts = std::make_unique<CRDTNotesToxSync>(*notes_sync, *cs, *t, *tep, *tcm);
|
||||
g_crdtn_ts = std::make_unique<CRDTNotesToxSync>(*notes_sync, *cr, *t, *tep, *tcm);
|
||||
|
||||
// register types
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesToxSync, plugin_name, g_crdtn_ts.get());
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "./crdtnotes.hpp"
|
||||
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
|
||||
// send api
|
||||
struct CRDTNotesContactSyncModelI {
|
||||
@ -12,12 +12,12 @@ struct CRDTNotesContactSyncModelI {
|
||||
public:
|
||||
// notify of doc existing
|
||||
virtual void SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) = 0;
|
||||
|
||||
virtual void SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const std::vector<CRDTNotes::Frontier>& selected_frontier
|
||||
) = 0;
|
||||
@ -26,13 +26,13 @@ struct CRDTNotesContactSyncModelI {
|
||||
public:
|
||||
// causes the other peer to send gossip with all known frontiers (on cool down)
|
||||
virtual void SendFetchCompleteFrontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) = 0;
|
||||
|
||||
// action range request
|
||||
virtual void SendFetchOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const CRDTNotes::CRDTAgent& agent,
|
||||
const uint64_t seq_from,
|
||||
@ -41,7 +41,7 @@ struct CRDTNotesContactSyncModelI {
|
||||
|
||||
public: // ops response
|
||||
virtual void SendOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
// TODO: optimize this
|
||||
const std::vector<CRDTNotes::Doc::Op>&
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "./crdtnotes_sync.hpp"
|
||||
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_contact_sync_model.hpp>
|
||||
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
@ -18,7 +17,7 @@ static ID32 id_from_vec(const std::vector<uint8_t>& vec) {
|
||||
return new_id;
|
||||
}
|
||||
|
||||
CRDTNotesSync::CRDTNotesSync(CRDTNotes& notes, ContactStore4I& cs) : _notes(notes), _cs(cs) {
|
||||
CRDTNotesSync::CRDTNotesSync(CRDTNotes& notes, Contact3Registry& cr) : _notes(notes), _cr(cr) {
|
||||
_rng.seed(std::random_device{}());
|
||||
_rng.discard(707);
|
||||
}
|
||||
@ -88,17 +87,15 @@ CRDTNotes::Doc* CRDTNotesSync::getDoc(const CRDTNotes::DocID& doc_id) {
|
||||
return _notes.getDoc(doc_id);
|
||||
}
|
||||
|
||||
std::optional<CRDTNotes::DocID> CRDTNotesSync::addNewDoc(ContactHandle4 c, bool secret) {
|
||||
std::optional<CRDTNotes::DocID> CRDTNotesSync::addNewDoc(Contact3Handle c, bool secret) {
|
||||
if (!static_cast<bool>(c)) {
|
||||
std::cerr << "CRDTNS error: invalid contact\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
const auto self = c.get<Contact::Components::Self>().self;
|
||||
assert(cr.all_of<Contact::Components::ID>(self));
|
||||
const auto& self_id = cr.get<Contact::Components::ID>(self);
|
||||
const auto& self = c.get<Contact::Components::Self>().self;
|
||||
assert(_cr.all_of<Contact::Components::ID>(self));
|
||||
const auto& self_id = _cr.get<Contact::Components::ID>(self);
|
||||
assert(!self_id.data.empty());
|
||||
|
||||
CRDTNotes::CRDTAgent self_agent_id = id_from_vec(self_id.data);
|
||||
@ -130,17 +127,15 @@ std::optional<CRDTNotes::DocID> CRDTNotesSync::addNewDoc(ContactHandle4 c, bool
|
||||
return new_id;
|
||||
}
|
||||
|
||||
bool CRDTNotesSync::addDoc(const CRDTNotes::DocID& doc_id, ContactHandle4 c) {
|
||||
bool CRDTNotesSync::addDoc(const CRDTNotes::DocID& doc_id, Contact3Handle c) {
|
||||
if (!static_cast<bool>(c)) {
|
||||
std::cerr << "CRDTNS error: invalid contact\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
const auto& self = c.get<Contact::Components::Self>().self;
|
||||
assert(cr.all_of<Contact::Components::ID>(self));
|
||||
const auto& self_id = cr.get<Contact::Components::ID>(self);
|
||||
assert(_cr.all_of<Contact::Components::ID>(self));
|
||||
const auto& self_id = _cr.get<Contact::Components::ID>(self);
|
||||
assert(!self_id.data.empty());
|
||||
|
||||
CRDTNotes::CRDTAgent self_agent_id = id_from_vec(self_id.data);
|
||||
@ -163,12 +158,12 @@ std::vector<CRDTNotes::DocID> CRDTNotesSync::getDocList(void) {
|
||||
return _notes.getDocList();
|
||||
}
|
||||
|
||||
std::vector<CRDTNotes::DocID> CRDTNotesSync::getDocList(ContactHandle4 c) {
|
||||
std::vector<CRDTNotes::DocID> CRDTNotesSync::getDocList(Contact3Handle c) {
|
||||
std::vector<CRDTNotes::DocID> list;
|
||||
|
||||
ContactHandle4 parent;
|
||||
Contact3Handle parent;
|
||||
if (c.all_of<Contact::Components::Parent>()) {
|
||||
parent = ContactHandle4{*c.registry(), c.get<Contact::Components::Parent>().parent};
|
||||
parent = Contact3Handle{*c.registry(), c.get<Contact::Components::Parent>().parent};
|
||||
}
|
||||
|
||||
for (const auto& [k, v] : _docs_contacts) {
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "./crdtnotes.hpp"
|
||||
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/handle.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
|
||||
#include <set>
|
||||
#include <random>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
// fwd
|
||||
struct CRDTNotesContactSyncModelI;
|
||||
@ -19,7 +14,7 @@ namespace Events {
|
||||
|
||||
// - DocID
|
||||
struct NGCEXT_crdtns_gossip {
|
||||
ContactHandle4 c;
|
||||
Contact3Handle c;
|
||||
CRDTNotes::DocID doc_id;
|
||||
};
|
||||
|
||||
@ -29,14 +24,14 @@ namespace Events {
|
||||
// - seq (frontier)
|
||||
// - ]
|
||||
struct NGCEXT_crdtns_gossip_frontier {
|
||||
ContactHandle4 c;
|
||||
Contact3Handle c;
|
||||
CRDTNotes::DocID doc_id;
|
||||
std::vector<CRDTNotes::Frontier> selected_frontier;
|
||||
};
|
||||
|
||||
// - DocID
|
||||
struct NGCEXT_crdtns_fetch_complete_frontier {
|
||||
ContactHandle4 c;
|
||||
Contact3Handle c;
|
||||
CRDTNotes::DocID doc_id;
|
||||
};
|
||||
|
||||
@ -45,7 +40,7 @@ namespace Events {
|
||||
// - seq_from
|
||||
// - seq_to
|
||||
struct NGCEXT_crdtns_fetch_op_range {
|
||||
ContactHandle4 c;
|
||||
Contact3Handle c;
|
||||
CRDTNotes::DocID doc_id;
|
||||
CRDTNotes::CRDTAgent agent;
|
||||
uint64_t seq_from;
|
||||
@ -57,7 +52,7 @@ namespace Events {
|
||||
// - op
|
||||
// - ]
|
||||
struct NGCEXT_crdtns_ops {
|
||||
ContactHandle4 c;
|
||||
Contact3Handle c;
|
||||
CRDTNotes::DocID doc_id;
|
||||
std::vector<CRDTNotes::Doc::Op> ops;
|
||||
};
|
||||
@ -81,24 +76,18 @@ struct CRDTNotesEventI {
|
||||
class CRDTNotesSync final : public CRDTNotesEventI {
|
||||
// pull inside????
|
||||
CRDTNotes& _notes;
|
||||
ContactStore4I& _cs;
|
||||
Contact3Registry& _cr;
|
||||
|
||||
std::default_random_engine _rng;
|
||||
|
||||
std::unordered_map<CRDTNotes::DocID, std::set<ContactHandle4>> _docs_contacts;
|
||||
struct Peer {
|
||||
// global frontier
|
||||
// what we know the peer knows(/gossiped) about
|
||||
std::unordered_map<decltype(CRDTNotes::Frontier::agent), decltype(CRDTNotes::Frontier::seq)> other_frontier;
|
||||
};
|
||||
std::unordered_map<CRDTNotes::DocID, std::map<ContactHandle4, Peer>> _docs_peers;
|
||||
std::unordered_map<CRDTNotes::DocID, std::set<Contact3Handle>> _docs_contacts;
|
||||
|
||||
// if a doc is eg new, it is added here
|
||||
std::set<CRDTNotes::DocID> _gossip_queue; // TODO: no
|
||||
std::set<CRDTNotes::DocID> _gossip_queue;
|
||||
std::set<CRDTNotes::DocID> _fetch_frontier_queue;
|
||||
|
||||
public:
|
||||
CRDTNotesSync(CRDTNotes& notes, ContactStore4I& cs);
|
||||
CRDTNotesSync(CRDTNotes& notes, Contact3Registry& cr);
|
||||
|
||||
~CRDTNotesSync(void);
|
||||
|
||||
@ -110,14 +99,14 @@ class CRDTNotesSync final : public CRDTNotesEventI {
|
||||
|
||||
// adds a doc and assosiates contact (and self)
|
||||
// if secret, only self is added (and thats why contact is needed)
|
||||
std::optional<CRDTNotes::DocID> addNewDoc(ContactHandle4 c, bool secret = false);
|
||||
std::optional<CRDTNotes::DocID> addNewDoc(Contact3Handle c, bool secret = false);
|
||||
|
||||
// adds a doc by id to a contact
|
||||
// (for gossip or manual add)
|
||||
bool addDoc(const CRDTNotes::DocID& doc_id, ContactHandle4 c);
|
||||
bool addDoc(const CRDTNotes::DocID& doc_id, Contact3Handle c);
|
||||
|
||||
std::vector<CRDTNotes::DocID> getDocList(void);
|
||||
std::vector<CRDTNotes::DocID> getDocList(ContactHandle4 c);
|
||||
std::vector<CRDTNotes::DocID> getDocList(Contact3Handle c);
|
||||
|
||||
void merge(const CRDTNotes::DocID& doc_id, std::string_view new_text);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "./crdtnotes_imgui.hpp"
|
||||
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
@ -48,7 +47,7 @@ namespace detail {
|
||||
} // detail
|
||||
|
||||
|
||||
CRDTNotesImGui::CRDTNotesImGui(CRDTNotesSync& notes_sync, ContactStore4I& cs) : _notes_sync(notes_sync), _cs(cs) {
|
||||
CRDTNotesImGui::CRDTNotesImGui(CRDTNotesSync& notes_sync, Contact3Registry& cr) : _notes_sync(notes_sync), _cr(cr) {
|
||||
}
|
||||
|
||||
float CRDTNotesImGui::render(void) {
|
||||
@ -59,7 +58,7 @@ float CRDTNotesImGui::render(void) {
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("create new doc contact")) {
|
||||
for (const auto& c : _cs.registry().view<Contact::Components::TagBig>()) {
|
||||
for (const auto& c : _cr.view<Contact::Components::TagBig>()) {
|
||||
if (renderContactListContactSmall(c, false)) {
|
||||
//const auto& self = _cr.get<Contact::Components::Self>(c).self;
|
||||
//assert(_cr.all_of<Contact::Components::ID>(self));
|
||||
@ -77,7 +76,7 @@ float CRDTNotesImGui::render(void) {
|
||||
//// tox id (id from self)
|
||||
//self_agent_id
|
||||
//);
|
||||
_notes_sync.addNewDoc(_cs.contactHandle(c), false);
|
||||
_notes_sync.addNewDoc({_cr, c}, false);
|
||||
|
||||
//// and open the doc
|
||||
}
|
||||
@ -123,12 +122,10 @@ float CRDTNotesImGui::render(void) {
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
bool CRDTNotesImGui::renderContactListContactSmall(const Contact4 c, const bool selected) const {
|
||||
bool CRDTNotesImGui::renderContactListContactSmall(const Contact3 c, const bool selected) const {
|
||||
std::string label;
|
||||
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
label += (cr.all_of<Contact::Components::Name>(c) ? cr.get<Contact::Components::Name>(c).name.c_str() : "<unk>");
|
||||
label += (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name.c_str() : "<unk>");
|
||||
label += "###";
|
||||
label += std::to_string(entt::to_integral(c));
|
||||
|
||||
|
@ -1,24 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
|
||||
#include <set>
|
||||
|
||||
class CRDTNotesImGui {
|
||||
CRDTNotesSync& _notes_sync;
|
||||
ContactStore4I& _cs;
|
||||
Contact3Registry& _cr;
|
||||
|
||||
bool _show_global_list {true};
|
||||
|
||||
std::set<CRDTNotes::DocID> _open_docs;
|
||||
|
||||
public:
|
||||
CRDTNotesImGui(CRDTNotesSync& notes_sync, ContactStore4I& cs);
|
||||
CRDTNotesImGui(CRDTNotesSync& notes_sync, Contact3Registry& cr);
|
||||
|
||||
float render(void);
|
||||
|
||||
bool renderContactListContactSmall(const Contact4 c, const bool selected) const;
|
||||
bool renderContactListContactSmall(const Contact3 c, const bool selected) const;
|
||||
|
||||
bool renderDoc(const CRDTNotes::DocID& doc_id);
|
||||
bool renderDocText(std::string& text) const;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "./crdtnotes_toxsync.hpp"
|
||||
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||
|
||||
#include <solanaceae/tox_contacts/components.hpp>
|
||||
@ -40,11 +39,11 @@ enum class NGCEXT_Event : uint8_t {
|
||||
|
||||
CRDTNotesToxSync::CRDTNotesToxSync(
|
||||
CRDTNotesEventI& notes_sync,
|
||||
ContactStore4I& cs,
|
||||
Contact3Registry& cr,
|
||||
ToxI& t,
|
||||
ToxEventProviderI& tep,
|
||||
ToxContactModel2& tcm
|
||||
) : _notes_sync(notes_sync), _cs(cs), _t(t), _tep_sr(tep.newSubRef(this)), _tcm(tcm) {
|
||||
) : _notes_sync(notes_sync), _cr(cr), _t(t), _tep_sr(tep.newSubRef(this)), _tcm(tcm) {
|
||||
// TODO: non groups
|
||||
|
||||
// should be called for every peer (except self)
|
||||
@ -59,13 +58,13 @@ CRDTNotesToxSync::CRDTNotesToxSync(
|
||||
|
||||
CRDTNotesToxSync::~CRDTNotesToxSync(void) {
|
||||
// TODO: find a better way to remove dangling pointers
|
||||
std::vector<Contact4> to_remove_self;
|
||||
_cs.registry().view<CRDTNotesContactSyncModelI*>().each([&to_remove_self, this](Contact4 c, const auto* csm) {
|
||||
std::vector<Contact3> to_remove_self;
|
||||
_cr.view<CRDTNotesContactSyncModelI*>().each([&to_remove_self, this](Contact3 c, const auto* csm) {
|
||||
if (this == csm) {
|
||||
to_remove_self.push_back(c);
|
||||
}
|
||||
});
|
||||
_cs.registry().remove<CRDTNotesContactSyncModelI*>(to_remove_self.cbegin(), to_remove_self.cend());
|
||||
_cr.remove<CRDTNotesContactSyncModelI*>(to_remove_self.cbegin(), to_remove_self.cend());
|
||||
}
|
||||
|
||||
float CRDTNotesToxSync::iterate(float time_delta) {
|
||||
@ -74,7 +73,7 @@ float CRDTNotesToxSync::iterate(float time_delta) {
|
||||
}
|
||||
|
||||
void CRDTNotesToxSync::SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) {
|
||||
if (!c.all_of<Contact::Components::ToxGroupPeerEphemeral>()) {
|
||||
@ -99,7 +98,7 @@ void CRDTNotesToxSync::SendGossip(
|
||||
}
|
||||
|
||||
void CRDTNotesToxSync::SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const std::vector<CRDTNotes::Frontier>& selected_frontier
|
||||
) {
|
||||
@ -140,7 +139,7 @@ void CRDTNotesToxSync::SendGossip(
|
||||
}
|
||||
|
||||
void CRDTNotesToxSync::SendFetchCompleteFrontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) {
|
||||
if (!c.all_of<Contact::Components::ToxGroupPeerEphemeral>()) {
|
||||
@ -165,7 +164,7 @@ void CRDTNotesToxSync::SendFetchCompleteFrontier(
|
||||
}
|
||||
|
||||
void CRDTNotesToxSync::SendFetchOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const CRDTNotes::CRDTAgent& agent,
|
||||
const uint64_t seq_from,
|
||||
@ -208,7 +207,7 @@ void CRDTNotesToxSync::SendFetchOps(
|
||||
}
|
||||
|
||||
void CRDTNotesToxSync::SendOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const std::vector<CRDTNotes::Doc::Op>& ops
|
||||
) {
|
||||
@ -289,7 +288,7 @@ void CRDTNotesToxSync::SendOps(
|
||||
}
|
||||
|
||||
bool CRDTNotesToxSync::parse_crdtn_gossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool // dont care private
|
||||
) {
|
||||
@ -314,7 +313,7 @@ bool CRDTNotesToxSync::parse_crdtn_gossip(
|
||||
}
|
||||
|
||||
bool CRDTNotesToxSync::parse_crdtn_gossip_frontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool // dont care private
|
||||
) {
|
||||
@ -352,7 +351,7 @@ bool CRDTNotesToxSync::parse_crdtn_gossip_frontier(
|
||||
}
|
||||
|
||||
bool CRDTNotesToxSync::parse_crdtn_fetch_complete_frontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool // dont care private
|
||||
) {
|
||||
@ -372,7 +371,7 @@ bool CRDTNotesToxSync::parse_crdtn_fetch_complete_frontier(
|
||||
}
|
||||
|
||||
bool CRDTNotesToxSync::parse_crdtn_fetch_op_range(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool // dont care private
|
||||
) {
|
||||
@ -409,7 +408,7 @@ bool CRDTNotesToxSync::parse_crdtn_fetch_op_range(
|
||||
}
|
||||
|
||||
bool CRDTNotesToxSync::parse_crdtn_ops(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool // dont care private
|
||||
) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
#include "solanaceae/crdtnotes/crdtnotes_sync.hpp"
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_contact_sync_model.hpp>
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
|
||||
@ -13,7 +14,7 @@ struct ToxEventProviderI;
|
||||
// implements CRDTNotesContactSyncModelI and attaches itself to tox contacts
|
||||
class CRDTNotesToxSync : public CRDTNotesContactSyncModelI, public ToxEventI {
|
||||
CRDTNotesEventI& _notes_sync;
|
||||
ContactStore4I& _cs;
|
||||
Contact3Registry& _cr;
|
||||
ToxI& _t;
|
||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||
ToxContactModel2& _tcm;
|
||||
@ -21,7 +22,7 @@ class CRDTNotesToxSync : public CRDTNotesContactSyncModelI, public ToxEventI {
|
||||
public:
|
||||
CRDTNotesToxSync(
|
||||
CRDTNotesEventI& notes_sync,
|
||||
ContactStore4I& cs,
|
||||
Contact3Registry& cr,
|
||||
ToxI& t,
|
||||
ToxEventProviderI& tep,
|
||||
ToxContactModel2& tcm
|
||||
@ -32,23 +33,23 @@ class CRDTNotesToxSync : public CRDTNotesContactSyncModelI, public ToxEventI {
|
||||
|
||||
public: // sync api
|
||||
void SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) override;
|
||||
|
||||
void SendGossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const std::vector<CRDTNotes::Frontier>& selected_frontier
|
||||
) override;
|
||||
|
||||
void SendFetchCompleteFrontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id
|
||||
) override;
|
||||
|
||||
void SendFetchOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const CRDTNotes::CRDTAgent& agent,
|
||||
const uint64_t seq_from,
|
||||
@ -56,34 +57,34 @@ class CRDTNotesToxSync : public CRDTNotesContactSyncModelI, public ToxEventI {
|
||||
) override;
|
||||
|
||||
void SendOps(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const CRDTNotes::DocID& doc_id,
|
||||
const std::vector<CRDTNotes::Doc::Op>&
|
||||
) override;
|
||||
|
||||
private:
|
||||
bool parse_crdtn_gossip(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool _private
|
||||
);
|
||||
bool parse_crdtn_gossip_frontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool _private
|
||||
);
|
||||
bool parse_crdtn_fetch_complete_frontier(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool _private
|
||||
);
|
||||
bool parse_crdtn_fetch_op_range(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool _private
|
||||
);
|
||||
bool parse_crdtn_ops(
|
||||
ContactHandle4 c,
|
||||
Contact3Handle c,
|
||||
const uint8_t* data, size_t data_size,
|
||||
bool _private
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user