Options
All
  • Public
  • Public/Protected
  • All
Menu

BlockService is a hybrid block datastore. It stores data in a local datastore and may retrieve data from a remote Exchange. It uses an internal datastore.Datastore instance to store values.

Hierarchy

  • BlockService

Index

Constructors

constructor

  • new BlockService(ipfsRepo: IpfsRepo): BlockService
  • Create a new BlockService

    Parameters

    • ipfsRepo: IpfsRepo

    Returns BlockService

Properties

_bitswap

_bitswap: any

_repo

_repo: IpfsRepo

Methods

delete

  • delete(cid: CID, options: undefined | { signal: undefined | AbortSignal }): Promise<void>
  • Delete a block from the blockstore.

    Parameters

    • cid: CID
    • options: undefined | { signal: undefined | AbortSignal }

    Returns Promise<void>

deleteMany

  • deleteMany(cids: AsyncIterable<CID> | Iterable<CID>, options: undefined | { signal: undefined | AbortSignal }): AsyncIterable<Key>
  • Delete multiple blocks from the blockstore.

    Parameters

    • cids: AsyncIterable<CID> | Iterable<CID>
    • options: undefined | { signal: undefined | AbortSignal }

    Returns AsyncIterable<Key>

get

  • get(cid: CID, options: undefined | { signal: undefined | AbortSignal }): Promise<Block>
  • Get a block by cid.

    Parameters

    • cid: CID
    • options: undefined | { signal: undefined | AbortSignal }

    Returns Promise<Block>

getMany

  • getMany(cids: AsyncIterable<CID> | Iterable<CID>, options: undefined | { signal: undefined | AbortSignal }): AsyncIterable<Block>
  • Get multiple blocks back from an array of cids.

    Parameters

    • cids: AsyncIterable<CID> | Iterable<CID>
    • options: undefined | { signal: undefined | AbortSignal }

    Returns AsyncIterable<Block>

hasExchange

  • hasExchange(): boolean
  • Is the blockservice online, i.e. is bitswap present.

    Returns boolean

put

  • put(block: Block, options: undefined | { signal: undefined | AbortSignal }): Promise<Block>
  • Put a block to the underlying datastore.

    Parameters

    • block: Block
    • options: undefined | { signal: undefined | AbortSignal }

    Returns Promise<Block>

putMany

  • putMany(blocks: AsyncIterable<Block> | Iterable<Block>, options: undefined | { signal: undefined | AbortSignal }): AsyncIterable<Block>
  • Put a multiple blocks to the underlying datastore.

    Parameters

    • blocks: AsyncIterable<Block> | Iterable<Block>
    • options: undefined | { signal: undefined | AbortSignal }

    Returns AsyncIterable<Block>

setExchange

  • setExchange(bitswap: any): void
  • Add a bitswap instance that communicates with the network to retreive blocks that are not in the local store.

    If the node is online all requests for blocks first check locally and afterwards ask the network for the blocks.

    Parameters

    • bitswap: any

    Returns void

unsetExchange

  • unsetExchange(): void
  • Go offline, i.e. drop the reference to bitswap.

    Returns void