Class Database

This is an instance of the Gink database that can be run inside a web browser or via ts-node on a server. Because of the need to work within a browser it doesn't do any port listening (see SimpleServer for that capability).

Hierarchy (View Summary)

Constructors

Properties

keyPair?: KeyPair
lastLink?: BundleInfo
logger: CallBack
medallion?: number
peers: Map<number, Peer> = ...
promiseChainLock: PromiseChainLock = ...
ready: Promise<any>
store: Store
PROTOCOL: "gink"

Accessors

Methods

  • Adds a listener that will be called every time a bundle is received with the BundleInfo (which contains chain information, timestamp, and bundle comment).

    Parameters

    • listener: BundleListener

      a callback to be invoked when a change occurs in the database or container

    • OptionalcontainerMuid: Muid

      the Muid of a container to subscribe to. If left out, subscribe to all containers.

    • remoteOnly: boolean = false

    Returns void

  • Initiates a websocket connection to a peer.

    Parameters

    • target: string

      a websocket uri, e.g. "ws://127.0.0.1:8080/"

    • Optionaloptions: {
          authToken?: string;
          onClose?: CallBack;
          resolveOnOpen?: boolean;
          retryOnDisconnect?: boolean;
      }

    Returns Promise<Peer>

    a promise to the peer

  • Parameters

    • messageBytes: Uint8Array

      Bytes received from a peer.

    • fromConnectionId: number

      Local name of the peer the data was received from.

    Returns Promise<void>