Pool adapter + bootstrap monitor relays (+ optional network filter)
A fresh Nip66Aggregator handle
import { createNip66Aggregator } from '@kehto/nip/66';
import { SimplePool } from 'nostr-tools/pool';
const pool = new SimplePool();
const aggregator = createNip66Aggregator({
pool: {
subscribe: (relays, filter, onEvent) => {
const sub = pool.subscribeMany(relays, [filter], { onevent: onEvent });
return () => sub.close();
},
},
bootstrap: ['wss://monitor1.example.com'],
});
aggregator.start();
// Later — inside a ShellAdapter hook:
const suggestions = Array.from(aggregator.getRelaySet());
Create a NIP-66 kind-30166 relay-discovery aggregator with closure-scoped state.
Subscribes to kind-30166 events via the injected Nip66RelayPool, extracts relay URLs from
d-tags, and parsesN-tags to track which NIP numbers each relay supports. Multi-instance safe — each factory call owns its ownSet+Map; multiple aggregators share nothing at module scope.The aggregator is framework-agnostic: it knows nothing about negentropy (NIP-77), OPFS caching, worker relays, or network-type config stores. Consumers inject those concerns through their Nip66RelayPool implementation.
start()is synchronous and idempotent — consumers schedule their own cadence (delayed start, retry, etc.).