From d17a6aa9c8e3aefc2086c17baa6b180d32a3ca6b Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Tue, 5 Dec 2023 18:19:11 -0500 Subject: [PATCH] remove old ephemeral event pruning method --- src/apps/relay/RelayCron.cpp | 58 ------------------------------------ 1 file changed, 58 deletions(-) diff --git a/src/apps/relay/RelayCron.cpp b/src/apps/relay/RelayCron.cpp index 558f07e..7413531 100644 --- a/src/apps/relay/RelayCron.cpp +++ b/src/apps/relay/RelayCron.cpp @@ -9,64 +9,6 @@ void RelayServer::runCron() { cron.setupCb = []{ setThreadName("cron"); }; - // Delete ephemeral events - // FIXME: This is for backwards compat during upgrades, and can be removed eventually since - // the newer style of finding ephemeral events relies on expiration=1 - - cron.repeat(10 * 1'000'000UL, [&]{ - std::vector expiredLevIds; - - { - auto txn = env.txn_ro(); - - auto mostRecent = getMostRecentLevId(txn); - uint64_t cutoff = hoytech::curr_time_s() - cfg().events__ephemeralEventsLifetimeSeconds; - uint64_t currKind = 20'000; - - while (currKind < 30'000) { - uint64_t numRecs = 0; - - env.generic_foreachFull(txn, env.dbi_Event__kind, makeKey_Uint64Uint64(currKind, 0), lmdb::to_sv(0), [&](auto k, auto v) { - numRecs++; - ParsedKey_Uint64Uint64 parsedKey(k); - currKind = parsedKey.n1; - - if (currKind >= 30'000) return false; - - if (parsedKey.n2 > cutoff) { - currKind++; - return false; - } - - uint64_t levId = lmdb::from_sv(v); - - if (levId != mostRecent) { // prevent levId re-use - expiredLevIds.emplace_back(levId); - } - - return true; - }); - - if (numRecs == 0) break; - } - } - - if (expiredLevIds.size() > 0) { - auto txn = env.txn_rw(); - - uint64_t numDeleted = 0; - - for (auto levId : expiredLevIds) { - if (deleteEvent(txn, levId)) numDeleted++; - } - - txn.commit(); - - if (numDeleted) LI << "Deleted " << numDeleted << " ephemeral events"; - } - }); - - // Delete expired events cron.repeat(9 * 1'000'000UL, [&]{