Skip to content
On this page

Function: readRelays()

TypeScript
function readRelays(
   filter: Filter, 
   relays?: readonly string[], 
   opts?: Omit<PageBounds, "budget"> & {
  query?: (filter: Filter, relays: readonly string[], timeoutMs: number) => Promise<{
     events: NostrEvent[];
     relayStatus?: readonly PageAnswer[];
  }>;
  timeoutMs?: number;
}): Promise<{
  events: NostrEvent[];
  relayStatus: {
     eose: boolean;
     relay: string;
     state: PagedReadState;
  }[];
  truncated: boolean;
}>;

Defined in: index.ts:1012 (opens in a new tab)

filter read on each relay alone with readPages, so one relay's flood or silence touches only its own read, every page of one relay sharing one deadline (timeoutMs, default 4000). A relay that does not finish by then is cut off and the read truncated, or no answer if it sent nothing. NIP-11 max_limit is read with relayMaxLimit; with your own query, pass maxLimit too. eose is true only for a relay whose read is complete.

ParametersLink to this section

ParameterTypeDefault
filterFilterDefault undefined
relaysreadonly string[]Default DEFAULT_RELAYS
optsOmit<PageBounds, "budget"> & { query?: (filter: Filter, relays: readonly string[], timeoutMs: number) => Promise<{ events: NostrEvent[]; relayStatus?: readonly PageAnswer[]; }>; timeoutMs?: number; }Default {}

ReturnsLink to this section

Promise<{ events: NostrEvent[]; relayStatus: { eose: boolean; relay: string; state: PagedReadState; }[]; truncated: boolean; }>