update for new DB layout

This commit is contained in:
Doug Hoyte
2024-08-31 00:47:38 -04:00
parent fc43a2260b
commit 9a7128e102
3 changed files with 6 additions and 4 deletions

View File

@ -76,7 +76,8 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
for (auto levId : levIds) {
auto ev = lookupEventByLevId(txn, levId);
storageVector.insert(packed.created_at(), packed.id().substr(0, ne.idSize));
PackedEventView packed(ev.buf);
storageVector.insert(packed.created_at(), packed.id());
}
LI << "Filter matches " << numEvents << " events";

View File

@ -161,7 +161,8 @@ void RelayServer::runNegentropy(ThreadPool<MsgNegentropy>::Thread &thr) {
for (auto levId : view->levIds) {
try {
auto ev = lookupEventByLevId(txn, levId);
view->storageVector.insert(packed.created_at(), packed.id().substr(0, view->ne.idSize));
PackedEventView packed(ev.buf);
view->storageVector.insert(packed.created_at(), packed.id());
} catch (std::exception &) {
// levId was deleted when query was paused
}

View File

@ -231,9 +231,9 @@ std::string_view getEventJson(lmdb::txn &txn, Decompressor &decomp, uint64_t lev
bool deleteEvent(lmdb::txn &txn, uint64_t levId, negentropy::storage::BTreeLMDB &negentropyStorage) {
auto view = env.lookup_Event(txn, levId);
if (!view) return false;
auto *flat = view->flat_nested();
PackedEventView packed(view->buf);
negentropyStorage.erase(flat->created_at(), sv(flat->id()));
negentropyStorage.erase(packed.created_at(), packed.id());
bool deleted = env.dbi_EventPayload.del(txn, lmdb::to_sv<uint64_t>(levId));
env.delete_Event(txn, levId);