@helia/interface 2.0.0-fdda692 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -9
- package/dist/src/blocks.d.ts +28 -5
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/typedoc-urls.json +54 -0
- package/package.json +1 -1
- package/src/blocks.ts +32 -5
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
# @helia/interface <!-- omit in toc -->
|
|
8
|
-
|
|
9
7
|
[](https://ipfs.tech)
|
|
10
8
|
[](https://discuss.ipfs.tech)
|
|
11
9
|
[](https://codecov.io/gh/ipfs/helia)
|
|
@@ -13,13 +11,6 @@
|
|
|
13
11
|
|
|
14
12
|
> The Helia API
|
|
15
13
|
|
|
16
|
-
## Table of contents <!-- omit in toc -->
|
|
17
|
-
|
|
18
|
-
- [Install](#install)
|
|
19
|
-
- [API Docs](#api-docs)
|
|
20
|
-
- [License](#license)
|
|
21
|
-
- [Contribute](#contribute)
|
|
22
|
-
|
|
23
14
|
## Install
|
|
24
15
|
|
|
25
16
|
```console
|
package/dist/src/blocks.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Blockstore } from 'interface-blockstore';
|
|
2
|
+
import type { AbortOptions } from 'interface-store';
|
|
2
3
|
import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap';
|
|
3
4
|
import type { CID } from 'multiformats/cid';
|
|
4
5
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
@@ -6,11 +7,11 @@ export interface Pair {
|
|
|
6
7
|
cid: CID;
|
|
7
8
|
block: Uint8Array;
|
|
8
9
|
}
|
|
9
|
-
export type HasBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:
|
|
10
|
-
export type PutBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:
|
|
11
|
-
export type PutManyBlocksProgressEvents = ProgressEvent<'blocks:put-many:duplicate', CID> | ProgressEvent<'blocks:put-many:
|
|
12
|
-
export type GetBlockProgressEvents = ProgressEvent<'blocks:get:
|
|
13
|
-
export type GetManyBlocksProgressEvents = ProgressEvent<'blocks:get-many:blockstore:get-many'> | ProgressEvent<'blocks:get-many:
|
|
10
|
+
export type HasBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:providers:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID> | BitswapNotifyProgressEvents;
|
|
11
|
+
export type PutBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:providers:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID> | BitswapNotifyProgressEvents;
|
|
12
|
+
export type PutManyBlocksProgressEvents = ProgressEvent<'blocks:put-many:duplicate', CID> | ProgressEvent<'blocks:put-many:providers:notify', CID> | ProgressEvent<'blocks:put-many:blockstore:put-many'> | BitswapNotifyProgressEvents;
|
|
13
|
+
export type GetBlockProgressEvents = ProgressEvent<'blocks:get:providers:want', CID> | ProgressEvent<'blocks:get:blockstore:get', CID> | ProgressEvent<'blocks:get:blockstore:put', CID> | BitswapWantProgressEvents;
|
|
14
|
+
export type GetManyBlocksProgressEvents = ProgressEvent<'blocks:get-many:blockstore:get-many'> | ProgressEvent<'blocks:get-many:providers:want', CID> | ProgressEvent<'blocks:get-many:blockstore:put', CID> | BitswapWantProgressEvents;
|
|
14
15
|
export type GetAllBlocksProgressEvents = ProgressEvent<'blocks:get-all:blockstore:get-many'>;
|
|
15
16
|
export type DeleteBlockProgressEvents = ProgressEvent<'blocks:delete:blockstore:delete', CID>;
|
|
16
17
|
export type DeleteManyBlocksProgressEvents = ProgressEvent<'blocks:delete-many:blockstore:delete-many'>;
|
|
@@ -22,4 +23,26 @@ export interface GetOfflineOptions {
|
|
|
22
23
|
}
|
|
23
24
|
export interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>, ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>, GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>, ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>> {
|
|
24
25
|
}
|
|
26
|
+
export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = ProgressOptions> = AbortOptions & GetProgressOptions & {
|
|
27
|
+
/**
|
|
28
|
+
* A function that blockBrokers should call prior to returning a block to ensure it can maintain control
|
|
29
|
+
* of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
|
|
30
|
+
* is valid from one of the gateways before assuming it's work is done. If the block is not valid, it should try another gateway
|
|
31
|
+
* and WILL consider the gateway that returned the invalid blocks completely unreliable.
|
|
32
|
+
*/
|
|
33
|
+
validateFn?(block: Uint8Array): Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
export interface BlockRetriever<GetProgressOptions extends ProgressOptions = ProgressOptions> {
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve a block from a source
|
|
38
|
+
*/
|
|
39
|
+
retrieve(cid: CID, options?: BlockRetrievalOptions<GetProgressOptions>): Promise<Uint8Array>;
|
|
40
|
+
}
|
|
41
|
+
export interface BlockAnnouncer<NotifyProgressOptions extends ProgressOptions = ProgressOptions> {
|
|
42
|
+
/**
|
|
43
|
+
* Make a new block available to peers
|
|
44
|
+
*/
|
|
45
|
+
announce(cid: CID, block: Uint8Array, options?: NotifyProgressOptions): void;
|
|
46
|
+
}
|
|
47
|
+
export type BlockBroker = BlockRetriever | BlockAnnouncer;
|
|
25
48
|
//# sourceMappingURL=blocks.d.ts.map
|
package/dist/src/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,sBAAsB,EAAE,GAAG,CAAC,GAC1C,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,sBAAsB,EAAE,GAAG,CAAC,GAC1C,aAAa,CAAC,6BAA6B,EAAE,GAAG,CAAC,GACjD,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,2BAA2B,CAAA;AAE7B,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,sBAAsB,EAAE,GAAG,CAAC,GAC1C,aAAa,CAAC,6BAA6B,EAAE,GAAG,CAAC,GACjD,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,2BAA2B,CAAA;AAE7B,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,kCAAkC,EAAE,GAAG,CAAC,GACtD,aAAa,CAAC,qCAAqC,CAAC,GACpD,2BAA2B,CAAA;AAE7B,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,yBAAyB,CAAA;AAE3B,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,qCAAqC,CAAC,GACpD,aAAa,CAAC,gCAAgC,EAAE,GAAG,CAAC,GACpD,aAAa,CAAC,gCAAgC,EAAE,GAAG,CAAC,GACpD,yBAAyB,CAAA;AAE3B,MAAM,MAAM,0BAA0B,GACpC,aAAa,CAAC,oCAAoC,CAAC,CAAA;AAErD,MAAM,MAAM,yBAAyB,GACnC,aAAa,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAA;AAEvD,MAAM,MAAM,8BAA8B,GACxC,aAAa,CAAC,2CAA2C,CAAC,CAAA;AAE5D,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,MAAO,SAAQ,UAAU,CAAC,eAAe,CAAC,sBAAsB,CAAC,EAClF,eAAe,CAAC,sBAAsB,CAAC,EAAE,eAAe,CAAC,2BAA2B,CAAC,EACrF,iBAAiB,GAAG,eAAe,CAAC,sBAAsB,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,2BAA2B,CAAC,EAAE,eAAe,CAAC,0BAA0B,CAAC,EAC1K,eAAe,CAAC,yBAAyB,CAAC,EAAE,eAAe,CAAC,8BAA8B,CAAC,CAC1F;CAEA;AAED,MAAM,MAAM,qBAAqB,CAAC,kBAAkB,SAAS,eAAe,GAAG,eAAe,IAAI,YAAY,GAAG,kBAAkB,GAAG;IACpI;;;;;OAKG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9C,CAAA;AAED,MAAM,WAAW,cAAc,CAAC,kBAAkB,SAAS,eAAe,GAAG,eAAe;IAC1F;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7F;AAED,MAAM,WAAW,cAAc,CAAC,qBAAqB,SAAS,eAAe,GAAG,eAAe;IAC7F;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAA;CAC7E;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,cAAc,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AddOptions": "https://ipfs.github.io/helia/interfaces/helia.index.AddOptions.html",
|
|
3
|
+
"./pins:AddOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.AddOptions.html",
|
|
4
|
+
"BlockAnnouncer": "https://ipfs.github.io/helia/interfaces/helia.index.BlockAnnouncer.html",
|
|
5
|
+
"./blocks:BlockAnnouncer": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockAnnouncer.html",
|
|
6
|
+
"BlockRetriever": "https://ipfs.github.io/helia/interfaces/helia.index.BlockRetriever.html",
|
|
7
|
+
"./blocks:BlockRetriever": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockRetriever.html",
|
|
8
|
+
"Blocks": "https://ipfs.github.io/helia/interfaces/helia.index.Blocks.html",
|
|
9
|
+
"./blocks:Blocks": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Blocks.html",
|
|
10
|
+
"GCOptions": "https://ipfs.github.io/helia/interfaces/helia.index.GCOptions.html",
|
|
11
|
+
".:GCOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.GCOptions.html",
|
|
12
|
+
"GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/helia.index.GetOfflineOptions.html",
|
|
13
|
+
"./blocks:GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.GetOfflineOptions.html",
|
|
14
|
+
"Helia": "https://ipfs.github.io/helia/interfaces/helia.index.Helia.html",
|
|
15
|
+
".:Helia": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.Helia.html",
|
|
16
|
+
"IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/helia.index.IsPinnedOptions.html",
|
|
17
|
+
"./pins:IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.IsPinnedOptions.html",
|
|
18
|
+
"LsOptions": "https://ipfs.github.io/helia/interfaces/helia.index.LsOptions.html",
|
|
19
|
+
"./pins:LsOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.LsOptions.html",
|
|
20
|
+
"Pair": "https://ipfs.github.io/helia/interfaces/helia.index.Pair.html",
|
|
21
|
+
"./blocks:Pair": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Pair.html",
|
|
22
|
+
"Pin": "https://ipfs.github.io/helia/interfaces/helia.index.Pin.html",
|
|
23
|
+
"./pins:Pin": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pin.html",
|
|
24
|
+
"Pins": "https://ipfs.github.io/helia/interfaces/helia.index.Pins.html",
|
|
25
|
+
"./pins:Pins": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pins.html",
|
|
26
|
+
"RmOptions": "https://ipfs.github.io/helia/interfaces/helia.index.RmOptions.html",
|
|
27
|
+
"./pins:RmOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.RmOptions.html",
|
|
28
|
+
"AddPinEvents": "https://ipfs.github.io/helia/types/helia.index.AddPinEvents.html",
|
|
29
|
+
"./pins:AddPinEvents": "https://ipfs.github.io/helia/types/_helia_interface.pins.AddPinEvents.html",
|
|
30
|
+
"BlockBroker": "https://ipfs.github.io/helia/types/helia.index.BlockBroker.html",
|
|
31
|
+
"./blocks:BlockBroker": "https://ipfs.github.io/helia/types/_helia_interface.blocks.BlockBroker.html",
|
|
32
|
+
"BlockRetrievalOptions": "https://ipfs.github.io/helia/types/helia.index.BlockRetrievalOptions.html",
|
|
33
|
+
"./blocks:BlockRetrievalOptions": "https://ipfs.github.io/helia/types/_helia_interface.blocks.BlockRetrievalOptions.html",
|
|
34
|
+
"DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.index.DeleteBlockProgressEvents.html",
|
|
35
|
+
"./blocks:DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteBlockProgressEvents.html",
|
|
36
|
+
"DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.index.DeleteManyBlocksProgressEvents.html",
|
|
37
|
+
"./blocks:DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteManyBlocksProgressEvents.html",
|
|
38
|
+
"GcEvents": "https://ipfs.github.io/helia/types/helia.index.GcEvents.html",
|
|
39
|
+
".:GcEvents": "https://ipfs.github.io/helia/types/_helia_interface.index.GcEvents.html",
|
|
40
|
+
"GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.index.GetAllBlocksProgressEvents.html",
|
|
41
|
+
"./blocks:GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetAllBlocksProgressEvents.html",
|
|
42
|
+
"GetBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.index.GetBlockProgressEvents.html",
|
|
43
|
+
"./blocks:GetBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetBlockProgressEvents.html",
|
|
44
|
+
"GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.index.GetManyBlocksProgressEvents.html",
|
|
45
|
+
"./blocks:GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetManyBlocksProgressEvents.html",
|
|
46
|
+
"HasBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.index.HasBlockProgressEvents.html",
|
|
47
|
+
"./blocks:HasBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.HasBlockProgressEvents.html",
|
|
48
|
+
"PinType": "https://ipfs.github.io/helia/types/helia.index.PinType.html",
|
|
49
|
+
"./pins:PinType": "https://ipfs.github.io/helia/types/_helia_interface.pins.PinType.html",
|
|
50
|
+
"PutBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.index.PutBlockProgressEvents.html",
|
|
51
|
+
"./blocks:PutBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutBlockProgressEvents.html",
|
|
52
|
+
"PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.index.PutManyBlocksProgressEvents.html",
|
|
53
|
+
"./blocks:PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutManyBlocksProgressEvents.html"
|
|
54
|
+
}
|
package/package.json
CHANGED
package/src/blocks.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Blockstore } from 'interface-blockstore'
|
|
2
|
+
import type { AbortOptions } from 'interface-store'
|
|
2
3
|
import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap'
|
|
3
4
|
import type { CID } from 'multiformats/cid'
|
|
4
5
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
@@ -10,31 +11,31 @@ export interface Pair {
|
|
|
10
11
|
|
|
11
12
|
export type HasBlockProgressEvents =
|
|
12
13
|
ProgressEvent<'blocks:put:duplicate', CID> |
|
|
13
|
-
ProgressEvent<'blocks:put:
|
|
14
|
+
ProgressEvent<'blocks:put:providers:notify', CID> |
|
|
14
15
|
ProgressEvent<'blocks:put:blockstore:put', CID> |
|
|
15
16
|
BitswapNotifyProgressEvents
|
|
16
17
|
|
|
17
18
|
export type PutBlockProgressEvents =
|
|
18
19
|
ProgressEvent<'blocks:put:duplicate', CID> |
|
|
19
|
-
ProgressEvent<'blocks:put:
|
|
20
|
+
ProgressEvent<'blocks:put:providers:notify', CID> |
|
|
20
21
|
ProgressEvent<'blocks:put:blockstore:put', CID> |
|
|
21
22
|
BitswapNotifyProgressEvents
|
|
22
23
|
|
|
23
24
|
export type PutManyBlocksProgressEvents =
|
|
24
25
|
ProgressEvent<'blocks:put-many:duplicate', CID> |
|
|
25
|
-
ProgressEvent<'blocks:put-many:
|
|
26
|
+
ProgressEvent<'blocks:put-many:providers:notify', CID> |
|
|
26
27
|
ProgressEvent<'blocks:put-many:blockstore:put-many'> |
|
|
27
28
|
BitswapNotifyProgressEvents
|
|
28
29
|
|
|
29
30
|
export type GetBlockProgressEvents =
|
|
30
|
-
ProgressEvent<'blocks:get:
|
|
31
|
+
ProgressEvent<'blocks:get:providers:want', CID> |
|
|
31
32
|
ProgressEvent<'blocks:get:blockstore:get', CID> |
|
|
32
33
|
ProgressEvent<'blocks:get:blockstore:put', CID> |
|
|
33
34
|
BitswapWantProgressEvents
|
|
34
35
|
|
|
35
36
|
export type GetManyBlocksProgressEvents =
|
|
36
37
|
ProgressEvent<'blocks:get-many:blockstore:get-many'> |
|
|
37
|
-
ProgressEvent<'blocks:get-many:
|
|
38
|
+
ProgressEvent<'blocks:get-many:providers:want', CID> |
|
|
38
39
|
ProgressEvent<'blocks:get-many:blockstore:put', CID> |
|
|
39
40
|
BitswapWantProgressEvents
|
|
40
41
|
|
|
@@ -61,3 +62,29 @@ ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProg
|
|
|
61
62
|
> {
|
|
62
63
|
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = ProgressOptions> = AbortOptions & GetProgressOptions & {
|
|
67
|
+
/**
|
|
68
|
+
* A function that blockBrokers should call prior to returning a block to ensure it can maintain control
|
|
69
|
+
* of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
|
|
70
|
+
* is valid from one of the gateways before assuming it's work is done. If the block is not valid, it should try another gateway
|
|
71
|
+
* and WILL consider the gateway that returned the invalid blocks completely unreliable.
|
|
72
|
+
*/
|
|
73
|
+
validateFn?(block: Uint8Array): Promise<void>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface BlockRetriever<GetProgressOptions extends ProgressOptions = ProgressOptions> {
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve a block from a source
|
|
79
|
+
*/
|
|
80
|
+
retrieve(cid: CID, options?: BlockRetrievalOptions<GetProgressOptions>): Promise<Uint8Array>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface BlockAnnouncer<NotifyProgressOptions extends ProgressOptions = ProgressOptions> {
|
|
84
|
+
/**
|
|
85
|
+
* Make a new block available to peers
|
|
86
|
+
*/
|
|
87
|
+
announce(cid: CID, block: Uint8Array, options?: NotifyProgressOptions): void
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type BlockBroker = BlockRetriever | BlockAnnouncer
|