helia
    Preparing search index...

    Module @helia/block-brokers

    This module contains Helia block brokers, currently for bitswap and Trustless Gateways.

    The TrustlessGatewayBlockBroker fetches blocks from HTTP gateways.

    It is possible to modify outgoing requests to (for example) include authentication information (such as a JWT token in a header).

    import { createHelia } from 'helia'
    import { trustlessGateway } from '@helia/block-brokers'
    import { unixfs } from '@helia/unixfs'
    import { CID } from 'multiformats/cid'
    import { concat } from 'uint8arrays/concat'
    import all from 'it-all'

    const helia = await createHelia({
    blockBrokers: [
    trustlessGateway({
    transformRequestInit: (requestInit) => {
    // modify the request init object as required
    requestInit.headers = {
    ...requestInit.headers,
    'User-Agent': 'Helia Example Script'
    }
    return requestInit
    }
    })
    ]
    })

    const cid = CID.parse('bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa')
    const fs = unixfs(helia)

    for await (const chunk of fs.cat(cid, {
    signal: AbortSignal.timeout(10_000)
    })) {
    console.info(chunk)
    }

    Interfaces

    BitswapBlockBrokerComponents
    BitswapBlockBrokerInit
    BitswapProvider
    TrustlessGatewayBlockBrokerComponents
    TrustlessGatewayBlockBrokerInit
    TrustlessGatewayProvider

    Type Aliases

    TrustlessGatewayGetBlockProgressEvents

    Functions

    bitswap
    trustlessGateway