Skip to content

Firehose phase 4: active relay-health prober (unfreezes /relays)#16

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-15-relay-prober
Jun 17, 2026
Merged

Firehose phase 4: active relay-health prober (unfreezes /relays)#16
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-15-relay-prober

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Closes #15. Phase 4 — the active relay-health prober that refreshes the relays directory the /relays page renders (currently a frozen 2025-11 snapshot). It's active (dials each relay) and kind-less, so it's not a hose — a self-scheduling module of its own.

What

  • src/prober.js:
    • Connectivity: opens a WebSocket (Node global, no ws dep) → online, responseTime, lastError.
    • NIP-11: HTTP GET Accept: application/nostr+json (global fetch) → requiresAuth / requiresPayment from limitation.
    • Consistent uptime rollup: aggregation-pipeline updateOne $incs checksTotal/checksOnline then sets uptime = checksOnline/checksTotal*100 from the fresh totals — and lastChecked via $$NOW. Doesn't clobber unrelated fields (e.g. acceptsEvents).
    • Relay universe: the relays collection itself, continuously self-fed by the phase 2/3 hose harvesting.
    • Self-schedules (PROBE_INTERVAL, default 1h); --once / RUN_ONCE for a single sweep. PROBE_CONCURRENCY (25), PROBE_TIMEOUT (7s) env/CLI-configurable. Bounded-concurrency sweep.
  • probe.js: pm2/standalone entry (mirrors serve.js); npm run probe.
  • .env.example + README document it.

Verification

  • npm test55/55 (new pure-helper tests: arg parsing, proberConfig env+flag precedence, relayInfoUrl, nip11Flags).
  • node probe.js --help prints usage without connecting to Mongo.
  • Integration smoke — two real sweeps over a seeded scratch db:
    • uptime rollup correct (a flaky relay → 50%, checks 1/2; a stable one → 100%, 2/2);
    • NIP-11 detected a paid relay (nostr.winerequiresPayment: true);
    • a dead URL → online:false, uptime 0, lastChecked set; auth/payment left untouched.

Out of scope

Publish-test (acceptsEvents) — a later pass · deploy + cut-over on nostr.social — phase 5 (would run probe.js under pm2 alongside the indexer).

Refreshes the relays directory the /relays page renders (currently a
frozen 2025-11 snapshot). Active, kind-less — not a hose.

- src/prober.js: dials every relay in the directory (Node global WebSocket)
  for online/responseTime, fetches the NIP-11 info doc (global fetch) for
  requiresAuth/requiresPayment, and rolls up uptime via an aggregation-
  pipeline updateOne so uptime = checksOnline/checksTotal*100 stays
  consistent with the $inc'd totals. Self-schedules (PROBE_INTERVAL,
  default 1h); --once / RUN_ONCE for a single sweep. Concurrency + timeout
  env/CLI configurable. Relay universe = the relays collection, self-fed by
  the hose URL harvesting. No new deps.
- probe.js: pm2/standalone entry (mirrors serve.js); npm run probe.
- .env.example + README: document the prober.
- test/prober.test.js: pure helpers (config/flags, nip11Flags, relayInfoUrl).

Smoke (2 real sweeps): uptime rollup correct, NIP-11 detected a paid
relay, offline relays handled, lastChecked set. npm test 55/55.

Closes #15
@melvincarvalho
melvincarvalho merged commit 64ad298 into gh-pages Jun 17, 2026
@melvincarvalho
melvincarvalho deleted the issue-15-relay-prober branch June 17, 2026 09:46
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.

Firehose phase 4: active relay-health prober (unfreezes /relays)

1 participant