HttpStore

@twine-protocol/twine-http-store v0.1.0Docs


twine-js / @twine-protocol/twine-http-store / HttpStore

Class: HttpStore

An HTTP client that implements Store

Implements

  • Store

Constructors

new HttpStore()

new HttpStore(baseUrl, fetcherOptions?): HttpStore

Create a new HTTP store

Parameters

Parameter
Type
Description

baseUrl

string

The base URL of the store

fetcherOptions?

FetcherOptions & HttpStoreOptions

Options for the fetcher

Returns

HttpStore

Defined in

index.ts:188arrow-up-right

Methods

fetchChain()

fetchChain(chainCid): Promise<null | Chain>

Fetch a chain by CID without validation

Parameters

Parameter
Type

chainCid

IntoCid

Returns

Promise<null | Chain>

Defined in

index.ts:219arrow-up-right


chains()

chains(): AsyncIterable<Chain, any, any>

Get the chains that are known to the resolver

Returns

AsyncIterable<Chain, any, any>

An sync/async iterable of chains

Example

Implementation of

Store.chains

Defined in

index.ts:228arrow-up-right


pulses()

pulses(chain, start?, options?): AsyncIterable<Pulse, any, any>

Get the pulses of a chain

Parameters

Parameter
Type
Description

chain

IntoCid

The chain CID or chain itself to get the pulses from

start?

number | IntoCid

The index or CID of the pulse to start from

options?

ResolveOptions

Options for the resolution

Returns

AsyncIterable<Pulse, any, any>

An sync/async iterable of pulses

Example

Implementation of

Store.pulses

Defined in

index.ts:236arrow-up-right


fetch()

fetch(cid): Promise<null | Twine<TwineValue>>

Fetch a twine from storage, returning null if it is not found

it is NOT expected that the twine signature is checked, that is for the Resolver to do.

Parameters

Parameter
Type
Description

cid

IntoCid

The CID of the twine to fetch

Returns

Promise<null | Twine<TwineValue>>

Implementation of

Store.fetch

Defined in

index.ts:294arrow-up-right


has()

has(cid): Promise<boolean>

Check if a cid can be resolved

Parameters

Parameter
Type
Description

cid

IntoCid

The CID to check

Returns

Promise<boolean>

True if the CID can be resolved, false otherwise

Example

Implementation of

Store.has

Defined in

index.ts:303arrow-up-right


delete()

delete(cid): Promise<void>

Delete a twine from storage

Parameters

Parameter
Type
Description

cid

IntoCid

The CID of the twine to delete

Returns

Promise<void>

Implementation of

Store.delete

Defined in

index.ts:309arrow-up-right


resolveIndex()

resolveIndex(chain, index, options?): Promise<PulseResolution>

Resolve a pulse by index

Parameters

Parameter
Type
Description

chain

IntoCid

The chain CID or chain itself to resolve the pulse from

index

number

The index of the pulse to resolve

options?

ResolveOptions

Options for the resolution

Returns

Promise<PulseResolution>

A pulse resolution

Example

Implementation of

Store.resolveIndex

Defined in

index.ts:313arrow-up-right


resolve()

resolve(query, options)

resolve(query, options?): Promise<ChainResolution>

Resolve a chain from a query

This is the main way to get a pulse or chain from somewhere and have it automatically verified.

If the input is already a successful resolution, it will be returned as is.

If the input is a chain or pulse, it will be resolved as a chain or pulse resolution.

Parameters

Parameter
Type
Description

query

IntoResolveChainQuery

The query to resolve

options?

ResolveOptions

Options for the resolution

Returns

Promise<ChainResolution>

A chain or pulse resolution

Examples

Implementation of

Store.resolve

Defined in

index.ts:327arrow-up-right

resolve(query, options)

resolve(query, options?): Promise<PulseResolution>

Resolve a pulse (with its chain) from a query

Parameters

Parameter
Type

query

IntoResolvePulseQuery

options?

ResolveOptions

Returns

Promise<PulseResolution>

Implementation of

Store.resolve

Defined in

index.ts:328arrow-up-right


resolveLatest()

resolveLatest(chain, options?): Promise<PulseResolution>

Resolve the latest pulse of a chain

Parameters

Parameter
Type
Description

chain

IntoCid

The chain CID or chain itself to resolve the latest pulse from

options?

ResolveOptions

Options for the resolution

Returns

Promise<PulseResolution>

A pulse resolution

Examples

Implementation of

Store.resolveLatest

Defined in

index.ts:342arrow-up-right


saveMany()

saveMany(twines): Promise<void>

Save many twines to storage

Parameters

Parameter
Type
Description

twines

AnyIterable<Twine<TwineValue>>

The twines to save

Returns

Promise<void>

Implementation of

Store.saveMany

Defined in

index.ts:353arrow-up-right


save()

save(twine): Promise<void>

Save a twine to storage

Parameters

Parameter
Type
Description

twine

Twine<TwineValue>

The twine to save

Returns

Promise<void>

Implementation of

Store.save

Defined in

index.ts:394arrow-up-right

Last updated