1.4.0 • Published 5 months ago

@hash-stream/streamer v1.4.0

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
5 months ago

Install

npm install @hash-stream/streamer

Usage

This usage guides takes into account that the Pack Store and Index Store used by the streamer implementation to stream data from are populated with the multihashes to be requested. If not the case, please see the documentation for pack and index packages first.

import { HashStreamer } from '@hash-stream/streamer'
import { IndexReader } from '@hash-stream/index/reader'
import { FSIndexStore } from '@hash-stream/index/store/fs'
import { FSPackStore } from '@hash-stream/pack/store/fs'
import { PackReader } from '@hash-stream/pack'

async function main() {
  // Initialize the stores
  const indexStore = new FSIndexStore('/path/to/index-store')
  const packStore = new FSPackStore('/path/to/pack-store')

  // Initialize the readers
  const indexReader = new IndexReader(indexStore)
  const packReader = new PackReader(packStore)

  // Initialize the streamer
  const hashStreamer = new HashStreamer(indexReader, packReader)

  // Fill in multihashes to look for
  const targetMultihash = // TODO
  const containingMultihash = // TODO

  // Iterate over the verifiable entries and reconstruct the content
  for await (const { multihash, bytes } of hashStreamer.stream(
    targetMultihash,
    { containingMultihash }
  )) {
    // TODO
  }
}

main().catch(console.error)

One of the typical ways to transport the verifiable entries is via CAR files. A CarWriter may be used to write the content of the stream into.

Relevant Specifications

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under MIT + Apache 2.0

1.4.0

5 months ago

1.3.1

5 months ago

1.3.0

5 months ago

1.2.1

5 months ago

1.2.0

6 months ago

1.1.0

6 months ago

1.0.0

7 months ago