@helia/utils 2.4.2-2d30414a → 2.4.2-397f2d86
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/abstract-session.d.ts +1 -1
- package/dist/src/abstract-session.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +8 -8
- package/dist/src/routing.d.ts +10 -9
- package/dist/src/routing.d.ts.map +1 -1
- package/dist/src/routing.js +79 -1
- package/dist/src/routing.js.map +1 -1
- package/dist/src/storage.js +1 -1
- package/dist/src/utils/datastore-version.js +1 -1
- package/dist/src/utils/get-codec.js +1 -1
- package/dist/src/utils/get-hasher.js +1 -1
- package/dist/src/utils/storage.js +1 -1
- package/package.json +5 -5
- package/src/abstract-session.ts +1 -1
- package/src/index.ts +10 -10
- package/src/routing.ts +100 -11
- package/src/storage.ts +1 -1
- package/src/utils/datastore-version.ts +1 -1
- package/src/utils/get-codec.ts +1 -1
- package/src/utils/get-hasher.ts +1 -1
- package/src/utils/storage.ts +1 -1
|
@@ -42,7 +42,7 @@ export declare abstract class AbstractSession<Provider, RetrieveBlockProgressEve
|
|
|
42
42
|
/**
|
|
43
43
|
* This method should search for new providers and yield them.
|
|
44
44
|
*/
|
|
45
|
-
abstract findNewProviders(cid: CID, options:
|
|
45
|
+
abstract findNewProviders(cid: CID, options: BlockRetrievalOptions<RetrieveBlockProgressEvents>): AsyncGenerator<Provider>;
|
|
46
46
|
/**
|
|
47
47
|
* The subclass should contact the provider and request the block from it.
|
|
48
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-session.d.ts","sourceRoot":"","sources":["../../src/abstract-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,iBAAiB,EAAmB,MAAM,mBAAmB,CAAA;AAKlF,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAA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E,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YAe/E,aAAa;IAwG3B;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAE/I;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,qBAAqB,CAAC,2BAA2B,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC;IAE3H;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IAEjG;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM;IAE9D;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,OAAO;IAEnE;;OAEG;IACH,QAAQ,CAAC,8BAA8B,CAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,CAAC,2BAA2B,CAAC,GAAG,IAAI;CAC1I"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* modules such as `helia`, `@helia/http`, etc.
|
|
6
6
|
*/
|
|
7
7
|
import { TypedEventEmitter } from '@libp2p/interface';
|
|
8
|
-
import { BlockStorage } from './storage.
|
|
9
|
-
import type { BlockStorageInit } from './storage.
|
|
8
|
+
import { BlockStorage } from './storage.ts';
|
|
9
|
+
import type { BlockStorageInit } from './storage.ts';
|
|
10
10
|
import type { Await, CodecLoader, GCOptions, HasherLoader, Helia as HeliaInterface, HeliaEvents, Routing } from '@helia/interface';
|
|
11
11
|
import type { BlockBroker } from '@helia/interface/blocks';
|
|
12
12
|
import type { Pins } from '@helia/interface/pins';
|
|
@@ -18,8 +18,8 @@ import type { Datastore } from 'interface-datastore';
|
|
|
18
18
|
import type { Libp2pOptions } from 'libp2p';
|
|
19
19
|
import type { BlockCodec } from 'multiformats';
|
|
20
20
|
import type { MultihashHasher } from 'multiformats/hashes/interface';
|
|
21
|
-
export { AbstractSession } from './abstract-session.
|
|
22
|
-
export type { AbstractCreateSessionOptions, BlockstoreSessionEvents, AbstractSessionComponents } from './abstract-session.
|
|
21
|
+
export { AbstractSession } from './abstract-session.ts';
|
|
22
|
+
export type { AbstractCreateSessionOptions, BlockstoreSessionEvents, AbstractSessionComponents } from './abstract-session.ts';
|
|
23
23
|
export type { BlockStorage, BlockStorageInit };
|
|
24
24
|
export { breadthFirstWalker, depthFirstWalker, naturalOrderWalker } from './graph-walker.ts';
|
|
25
25
|
export type { GraphWalkerComponents, GraphWalkerInit, GraphNode, GraphWalker } from './graph-walker.ts';
|
package/dist/src/index.js
CHANGED
|
@@ -8,14 +8,14 @@ import { contentRoutingSymbol, peerRoutingSymbol, start, stop, TypedEventEmitter
|
|
|
8
8
|
import { dns } from '@multiformats/dns';
|
|
9
9
|
import drain from 'it-drain';
|
|
10
10
|
import { CustomProgressEvent } from 'progress-events';
|
|
11
|
-
import { PinsImpl } from
|
|
12
|
-
import { Routing as RoutingClass } from
|
|
13
|
-
import { BlockStorage } from
|
|
14
|
-
import { assertDatastoreVersionIsCurrent } from
|
|
15
|
-
import { getCodec } from
|
|
16
|
-
import { getHasher } from
|
|
17
|
-
import { NetworkedStorage } from
|
|
18
|
-
export { AbstractSession } from
|
|
11
|
+
import { PinsImpl } from "./pins.js";
|
|
12
|
+
import { Routing as RoutingClass } from "./routing.js";
|
|
13
|
+
import { BlockStorage } from "./storage.js";
|
|
14
|
+
import { assertDatastoreVersionIsCurrent } from "./utils/datastore-version.js";
|
|
15
|
+
import { getCodec } from "./utils/get-codec.js";
|
|
16
|
+
import { getHasher } from "./utils/get-hasher.js";
|
|
17
|
+
import { NetworkedStorage } from "./utils/networked-storage.js";
|
|
18
|
+
export { AbstractSession } from "./abstract-session.js";
|
|
19
19
|
export { breadthFirstWalker, depthFirstWalker, naturalOrderWalker } from "./graph-walker.js";
|
|
20
20
|
export class Helia {
|
|
21
21
|
libp2p;
|
package/dist/src/routing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Routing as RoutingInterface, Provider, RoutingOptions } from '@helia/interface';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Routing as RoutingInterface, Provider, RoutingOptions, RoutingFindProvidersProgressEvents, RoutingProvideProgressEvents, RoutingPutProgressEvents, RoutingGetProgressEvents, RoutingFindPeerProgressEvents, RoutingGetClosestPeersProgressEvents, RoutingCancelReprovideProgressEvents } from '@helia/interface';
|
|
2
|
+
import type { ComponentLogger, Metrics, PeerId, PeerInfo, Startable } from '@libp2p/interface';
|
|
3
3
|
import type { CID } from 'multiformats/cid';
|
|
4
4
|
export interface RoutingInit {
|
|
5
5
|
routers: Array<Partial<RoutingInterface>>;
|
|
@@ -10,6 +10,7 @@ export interface RoutingComponents {
|
|
|
10
10
|
metrics?: Metrics;
|
|
11
11
|
}
|
|
12
12
|
export declare class Routing implements RoutingInterface, Startable {
|
|
13
|
+
name: string;
|
|
13
14
|
private readonly log;
|
|
14
15
|
private readonly routers;
|
|
15
16
|
private readonly providerLookupConcurrency;
|
|
@@ -20,29 +21,29 @@ export declare class Routing implements RoutingInterface, Startable {
|
|
|
20
21
|
* Iterates over all content routers in parallel to find providers of the
|
|
21
22
|
* given key
|
|
22
23
|
*/
|
|
23
|
-
findProviders(key: CID, options?: RoutingOptions): AsyncIterable<Provider>;
|
|
24
|
+
findProviders(key: CID, options?: RoutingOptions<RoutingFindProvidersProgressEvents>): AsyncIterable<Provider>;
|
|
24
25
|
/**
|
|
25
26
|
* Iterates over all content routers in parallel to notify it is
|
|
26
27
|
* a provider of the given key
|
|
27
28
|
*/
|
|
28
|
-
provide(key: CID, options?:
|
|
29
|
-
cancelReprovide(key: CID, options?:
|
|
29
|
+
provide(key: CID, options?: RoutingOptions<RoutingProvideProgressEvents>): Promise<void>;
|
|
30
|
+
cancelReprovide(key: CID, options?: RoutingOptions<RoutingCancelReprovideProgressEvents>): Promise<void>;
|
|
30
31
|
/**
|
|
31
32
|
* Store the given key/value pair in the available content routings
|
|
32
33
|
*/
|
|
33
|
-
put(key: Uint8Array, value: Uint8Array, options?:
|
|
34
|
+
put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions<RoutingPutProgressEvents>): Promise<void>;
|
|
34
35
|
/**
|
|
35
36
|
* Get the value to the given key. The first value offered by any configured
|
|
36
37
|
* router will be returned.
|
|
37
38
|
*/
|
|
38
|
-
get(key: Uint8Array, options?:
|
|
39
|
+
get(key: Uint8Array, options?: RoutingOptions<RoutingGetProgressEvents>): Promise<Uint8Array>;
|
|
39
40
|
/**
|
|
40
41
|
* Iterates over all peer routers in parallel to find the given peer
|
|
41
42
|
*/
|
|
42
|
-
findPeer(id: PeerId, options?: RoutingOptions): Promise<PeerInfo>;
|
|
43
|
+
findPeer(id: PeerId, options?: RoutingOptions<RoutingFindPeerProgressEvents>): Promise<PeerInfo>;
|
|
43
44
|
/**
|
|
44
45
|
* Attempt to find the closest peers on the network to the given key
|
|
45
46
|
*/
|
|
46
|
-
getClosestPeers(key: Uint8Array, options?: RoutingOptions): AsyncIterable<PeerInfo>;
|
|
47
|
+
getClosestPeers(key: Uint8Array, options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>): AsyncIterable<PeerInfo>;
|
|
47
48
|
}
|
|
48
49
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["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G,EAAE,OAAO,GAAE,cAAc,CAAC,4BAA4B,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB7F,eAAe,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,cAAc,CAAC,oCAAoC,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBnH;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBjH;;;OAGG;IACG,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAqCpG;;OAEG;IACG,QAAQ,CAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsCvG;;OAEG;IACK,eAAe,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,cAAc,CAAC,oCAAoC,CAAM,GAAG,aAAa,CAAC,QAAQ,CAAC;CA8BvI"}
|
package/dist/src/routing.js
CHANGED
|
@@ -2,14 +2,17 @@ import { NoRoutersAvailableError } from '@helia/interface';
|
|
|
2
2
|
import { NotFoundError, start, stop } from '@libp2p/interface';
|
|
3
3
|
import { PeerQueue } from '@libp2p/utils';
|
|
4
4
|
import merge from 'it-merge';
|
|
5
|
+
import { CustomProgressEvent } from 'progress-events';
|
|
5
6
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
6
7
|
import { GetFailedError } from "./errors.js";
|
|
7
8
|
const DEFAULT_PROVIDER_LOOKUP_CONCURRENCY = 5;
|
|
8
9
|
export class Routing {
|
|
10
|
+
name;
|
|
9
11
|
log;
|
|
10
12
|
routers;
|
|
11
13
|
providerLookupConcurrency;
|
|
12
14
|
constructor(components, init) {
|
|
15
|
+
this.name = 'helia';
|
|
13
16
|
this.log = components.logger.forComponent('helia:routing');
|
|
14
17
|
this.routers = init.routers ?? [];
|
|
15
18
|
this.providerLookupConcurrency = init.providerLookupConcurrency ?? DEFAULT_PROVIDER_LOOKUP_CONCURRENCY;
|
|
@@ -64,9 +67,19 @@ export class Routing {
|
|
|
64
67
|
const routers = supports(this.routers, 'findProviders')
|
|
65
68
|
.map(async function* (router) {
|
|
66
69
|
let foundProviders = 0;
|
|
70
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:find-providers:start', {
|
|
71
|
+
routing: router.name,
|
|
72
|
+
cid: key
|
|
73
|
+
}));
|
|
67
74
|
try {
|
|
68
75
|
for await (const prov of router.findProviders(key, options)) {
|
|
69
76
|
foundProviders++;
|
|
77
|
+
// @ts-expect-error router.name is a string, needs to be specific
|
|
78
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:find-providers:provider', {
|
|
79
|
+
routing: router.name,
|
|
80
|
+
cid: key,
|
|
81
|
+
provider: prov
|
|
82
|
+
}));
|
|
70
83
|
yield prov;
|
|
71
84
|
}
|
|
72
85
|
}
|
|
@@ -75,6 +88,11 @@ export class Routing {
|
|
|
75
88
|
}
|
|
76
89
|
finally {
|
|
77
90
|
self.log('router %s found %d providers for %c', router, foundProviders, key);
|
|
91
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:find-providers:end', {
|
|
92
|
+
routing: router.name,
|
|
93
|
+
cid: key,
|
|
94
|
+
found: foundProviders
|
|
95
|
+
}));
|
|
78
96
|
routersFinished++;
|
|
79
97
|
// if all routers have finished and there are no jobs to find updated
|
|
80
98
|
// peer multiaddres running or queued, cause the generator to exit
|
|
@@ -135,13 +153,29 @@ export class Routing {
|
|
|
135
153
|
}
|
|
136
154
|
await Promise.all(supports(this.routers, 'provide')
|
|
137
155
|
.map(async (router) => {
|
|
156
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:provide:start', {
|
|
157
|
+
routing: router.name,
|
|
158
|
+
cid: key
|
|
159
|
+
}));
|
|
138
160
|
await router.provide(key, options);
|
|
161
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:provide:end', {
|
|
162
|
+
routing: router.name,
|
|
163
|
+
cid: key
|
|
164
|
+
}));
|
|
139
165
|
}));
|
|
140
166
|
}
|
|
141
167
|
async cancelReprovide(key, options = {}) {
|
|
142
168
|
await Promise.all(supports(this.routers, 'cancelReprovide')
|
|
143
169
|
.map(async (router) => {
|
|
170
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:cancel-reprovide:start', {
|
|
171
|
+
routing: router.name,
|
|
172
|
+
cid: key
|
|
173
|
+
}));
|
|
144
174
|
await router.cancelReprovide(key, options);
|
|
175
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:cancel-reprovide:end', {
|
|
176
|
+
routing: router.name,
|
|
177
|
+
cid: key
|
|
178
|
+
}));
|
|
145
179
|
}));
|
|
146
180
|
}
|
|
147
181
|
/**
|
|
@@ -150,7 +184,17 @@ export class Routing {
|
|
|
150
184
|
async put(key, value, options) {
|
|
151
185
|
await Promise.all(supports(this.routers, 'put')
|
|
152
186
|
.map(async (router) => {
|
|
187
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:put:start', {
|
|
188
|
+
routing: router.name,
|
|
189
|
+
key,
|
|
190
|
+
value
|
|
191
|
+
}));
|
|
153
192
|
await router.put(key, value, options);
|
|
193
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:put:end', {
|
|
194
|
+
routing: router.name,
|
|
195
|
+
key,
|
|
196
|
+
value
|
|
197
|
+
}));
|
|
154
198
|
}));
|
|
155
199
|
}
|
|
156
200
|
/**
|
|
@@ -163,6 +207,10 @@ export class Routing {
|
|
|
163
207
|
try {
|
|
164
208
|
result = await Promise.any(supports(this.routers, 'get')
|
|
165
209
|
.map(async (router) => {
|
|
210
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:get:start', {
|
|
211
|
+
routing: router.name,
|
|
212
|
+
key
|
|
213
|
+
}));
|
|
166
214
|
try {
|
|
167
215
|
return await router.get(key, options);
|
|
168
216
|
}
|
|
@@ -170,6 +218,12 @@ export class Routing {
|
|
|
170
218
|
this.log('router %s failed with %e', router, err);
|
|
171
219
|
errors.push(err);
|
|
172
220
|
}
|
|
221
|
+
finally {
|
|
222
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:get:end', {
|
|
223
|
+
routing: router.name,
|
|
224
|
+
key
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
173
227
|
}));
|
|
174
228
|
}
|
|
175
229
|
catch {
|
|
@@ -190,12 +244,22 @@ export class Routing {
|
|
|
190
244
|
const self = this;
|
|
191
245
|
const source = merge(...supports(this.routers, 'findPeer')
|
|
192
246
|
.map(router => (async function* () {
|
|
247
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:find-peer:start', {
|
|
248
|
+
routing: router.name,
|
|
249
|
+
peerId: id
|
|
250
|
+
}));
|
|
193
251
|
try {
|
|
194
252
|
yield await router.findPeer(id, options);
|
|
195
253
|
}
|
|
196
254
|
catch (err) {
|
|
197
255
|
self.log.error(err);
|
|
198
256
|
}
|
|
257
|
+
finally {
|
|
258
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:find-peer:end', {
|
|
259
|
+
routing: router.name,
|
|
260
|
+
peerId: id
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
199
263
|
})()));
|
|
200
264
|
for await (const peer of source) {
|
|
201
265
|
if (peer == null) {
|
|
@@ -213,7 +277,21 @@ export class Routing {
|
|
|
213
277
|
throw new NoRoutersAvailableError('No peer routers available');
|
|
214
278
|
}
|
|
215
279
|
for await (const peer of merge(...supports(this.routers, 'getClosestPeers')
|
|
216
|
-
.map(
|
|
280
|
+
.map(async function* (router) {
|
|
281
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:get-closest-peers:start', {
|
|
282
|
+
routing: router.name,
|
|
283
|
+
key
|
|
284
|
+
}));
|
|
285
|
+
try {
|
|
286
|
+
yield* router.getClosestPeers(key, options);
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
options?.onProgress?.(new CustomProgressEvent('helia:routing:get-closest-peers:end', {
|
|
290
|
+
routing: router.name,
|
|
291
|
+
key
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
}))) {
|
|
217
295
|
if (peer == null) {
|
|
218
296
|
continue;
|
|
219
297
|
}
|
package/dist/src/routing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAK5C,MAAM,mCAAmC,GAAG,CAAC,CAAA;AAY7C,MAAM,OAAO,OAAO;
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAK5C,MAAM,mCAA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import { BlockPinnedError } from
|
|
3
|
+
import { BlockPinnedError } from "./errors.js";
|
|
4
4
|
/**
|
|
5
5
|
* BlockStorage is a hybrid blockstore that puts/gets blocks from a configured
|
|
6
6
|
* blockstore (that may be on disk, s3, or something else). If the blocks are
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Key } from 'interface-datastore';
|
|
2
2
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
3
3
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
4
|
-
import { InvalidDatastoreVersionError } from
|
|
4
|
+
import { InvalidDatastoreVersionError } from "../errors.js";
|
|
5
5
|
const DS_VERSION_KEY = new Key('/version');
|
|
6
6
|
const CURRENT_VERSION = 1;
|
|
7
7
|
export async function assertDatastoreVersionIsCurrent(datastore) {
|
|
@@ -5,7 +5,7 @@ import * as dagJson from '@ipld/dag-json';
|
|
|
5
5
|
import * as dagPb from '@ipld/dag-pb';
|
|
6
6
|
import * as json from 'multiformats/codecs/json';
|
|
7
7
|
import * as raw from 'multiformats/codecs/raw';
|
|
8
|
-
import { isPromise } from
|
|
8
|
+
import { isPromise } from "./is-promise.js";
|
|
9
9
|
export function getCodec(initialCodecs = [], loadCodec) {
|
|
10
10
|
const codecs = {
|
|
11
11
|
[dagPb.code]: dagPb,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UnknownHashAlgorithmError } from '@helia/interface';
|
|
2
2
|
import { identity } from 'multiformats/hashes/identity';
|
|
3
3
|
import { sha256, sha512 } from 'multiformats/hashes/sha2';
|
|
4
|
-
import { isPromise } from
|
|
4
|
+
import { isPromise } from "./is-promise.js";
|
|
5
5
|
export function getHasher(initialHashers = [], loadHasher) {
|
|
6
6
|
const hashers = {
|
|
7
7
|
[sha256.code]: sha256,
|
|
@@ -6,7 +6,7 @@ import forEach from 'it-foreach';
|
|
|
6
6
|
import { CustomProgressEvent } from 'progress-events';
|
|
7
7
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
|
|
8
8
|
import { BlockNotFoundWhileOfflineError, InvalidConfigurationError, LoadBlockFailedError } from "../errors.js";
|
|
9
|
-
import { isPromise } from
|
|
9
|
+
import { isPromise } from "./is-promise.js";
|
|
10
10
|
const DEFAULT_MAX_IDENTITY_HASH_DIGEST_LENGTH = 128;
|
|
11
11
|
export class Storage {
|
|
12
12
|
child;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/utils",
|
|
3
|
-
"version": "2.4.2-
|
|
3
|
+
"version": "2.4.2-397f2d86",
|
|
4
4
|
"description": "Shared code that implements the Helia API",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/utils#readme",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"test:electron-main": "aegir test -t electron-main"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@helia/interface": "6.1.1-
|
|
50
|
+
"@helia/interface": "6.1.1-397f2d86",
|
|
51
51
|
"@ipld/dag-cbor": "^9.2.5",
|
|
52
52
|
"@ipld/dag-json": "^10.2.5",
|
|
53
53
|
"@ipld/dag-pb": "^4.1.5",
|
|
54
|
-
"@libp2p/interface": "^3.
|
|
54
|
+
"@libp2p/interface": "^3.2.0",
|
|
55
55
|
"@libp2p/keychain": "^6.0.5",
|
|
56
56
|
"@libp2p/utils": "^7.0.5",
|
|
57
57
|
"@multiformats/dns": "^1.0.9",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"it-foreach": "^2.1.5",
|
|
68
68
|
"it-merge": "^3.0.12",
|
|
69
69
|
"it-to-buffer": "^4.0.10",
|
|
70
|
-
"libp2p": "^3.0
|
|
70
|
+
"libp2p": "^3.2.0",
|
|
71
71
|
"mortice": "^3.3.1",
|
|
72
72
|
"multiformats": "^13.4.1",
|
|
73
73
|
"p-defer": "^4.0.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@libp2p/crypto": "^5.1.12",
|
|
80
80
|
"@libp2p/logger": "^6.0.5",
|
|
81
|
-
"@libp2p/peer-id": "^6.0.
|
|
81
|
+
"@libp2p/peer-id": "^6.0.6",
|
|
82
82
|
"@types/sinon": "^21.0.0",
|
|
83
83
|
"aegir": "^47.0.22",
|
|
84
84
|
"datastore-core": "^11.0.2",
|
package/src/abstract-session.ts
CHANGED
|
@@ -406,7 +406,7 @@ export abstract class AbstractSession<Provider, RetrieveBlockProgressEvents exte
|
|
|
406
406
|
/**
|
|
407
407
|
* This method should search for new providers and yield them.
|
|
408
408
|
*/
|
|
409
|
-
abstract findNewProviders (cid: CID, options:
|
|
409
|
+
abstract findNewProviders (cid: CID, options: BlockRetrievalOptions<RetrieveBlockProgressEvents>): AsyncGenerator<Provider>
|
|
410
410
|
|
|
411
411
|
/**
|
|
412
412
|
* The subclass should contact the provider and request the block from it.
|
package/src/index.ts
CHANGED
|
@@ -9,14 +9,14 @@ import { contentRoutingSymbol, peerRoutingSymbol, start, stop, TypedEventEmitter
|
|
|
9
9
|
import { dns } from '@multiformats/dns'
|
|
10
10
|
import drain from 'it-drain'
|
|
11
11
|
import { CustomProgressEvent } from 'progress-events'
|
|
12
|
-
import { PinsImpl } from './pins.
|
|
13
|
-
import { Routing as RoutingClass } from './routing.
|
|
14
|
-
import { BlockStorage } from './storage.
|
|
15
|
-
import { assertDatastoreVersionIsCurrent } from './utils/datastore-version.
|
|
16
|
-
import { getCodec } from './utils/get-codec.
|
|
17
|
-
import { getHasher } from './utils/get-hasher.
|
|
18
|
-
import { NetworkedStorage } from './utils/networked-storage.
|
|
19
|
-
import type { BlockStorageInit } from './storage.
|
|
12
|
+
import { PinsImpl } from './pins.ts'
|
|
13
|
+
import { Routing as RoutingClass } from './routing.ts'
|
|
14
|
+
import { BlockStorage } from './storage.ts'
|
|
15
|
+
import { assertDatastoreVersionIsCurrent } from './utils/datastore-version.ts'
|
|
16
|
+
import { getCodec } from './utils/get-codec.ts'
|
|
17
|
+
import { getHasher } from './utils/get-hasher.ts'
|
|
18
|
+
import { NetworkedStorage } from './utils/networked-storage.ts'
|
|
19
|
+
import type { BlockStorageInit } from './storage.ts'
|
|
20
20
|
import type { Await, CodecLoader, GCOptions, HasherLoader, Helia as HeliaInterface, HeliaEvents, Routing } from '@helia/interface'
|
|
21
21
|
import type { BlockBroker } from '@helia/interface/blocks'
|
|
22
22
|
import type { Pins } from '@helia/interface/pins'
|
|
@@ -30,8 +30,8 @@ import type { BlockCodec } from 'multiformats'
|
|
|
30
30
|
import type { CID } from 'multiformats/cid'
|
|
31
31
|
import type { MultihashHasher } from 'multiformats/hashes/interface'
|
|
32
32
|
|
|
33
|
-
export { AbstractSession } from './abstract-session.
|
|
34
|
-
export type { AbstractCreateSessionOptions, BlockstoreSessionEvents, AbstractSessionComponents } from './abstract-session.
|
|
33
|
+
export { AbstractSession } from './abstract-session.ts'
|
|
34
|
+
export type { AbstractCreateSessionOptions, BlockstoreSessionEvents, AbstractSessionComponents } from './abstract-session.ts'
|
|
35
35
|
|
|
36
36
|
export type { BlockStorage, BlockStorageInit }
|
|
37
37
|
|