Skip to content

Data measurement#75

Merged
c03rad0r merged 22 commits intomainfrom
fix/data-measurement-cleanup
Jan 18, 2026
Merged

Data measurement#75
c03rad0r merged 22 commits intomainfrom
fix/data-measurement-cleanup

Conversation

@Origami74
Copy link
Contributor

@Origami74 Origami74 commented Jan 7, 2026

  • uses ndsctl for downstream measurement instead of measuring the gateway
  • added /usage endpoint that returns [usage]/[allotment]
  • use /usage endpoint to get remaining allotment for renewals

Your Name and others added 22 commits December 15, 2025 05:55
This commit refactors the session management architecture to correctly handle data-based (`bytes`) sessions.

Previously, the `Merchant` module was responsible for both payment processing and network access control via the `Valve`. This led to a critical flaw where data-based sessions were incorrectly granted a 24-hour time-based window, ignoring the purchased data allotment.

The new architecture delegates session lifecycle management to the `Chandler` module, adhering to a proper separation of concerns.

Key changes:
- The `Merchant`'s responsibility now ends after processing a payment. It notifies the `Chandler` to start a session.
- The `Chandler` is now the sole module responsible for creating the appropriate usage tracker and controlling the `Valve`.
- A new `CustomerSessionTracker` has been introduced to monitor data usage for downstream customers and close the gate when the allotment is consumed.
- The `Valve` has been updated with `OpenGate` and `CloseGate` functions to support indefinite data-based sessions.
- Documentation has been added to explain the architectural changes and the new session flow.
@Origami74 Origami74 marked this pull request as ready for review January 7, 2026 14:28
@Origami74 Origami74 requested review from Amperstrand and c03rad0r and removed request for c03rad0r January 8, 2026 07:29
@Origami74 Origami74 marked this pull request as draft January 8, 2026 16:34
@Origami74
Copy link
Contributor Author

Basic functionality seems to work but upstream usage-tracking seems out of sync, created branch debug/router-to-router to fix these issues. It's best if for now it just trusts the upstream to provide accurate info.

Once we got top-ups and multi-hop stable we can add tracking client-side again.

@Origami74 Origami74 changed the title Fix/data measurement cleanup Data measurement Jan 17, 2026
@Origami74 Origami74 marked this pull request as ready for review January 17, 2026 15:44
Copy link
Contributor

@c03rad0r c03rad0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

@c03rad0r c03rad0r merged commit 8171593 into main Jan 18, 2026
29 checks passed
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.

2 participants