Skip to content

refactor: move inactive stream records to temporary storage - #68

Merged
elizabetheonoja-art merged 2 commits into
SubStream-Protocol:mainfrom
ScriptedBro:refactor/temporary-storage-for-inactive-streams
Mar 24, 2026
Merged

refactor: move inactive stream records to temporary storage#68
elizabetheonoja-art merged 2 commits into
SubStream-Protocol:mainfrom
ScriptedBro:refactor/temporary-storage-for-inactive-streams

Conversation

@ScriptedBro

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes stream ledger storage by keeping active subscription records in Persistent storage while moving inactive (depleted) records to Temporary storage.

What Changed

  • Added stream storage routing helpers:
    • stream_exists
    • get_stream
    • set_stream
    • remove_stream
  • Updated stream lifecycle logic to read/write via the helpers instead of directly using persistent storage.
  • Implemented storage policy:
    • active streams (balance > 0) -> Persistent storage
    • inactive streams (balance == 0) -> Temporary storage
  • Applied this behavior across subscribe, collect, top-up, cancel, group flows, pause/unpause handling, tier migration, and batch withdrawal paths.
  • Added tests to verify storage transitions:
    • inactive stream moves to temporary storage
    • top-up reactivates stream back to persistent storage
  • Updated snapshots from test execution.

Why

Using Temporary storage for inactive subscription records reduces long-term ledger fee pressure while preserving active-stream durability in Persistent storage.

Validation

  • Ran cargo test
  • Result: 13 passed, 0 failed

Checklist

  • Active streams remain in Persistent storage
  • Inactive streams are moved to Temporary storage
  • Added tests for inactive/active storage transitions
  • Verified all existing tests still pass

Issue

Closes #17
Closes: #17

@drips-wave

drips-wave Bot commented Mar 24, 2026

Copy link
Copy Markdown

@ScriptedBro Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@elizabetheonoja-art
elizabetheonoja-art merged commit cd2ed1a into SubStream-Protocol:main Mar 24, 2026
1 check failed
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.

#17 Refactor Subscriber_Data for State Archival (TTL)

2 participants