Skip to content

Apply the record cap to the path store in Transport::start() - #76

Open
wet-bulb wants to merge 1 commit into
attermann:masterfrom
wet-bulb:fix/apply-path-store-cap
Open

Apply the record cap to the path store in Transport::start()#76
wet-bulb wants to merge 1 commit into
attermann:masterfrom
wet-bulb:fix/apply-path-store-cap

Conversation

@wet-bulb

@wet-bulb wet-bulb commented Aug 4, 2026

Copy link
Copy Markdown

Fixes the path table size limit never being applied

Transport::start() calls set_max_recs() for the packet-hashlist store and the known-destinations store, but not the path store. microStore's policy_max_recs defaults to USTORE_DEFAULT_MAX_RECS (0, disabled), so the RNS_PATH_TABLE_MAX default of 100 never reaches the store.

The same value is used by compact_if_threshold(). Leaving it unset disables both the record limit and threshold compaction. Lazy cleanup in get() and exists() does not cover this case, since expired records that are never accessed remain in storage.

The fix is to call set_max_recs() for the path store during Transport::start(), matching the other stores.

Nothing changes for users overriding the limit. The default remains 100.

Against the Python reference

Checked against b48b96e.

The Python implementation limits paths by age. microReticulum limits them by count. RNS_PATH_TABLE_MAX and Transport::path_table_maxsize() already existed, and microReticulum_Firmware already sets the value at boot with URTN_PATH_TABLE_MAX_RECS. This fixes the missing connection between that value and the store.

Testing

Tested on

  • Native host build - real BasicFileStore over a host filesystem.
    300 inserts leave 300 records without the limit, and 100 records with the limit set to 100.

Not tested

  • compiles for nRF52840 but has not been run there

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant