Interface SessionBlockstore

A session blockstore is a special blockstore that only pulls content from a subset of network peers which respond as having the block for the initial root CID.

Any blocks written to the blockstore as part of the session will propagate to the blockstore the session was created from.

interface SessionBlockstore {
    close(): void;
    delete(key, options?): Await<void>;
    deleteMany(source, options?): AwaitIterable<CID<unknown, number, number, Version>>;
    get(key, options?): Await<Uint8Array>;
    getAll(options?): AwaitIterable<Pair>;
    getMany(source, options?): AwaitIterable<Pair>;
    has(key, options?): Await<boolean>;
    put(key, val, options?): Await<CID<unknown, number, number, Version>>;
    putMany(source, options?): AwaitIterable<CID<unknown, number, number, Version>>;
}

Hierarchy

Methods

  • Any in-progress operations will be aborted.

    Returns void

  • Remove the record for the passed key

    Parameters

    Returns Await<void>

    Example

    await store.delete(new Key('awesome'))
    console.log('deleted awesome content :(')
  • Retrieve all cid/block pairs from the blockstore as an unordered iterable

    Returns AwaitIterable<Pair>

    Example

    for await (const { multihash, block } of store.getAll()) {
    console.log('got:', multihash, block)
    // => got MultihashDigest('Qmfoo') Uint8Array[...]
    }
  • Check for the existence of a value for the passed key

    Parameters

    Returns Await<boolean>

    Example

    const exists = await store.has(new Key('awesome'))

    if (exists) {
    console.log('it is there')
    } else {
    console.log('it is not there')
    }