• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 46198549982
78%
main: 81%

Build:
Build:
LAST BUILD BRANCH: rewrite/main
DEFAULT BRANCH: main
Ran 28 Nov 2026 10:52PM UTC
Jobs 2
Files 321
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Nov 2026 10:49PM UTC coverage: 77.582% (-0.006%) from 77.588%
46198549982

push

github

web-flow
refactor(relay): skip the WoT thresholds vec when the distance is None (#1264) (#1273)

## Description

Short-circuits `required_difficulty` in
`crates/nostream-relay/src/handlers/event.rs` when `distance.is_none()`,
returning `computed` difficulty directly and avoiding mapping and
collecting `limits.event.pow.wot_thresholds` into a heap-allocated
`Vec<WotPowThreshold>`.

## Related Issue

Closes #1264

## Motivation and Context

In `required_difficulty`, `limits.event.pow.wot_thresholds` was mapped
and collected into a `Vec<WotPowThreshold>` on every admitted event
before calling `adaptive_pow::apply_wot_pow_policy`. When `distance` is
`None` (which is true at all current event handler and NIP-11 call
sites), `apply_wot_pow_policy` returns the computed difficulty unchanged
and discards the thresholds.

By skipping threshold collection when `distance.is_none()`, we eliminate
an unnecessary heap allocation on every admitted event whenever
proof-of-work thresholds are configured.

## How Has This Been Tested?

- Added unit tests in `crates/nostream-relay/src/handlers/event.rs`:
- `required_difficulty_skips_thresholds_when_distance_is_none`: verifies
that `distance: None` returns the computed difficulty without threshold
discount, and that `distance: Some(d)` applies the matching discount.
- `required_difficulty_handles_empty_or_absent_thresholds`: verifies
that empty and absent threshold lists are handled gracefully without
error.
- Ran all unit and integration tests across `nostream-relay` (`287/287
passed`):
  - `cargo test -p nostream-relay --lib` (24 passed)
  - `cargo test -p nostream-relay --test nip11` (8 passed)
  - `cargo test -p nostream-relay` (all 287 passed)
- Verified formatting and lints:
  - `cargo fmt --check --package nostream-relay`
  - `cargo clippy -p nostream-relay --all-targets -- -D warnings`

## Types of changes

- [x] Non-functional change (docs, style, minor refactor)
- [x] Bug fix (non-breaking change which fixes an issue)
- ... (continued)

4501 of 6342 branches covered (70.97%)

Branch coverage included in aggregate %.

9792 of 12081 relevant lines covered (81.05%)

759.21 hits per line

Jobs
ID Job ID Ran Files Coverage
1 Integration - 46198549982.1 28 Nov 2026 10:52PM UTC 321
32.99
GitHub Action Run
2 Unit - 46198549982.2 28 Nov 2026 10:53PM UTC 321
75.03
GitHub Action Run
Source Files on build 46198549982
  • Tree
  • List 321
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #46198549982
  • 8cdbd0f5 on github
  • Prev Build on rewrite/main (#46048734954)
  • Next Build on rewrite/main (#46262937164)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc