HttpStore
@twine-protocol/twine-http-store v0.1.0 • Docs
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
baseUrl
string
The base URL of the store
Returns
Defined in
Methods
fetchChain()
fetchChain(
chainCid
):Promise
<null
|Chain
>
Fetch a chain by CID without validation
Parameters
chainCid
IntoCid
Returns
Promise
<null
| Chain
>
Defined in
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
pulses()
pulses(
chain
,start
?,options
?):AsyncIterable
<Pulse
,any
,any
>
Get the pulses of a chain
Parameters
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
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
cid
IntoCid
The CID of the twine to fetch
Returns
Promise
<null
| Twine
<TwineValue
>>
Implementation of
Store.fetch
Defined in
has()
has(
cid
):Promise
<boolean
>
Check if a cid can be resolved
Parameters
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
delete()
delete(
cid
):Promise
<void
>
Delete a twine from storage
Parameters
cid
IntoCid
The CID of the twine to delete
Returns
Promise
<void
>
Implementation of
Store.delete
Defined in
resolveIndex()
resolveIndex(
chain
,index
,options
?):Promise
<PulseResolution
>
Resolve a pulse by index
Parameters
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
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
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
resolve(query, options)
resolve(
query
,options
?):Promise
<PulseResolution
>
Resolve a pulse (with its chain) from a query
Parameters
query
IntoResolvePulseQuery
options
?
ResolveOptions
Returns
Promise
<PulseResolution
>
Implementation of
Store.resolve
Defined in
resolveLatest()
resolveLatest(
chain
,options
?):Promise
<PulseResolution
>
Resolve the latest pulse of a chain
Parameters
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
saveMany()
saveMany(
twines
):Promise
<void
>
Save many twines to storage
Parameters
twines
AnyIterable
<Twine
<TwineValue
>>
The twines to save
Returns
Promise
<void
>
Implementation of
Store.saveMany
Defined in
save()
save(
twine
):Promise
<void
>
Save a twine to storage
Parameters
twine
Twine
<TwineValue
>
The twine to save
Returns
Promise
<void
>
Implementation of
Store.save
Defined in
Last updated