Documentation
    Preparing search index...

    Interface IAuthoredDataSyncStore

    Interface that a data store needs to implement to manage blobs by their hashes.

    The store is the sole owner of the content-hash algorithm and the monotonic authoring clock. Local authoring goes through store, blobs received from peers through accept.

    interface IAuthoredDataSyncStore {
        accept(blob: Blob, author: string, authoredAt: number): Hash | null;
        get(hash: Hash, author: string): StoredBlob | undefined;
        getByAuthorBefore(author: string, before: number): StoredBlob[];
        getByAuthorSince(author: string, since: number): StoredBlob[];
        getLastKnownByAuthor(author: string): StoredBlob | undefined;
        onAuthored(listener: (entry: StoredBlob) => void): () => void;
        store(blob: Blob, author: string): Hash;
    }
    Index

    Methods

    • Persist a blob received from author at their authoredAt. The store computes the hash and stores if the distribution policy's willStore applies.

      Parameters

      • blob: Blob
      • author: string
      • authoredAt: number

      Returns Hash | null

      the hash if stored, or null if not stored (the policy declined it, or it exceeds the maximum blob size)

    • Blobs by author with authoredAt < before, ascending by authoredAt. (historical segment)

      Parameters

      • author: string
      • before: number

      Returns StoredBlob[]

    • Blobs by author with authoredAt >= since, ascending by authoredAt. (recent delta)

      Parameters

      • author: string
      • since: number

      Returns StoredBlob[]

    • The author's most recently authored blob this node holds, or undefined if none is held.

      Parameters

      • author: string

      Returns StoredBlob | undefined

    • Subscribe to locally authored blobs

      Parameters

      Returns () => void

      a function that removes the subscription

    • Author a local blob: hash it, assign a monotonic authoredAt from the store's clock, persist it under author, and notify onAuthored subscribers.

      Parameters

      • blob: Blob
      • author: string

      Returns Hash

      the blob's hash

      if the blob exceeds the store's maximum blob size