feat: archive stale convo volatile entries to extra_data#77
feat: archive stale convo volatile entries to extra_data#77Bilb wants to merge 5 commits intosession-foundation:devfrom
Conversation
| arch.insert_or_assign(key, c); | ||
| _needs_dump = true; |
There was a problem hiding this comment.
I think we'd want something like this instead
auto [it, inserted] = arch.try_emplace(key, c);
// avoid marking `_needs_dumps` as true when the change didn't do anything
if (inserted) {
_needs_dump = true;
} else if (it->second != c) {
it->second = c;
_needs_dump = true;
}But I need to write the operator for it first
| enum class ArchPhase : uint8_t { | ||
| s_1to1 = 0, | ||
| s_legacy = 1, | ||
| s_blinded = 2, | ||
| s_group = 3, | ||
| s_comm = 4, | ||
| done = 5 | ||
| }; | ||
| ArchPhase _arch_section = ArchPhase::done; |
There was a problem hiding this comment.
not fan of this and how it's used in the archive_stale, but I couldn't find a better option
| info.erase(); // remove from active dict if present | ||
| _arch_comm[c.base_url()].insert_or_assign(c.room_norm(), c); | ||
| _needs_dump = true; |
There was a problem hiding this comment.
same comment, we should avoid marking needs_dump when nothing has changed
| void ConvoInfoVolatile::load_extra_data(oxenc::bt_dict_consumer&& extra) { | ||
| // "1": one_to_one — skip if already in active config (handles re-activation) | ||
| if (extra.skip_until("1")) { | ||
| auto section = extra.consume_dict_consumer(); | ||
| while (!section.is_finished()) { | ||
| auto [key, val] = section.next_dict_consumer(); | ||
| if (key.size() != 33) | ||
| continue; | ||
| if (data["1"][std::string{key}].dict()) | ||
| continue; | ||
| convo::one_to_one c{oxenc::to_hex(key)}; | ||
| if (val.skip_until("e")) { | ||
| c.pro_expiry_unix_ts = std::chrono::sys_time<std::chrono::milliseconds>( | ||
| std::chrono::milliseconds(val.consume_integer<int64_t>())); | ||
| } |
There was a problem hiding this comment.
this whole function needs some cleanup. I'll check how the other wrappers are reading the extradata, and if there is a better/nicer way
| // Dict phase exhausted — scan typed archive sections in extra_data key order | ||
| // ("1"<"C"<"b"<"g"<"o"). | ||
| while (_arch_section != ArchPhase::done) { | ||
| switch (_arch_section) { | ||
| case ArchPhase::s_1to1: | ||
| if (_arch_1to1 && _arch_1to1_it != _arch_1to1->end()) { | ||
| _val = std::make_shared<convo::any>(_arch_1to1_it->second); | ||
| ++_arch_1to1_it; |
There was a problem hiding this comment.
As said above, not fan of this ArchPhase, there got to be a nicer way of doing this
| const ConvoInfoVolatile::arch_legacy_map_t* arch_legacy, | ||
| const ConvoInfoVolatile::arch_blinded_map_t* arch_blinded, | ||
| const ConvoInfoVolatile::arch_group_map_t* arch_group, | ||
| const ConvoInfoVolatile::arch_comm_map_t* arch_comm) { |
There was a problem hiding this comment.
this is kind of getting out of hands, maybe we should keep those iterators separate?
We already have begin_archived but it's reusing this one
64cc9a1 to
128ec7a
Compare
No description provided.