Interface Store

interface Store {
    acquireChain: (identity: string) => Promise<BundleInfo>;
    close: () => Promise<void>;
    getBundles: (callback: (bundle: BundleView) => void) => Promise<void>;
    getChainIdentity: (chainInfo: [number, number]) => Promise<string>;
    getChainTracker: () => Promise<ChainTracker>;
    getContainerBytes: (address: Muid) => Promise<Bytes>;
    getLocation: (entry: Muid, asOf?: AsOf) => Promise<Placement>;
    getVerifyKey: (chainInfo: [number, number]) => Promise<Bytes>;
    ready: Promise<void>;
    addBundle(bundle: BundleView, claimChain?: boolean): Promise<Boolean>;
    addFoundBundleCallBack(callback: BroadcastFunc): void;
    getAllContainerTuples(): Promise<MuidTuple[]>;
    getBillionths(muid: Muid, asOf?: AsOf): Promise<bigint>;
    getContainerProperties(
        containerMuid: Muid,
        asOf?: AsOf,
    ): Promise<Map<string, Value>>;
    getContainersByName(name: string, asOf?: AsOf): Promise<Muid[]>;
    getEntriesBySourceOrTarget(
        vertex: Muid,
        source: boolean,
        asOf?: AsOf,
    ): Promise<Entry[]>;
    getEntryById(entryMuid: Muid, asOf?: AsOf): Promise<Entry>;
    getEntryByKey(
        container: Muid,
        key?: ScalarKey | Muid | [Muid, Muid],
        asOf?: AsOf,
    ): Promise<Entry>;
    getKeyedEntries(source: Muid, asOf?: AsOf): Promise<Map<string, Entry>>;
    getOrderedEntries(
        source: Muid,
        through: number,
        asOf?: AsOf,
    ): Promise<Map<string, Entry>>;
    getSymmetricKey(keyId: Number): Promise<Bytes>;
    pullKeyPair(publicKey: Bytes): Promise<KeyPair>;
    saveKeyPair(keyPair: KeyPair): Promise<void>;
    saveSymmetricKey(symmetricKey: Bytes): Promise<number>;
}

Implemented by

Properties

acquireChain: (identity: string) => Promise<BundleInfo>

Tries to see if there's a free chain available with the given identity that's not currently being used by another processes, and if so, adds a claim to it and returns the final link of that chain.

close: () => Promise<void>

Closes the underlying data store. Implicitly awaits on the this.ready promise.

getBundles: (callback: (bundle: BundleView) => void) => Promise<void>

Get all bundles from a store ordered by [timestamp, medallion]. Intended to be used to send to a peer.

The callback should NOT await on anything (will cause problems with the IndexedDb implementation if you do). See https://github.com/google/gink/issues/28

Implicitly awaits on this.ready;

getChainIdentity: (chainInfo: [number, number]) => Promise<string>

Attempts to get the identity of the user who started the chain.

Type declaration

    • (chainInfo: [number, number]): Promise<string>
    • Parameters

      • chainInfo: [number, number]

        [Medallion, ChainStart]

      Returns Promise<string>

      a string of the identity of the user who started the chain.

getChainTracker: () => Promise<ChainTracker>

Generates a ChainTracker describing how much of each chain this store has.

Implicitly awaits on this.ready;

getContainerBytes: (address: Muid) => Promise<Bytes>

Gets the protobuf bytes corresponding to a particular container's address.

getLocation: (entry: Muid, asOf?: AsOf) => Promise<Placement>

In ordered container types (Sequence and EdgeType), entries may be moved around. This method returns information about the current effective time, which may be different from the timestamp of the entry itself.

Type declaration

    • (entry: Muid, asOf?: AsOf): Promise<Placement>
    • Parameters

      • entry: Muid

        the muid of the entry

      • OptionalasOf: AsOf

        optional timestamp to look back to

      Returns Promise<Placement>

      an object with the container muid, key, and the placement id.

getVerifyKey: (chainInfo: [number, number]) => Promise<Bytes>

Attempt to get the verify key for a particular chain (stored with the first bundle).

ready: Promise<void>

Can be awaited on for the underlying store to be ready for operations. Methods of the store should await on this, so if initialization fails then no other method will work either.

Methods

  • Tries to add a bundle to this store; returns truthy if actually added, false if not (e.g. if already has it). Will throw if passed a bundle without the proceeding ones in the associated chain.

    Optionally can reuse/start a new chain.

    Implicitly awaits on this.ready;

    Parameters

    Returns Promise<Boolean>

  • Adds a callback to be called when a bundle was added by a different store and is found by the current store. Primarily intended for use with the LogBackedStore and file sharing.

    Parameters

    • callback: BroadcastFunc

      the function to be called when a new bundle is found. It needs to take two arguments, bundleBytes and bundleInfo.

    Returns void

  • Get the properties corresponding to a container.

    Parameters

    • containerMuid: Muid

      the Muid of the container to get the properties of

    • OptionalasOf: AsOf

      optional timestamp to look back to

    Returns Promise<Map<string, Value>>

    a Map of string Muid (of the Property Container) to Value

  • Returns an Array of all containers matching the provided name. Names are set using the global property.

    Parameters

    • name: string
    • OptionalasOf: AsOf

      optional timestamp to look back to

    Returns Promise<Muid[]>

  • returns a map where the entries were inserted in the desired order, and the keys correspond to ,.

    Parameters

    • source: Muid
    • through: number
    • OptionalasOf: AsOf

    Returns Promise<Map<string, Entry>>

  • Retrieves a previously stored symmetric key.

    Parameters

    • keyId: Number

      the id of the symmetric key to retrieve

    Returns Promise<Bytes>

  • Saves a symmetric key for future use. Returns the keyId (a 52 bit digest of the key).

    Parameters

    • symmetricKey: Bytes

      the symmetric key to store

    Returns Promise<number>