reticulum-js
    Preparing search index...

    Class InterfaceDiscovery

    Consumer-side orchestrator for on-network interface discovery (Python InterfaceDiscovery). Subscribes to the transport "announce" event, aspect-filters to ASPECT, stamp-validates each candidate, and dispatches a "discovered" event for every fresh/repeated discovery.

    Persists discoveries across restarts when a storage adapter with the KV interface (#16) is supplied; otherwise keeps them in memory. v1 is surface-only — it does not auto-connect discovered interfaces.

    Hierarchy

    • EventTarget
      • InterfaceDiscovery
    Index
    _announceListener: ((event: Event) => void) | null = null
    _aspectNameHash: Uint8Array<ArrayBufferLike> | null = null
    _chain: Promise<void> = ...
    _started: boolean = false
    _store: Map<string, DiscoveredInterface> = ...
    backboneSupport: boolean
    discoverySources: Uint8Array<ArrayBufferLike>[] | null
    networkIdentity: Identity | null
    requiredValue: number
    startPromise: Promise<void> | null = null

    The in-flight start() promise, set by the Reticulum constructor when discovery is auto-started. Await this to ensure the listener is attached.

    storageAdapter: any
    storageNamespace: "discovery"
    transport: TransportCore
    • Returns the adapter only if it implements the KV interface (#16).

      Returns { delete: Function; get: Function; keys: Function; set: Function } | null

    • Handles a transport "announce" event: aspect-filters, parses, persists, and dispatches "discovered". Processing is serialized through InterfaceDiscovery#_chain so concurrent announces for the same interface can't lose heard_count increments (Python's discovery_lock).

      Parameters

      • event: CustomEvent<any>

      Returns void

    • Persists a record via the storage adapter.

      Parameters

      • key: string
      • info: DiscoveredInterface

      Returns Promise<void>

    • The actual (async) announce processing, run one at a time per instance.

      Parameters

      • event: CustomEvent<any>

      Returns Promise<void>

    • Upserts a discovery into the store (and storage adapter), bumping heard_count on repeats and refreshing last_heard. Mirrors Python's interface_discovered persistence flow.

      Parameters

      • info: DiscoveredInterface

      Returns Promise<void>

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Returns the persisted discovered-interface list, mirroring Python's list_discovered_interfaces.

      Records past THRESHOLD_REMOVE, or whose type/reachable_on is no longer valid, are pruned (from memory and the storage adapter). Remaining records get a computed status/status_code and are sorted by freshness, stamp value, then last-heard.

      Parameters

      • Optionalfilter: { onlyAvailable?: boolean; onlyTransport?: boolean } = {}
        • OptionalonlyAvailable?: boolean

          Only available records.

        • OptionalonlyTransport?: boolean

          Only records where transport is true.

      Returns Promise<DiscoveredInterface[]>

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Precomputes the aspect name-hash, hydrates the store from the storage adapter, and attaches the transport "announce" listener. Idempotent.

      Returns Promise<void>