BlockstoreStore

@twine-protocol/twine-blockstore-store v0.0.3Docs


twine-js / @twine-protocol/twine-blockstore-store / BlockstoreStore

Class: BlockstoreStore

Storage wrapper for storing Twine objects inside datastore and a blockstore

Implements

  • Store

Constructors

new BlockstoreStore()

new BlockstoreStore(datastore, blockstore): BlockstoreStore

Create a new BlockstoreStore

Parameters

Parameter
Type
Description

datastore

Datastore<object, object, object, object, object, object, object, object, object, object>

The datastore to use

blockstore

Blockstore<object, object, object, object, object, object, object, object>

The blockstore to use

Returns

BlockstoreStore

Defined in

index.ts:25

Methods

_cidOf()

_cidOf(chain, index): Promise<null | CID<unknown, number, number, Version>>

Get cid of pulse with specified index

Parameters

Parameter
Type
Description

chain

IntoCid

The chain CID

index

number

The index

Returns

Promise<null | CID<unknown, number, number, Version>>

The CID of the pulse, or null if not found

Defined in

index.ts:88


reIndex()

reIndex(latestCid): Promise<void>

Reindex a chain

Parameters

Parameter
Type
Description

latestCid

IntoCid

The CID of the latest pulse

Returns

Promise<void>

Defined in

index.ts:107


fetchIndex()

fetchIndex(chain, index): Promise<null | Chain | Pulse>

fetch by index

Parameters

Parameter
Type
Description

chain

IntoCid

The chain CID

index

number

The index

Returns

Promise<null | Chain | Pulse>

Defined in

index.ts:137


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:145


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:164


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:170


fetch()

fetch(cid): Promise<null | Chain | Pulse>

Fetch a twine by it's CID

Parameters

Parameter
Type

cid

IntoCid

Returns

Promise<null | Chain | Pulse>

Implementation of

Store.fetch

Defined in

index.ts:204


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

const chains = await collect(resolver.chains())

Implementation of

Store.chains

Defined in

index.ts:221


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

// loop through pulses and print indices
for await (const pulse of resolver.pulses('bafybeib3...')) {
  console.log('pulse', pulse.value.content.index)
}

Implementation of

Store.pulses

Defined in

index.ts:231


has()

has(cid): Promise<boolean>

Check if a Twine is present in the blockstore

Parameters

Parameter
Type

cid

IntoCid

Returns

Promise<boolean>

Implementation of

Store.has

Defined in

index.ts:256


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

const resolution = await resolver.resolveIndex('bafybeib3...', 42)
if (resolution.pulse) {
  console.log('pulse', resolution.pulse)
}

Implementation of

Store.resolveIndex

Defined in

index.ts:267


resolve()

resolve(query, options)

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

Resolves a twine query

Parameters

Parameter
Type

query

IntoResolvePulseQuery

options?

ResolveOptions

Returns

Promise<PulseResolution>

Implementation of

Store.resolve

Defined in

index.ts:276

resolve(query, options)

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

Resolve a pulse (with its chain) from a query

Parameters

Parameter
Type

query

IntoResolveChainQuery

options?

ResolveOptions

Returns

Promise<ChainResolution>

Implementation of

Store.resolve

Defined in

index.ts:277


resolveLatest()

resolveLatest(chain): Promise<PulseResolution>

Resolves the latest pulse for specified chain

Parameters

Parameter
Type

chain

IntoCid

Returns

Promise<PulseResolution>

Implementation of

Store.resolveLatest

Defined in

index.ts:288

Last updated