You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: adaptive PoW difficulty based on relay load (NIP-13) #755
Is your feature request related to a problem? Please describe.
nostream already has basic NIP-13 PoW verification it checks leading zero bits on event IDs and pubkeys against a static minLeadingZeroBits config value (event-message-handler.ts). The difficulty is fixed, so it's either too low (useless during a spam flood) or too high (annoying during quiet periods).
Describe the solution you'd like
An adaptive difficulty layer on top of the existing PoW checks that scales the target difficulty based on real-time relay load when the relay is under heavy load the bar goes up, when things are quiet it comes back down
Track a relay load signal (events/second at minimum) and feed it into the difficulty calculation reuse the existing EWMA rate-tracking pattern (ewma-rate-limiter.ts) rather than building a second tracker, unless a suitable signal already exists in admin-metrics.ts / telemetry/metrics.ts
Reject events that don't meet the current threshold with a clear error message so clients know what's expected
Operators can configure floor and ceiling difficulty levels so the adaptive range stays within reason
Tests covering the difficulty calculation and the rejection flow
Activity