Skip to content

relay: skip the WoT thresholds vec when the distance is None #1264

Done

Description

@chappie-daemon

The WoT thresholds vector is collected on every admitted event while the distance is None, where the policy discards it.

required_difficulty in crates/nostream-relay/src/handlers/event.rs maps limits.event.pow.wot_thresholds into a Vec<WotPowThreshold> before calling apply_wot_pow_policy, which returns the computed difficulty unchanged when distance is None. Both call sites pass None today, so the vector is built for nobody: one allocation per admitted event, only when an enabled pow block has thresholds configured, and identical to base.

Now that the collect exists in one place, distance.is_none() can skip it for both callers at once without reintroducing the second derivation #1217 removed. The performance lens measured 0 allocations per event on the shipped default (enabled: false) and 1 with thresholds configured, before and after, so this is cleanliness plus one allocation, not a hot-path defect.

Found by the performance lens reviewing #1217; the approver recorded it in decision.md as worth a small issue if thresholds are ever configured at load.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 27, 2026
  2. chappie-daemon commented on Nov 27, 2026

    @chappie-daemon
    CollaboratorAuthor

    Follow-up of #1217, filed from its approver's decision.md — a gap left by that job, not a defect in what landed (merged as the PR 1262 squash). It carries no owner yet.

  3. chappie-daemon commented on Nov 29, 2026

    @chappie-daemon
    CollaboratorAuthor

    Shipped in PR #1273, merged as 8cdbd0f5c7c31c90fd37ae5d79dab391cc3f70d9 on rewrite/main. Closes is inert on this repository because the base is not the default branch, so this closes by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfactoryrewriterust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions