Hierarchy

  • EventEmitter<NostrSystemEvents>
    • SystemWorker

Implements

Constructors

  • Parameters

    • scriptPath: string
    • props: NostrsystemProps

    Returns SystemWorker

Properties

#commandQueue: Map<string, ((v) => void)> = ...

Type declaration

    • (v): void
    • Parameters

      • v: unknown

      Returns void

#log: Debugger = ...
#worker: Worker
eventsCache: FeedCache<NostrEvent>
profileCache: FeedCache<CachedMetadata>
profileLoader: ProfileLoaderService
relayCache: FeedCache<UsersRelays>
relayLoader: RelayMetadataLoader
relayMetricsCache: FeedCache<RelayMetrics>
relayMetricsHandler: RelayMetricHandler
prefixed: string | boolean

Accessors

  • get checkSigs(): boolean
  • Check event signatures (reccomended)

    Returns boolean

  • set checkSigs(v): void
  • Check event signatures (reccomended)

    Parameters

    • v: boolean

    Returns void

  • get optimizer(): Optimizer
  • Query optimizer

    Returns Optimizer

  • get pool(): ConnectionPool
  • Main connection pool

    Returns ConnectionPool

Methods

  • Type Parameters

    • T

    • R

    Parameters

    • type: WorkerCommand
    • Optional data: T
    • timeout: number = 5_000

    Returns Promise<R>

  • Send an event to all permanent connections

    Parameters

    • ev: NostrEvent

      Event to broadcast

    • Optional cb: ((rsp) => void)

      Callback to handle OkResponse as they arrive

    Returns Promise<OkResponse[]>

  • Create a new permanent connection to a relay

    Parameters

    • address: string

      Relay URL

    • options: RelaySettings

      Read/Write settings

    Returns Promise<void>

  • Disconnect permanent relay connection

    Parameters

    • address: string

      Relay URL

    Returns void

  • Fetch data from nostr relays asynchronously

    Parameters

    • req: RequestBuilder

      Request to send to relays

    • Optional cb: ((evs) => void)

      A callback which will fire every 100ms when new data is received

    Returns Promise<TaggedNostrEvent[]>

  • Get an active query by ID

    Parameters

    • id: string

      Query ID

    Returns undefined | QueryLike

  • Push an event into the system from external source

    Parameters

    Returns void

  • Do some initialization

    Returns Promise<void>

  • Connect to a specific relay and send an event and wait for the response

    Parameters

    • relay: string

      Relay URL

    • ev: NostrEvent

      Event to send

    Returns Promise<OkResponse>

  • Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

          Returns void

    • Optional context: any

    Returns this

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (keyof NostrSystemEvents)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: keyof NostrSystemEvents

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

          Returns void

    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

          Returns void

    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: keyof NostrSystemEvents

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends keyof NostrSystemEvents

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<NostrSystemEvents>[Extract<T, keyof NostrSystemEvents>]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

Generated using TypeDoc