From ec3af0d59ea62ad5d7a6bc355e022afca892c300 Mon Sep 17 00:00:00 2001 From: wet-bulb <52295339+wet-bulb@users.noreply.github.com> Date: Mon, 3 Aug 2026 18:48:44 -0500 Subject: [PATCH] Apply the record cap to the path store in Transport::start() Transport::start() calls set_max_recs() for the packet-hashlist store and the known-destinations store, but never for the path store. microStore's policy_max_recs defaults to USTORE_DEFAULT_MAX_RECS, which is 0 and means "disabled", so the RNS_PATH_TABLE_MAX default of 100 never reaches the store. A consumer building directly on the library therefore runs with an uncapped path store unless it calls Transport::path_table_maxsize() itself. The same value gates compact_if_threshold(), where the dead-record percentage is computed relative to policy_max_recs. Leaving it unset therefore disables both the record cap and the threshold compaction that reclaims TTL-expired records nothing ever reads back. Lazy per-access removal in get()/exists() cannot help those, because nothing accesses them. Defaults are unchanged: 100 stays 100, it simply takes effect. Verified against a real BasicFileStore over a host filesystem: with the cap unset, 300 inserts leave 300 records; with it set to 100, 300 inserts leave exactly 100. --- src/microReticulum/Transport.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/microReticulum/Transport.cpp b/src/microReticulum/Transport.cpp index 89b5238..eeb8ac9 100644 --- a/src/microReticulum/Transport.cpp +++ b/src/microReticulum/Transport.cpp @@ -399,6 +399,15 @@ DestinationEntry empty_destination_entry; } } #endif // RNS_USE_FS && RNS_PERSIST_PATHS + // Apply the record cap to the path store, as is already done for the + // packet hashlist above and the known destinations below. Without this + // the RNS_PATH_TABLE_MAX default never reaches microStore, whose + // policy_max_recs defaults to 0 meaning disabled, so the path store + // runs uncapped unless the application calls + // Transport::path_table_maxsize() itself. The same value also gates + // compact_if_threshold(), so leaving it unset costs both the record cap + // and the compaction that reclaims expired records nothing reads back. + _path_store.set_max_recs(_path_table_maxsize); #if defined(RNS_USE_FS) && RNS_PERSIST_KNOWN_DESTINATIONS if (Utilities::OS::get_filesystem()) {