From a1bf480b8259d2a23131989af183b3682c2a39a8 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 3 Nov 2023 14:52:17 +0100 Subject: [PATCH] set local agent --- src/solanaceae/crdtnotes_imgui/crdtnotes_imgui.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/solanaceae/crdtnotes_imgui/crdtnotes_imgui.cpp b/src/solanaceae/crdtnotes_imgui/crdtnotes_imgui.cpp index 4ad8e89..b86c796 100644 --- a/src/solanaceae/crdtnotes_imgui/crdtnotes_imgui.cpp +++ b/src/solanaceae/crdtnotes_imgui/crdtnotes_imgui.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace detail { uint8_t nib_from_hex(char c) { @@ -60,10 +61,20 @@ float CRDTNotesImGui::render(void) { for (const auto& c : _cr.view()) { if (renderContactListContactSmall(c, false)) { const auto& self = _cr.get(c).self; + assert(_cr.all_of(self)); + const auto& self_id = _cr.get(self); + assert(!self_id.data.empty()); + + CRDTNotes::CRDTAgent self_agent_id; + + // at most agent size, up to self id size + for (size_t i = 0; i < self_agent_id.size() && i < self_id.data.size(); i++) { + self_agent_id.at(i) = self_id.data.at(i); + } _notes.addDoc( // tox id (id from self) - {}, + self_agent_id, // random 32bytes? {} );