@helia/block-brokers 1.0.0 → 2.0.0-e554493

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.
@@ -7,9 +7,15 @@ class BitswapBlockBroker {
7
7
  this.bitswap = createBitswap(libp2p, blockstore, {
8
8
  hashLoader: {
9
9
  getHasher: async (codecOrName) => {
10
- const hasher = hashers.find(hasher => {
11
- return hasher.code === codecOrName || hasher.name === codecOrName;
12
- });
10
+ let hasher;
11
+ if (typeof codecOrName === 'string') {
12
+ hasher = Object.values(hashers).find(hasher => {
13
+ return hasher.name === codecOrName;
14
+ });
15
+ }
16
+ else {
17
+ hasher = hashers[codecOrName];
18
+ }
13
19
  if (hasher != null) {
14
20
  return hasher;
15
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bitswap.js","sourceRoot":"","sources":["../../src/bitswap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAmB5C,MAAM,kBAAkB;IAGL,OAAO,CAAS;IACzB,OAAO,CAAS;IAExB,YAAa,UAA6B,EAAE,OAAoB,EAAE;QAChE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,UAAU,CAAA;QAElD,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE;YAC/C,UAAU,EAAE;gBACV,SAAS,EAAE,KAAK,EAAE,WAA4B,EAAoC,EAAE;oBAClF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;wBACnC,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAA;oBACnE,CAAC,CAAC,CAAA;oBAEF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;wBACnB,OAAO,MAAM,CAAA;oBACf,CAAC;oBAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,WAAW,GAAG,CAAC,CAAA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AAO,KAA6E,EAAE;QAC/H,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACxC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAE,OAAoB,EAAE;IAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACjE,CAAC"}
@@ -1,4 +1,3 @@
1
1
  export { bitswap } from './bitswap.js';
2
2
  export { trustlessGateway } from './trustless-gateway/index.js';
3
- export { NetworkedStorage } from './utils/networked-storage.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export { bitswap } from './bitswap.js';
2
2
  export { trustlessGateway } from './trustless-gateway/index.js';
3
- export { NetworkedStorage } from './utils/networked-storage.js';
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/block-brokers",
3
- "version": "1.0.0",
3
+ "version": "2.0.0-e554493",
4
4
  "description": "Block brokers for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/block-brokers#readme",
@@ -53,26 +53,17 @@
53
53
  "test:electron-main": "aegir test -t electron-main"
54
54
  },
55
55
  "dependencies": {
56
- "@helia/interface": "^3.0.1",
56
+ "@helia/interface": "4.0.0-e554493",
57
57
  "@libp2p/interface": "^1.1.1",
58
- "any-signal": "^4.1.1",
59
58
  "interface-blockstore": "^5.2.7",
60
- "interface-store": "^5.1.5",
61
59
  "ipfs-bitswap": "^20.0.0",
62
- "it-filter": "^3.0.4",
63
- "it-foreach": "^2.0.6",
64
60
  "multiformats": "^13.0.0",
65
- "progress-events": "^1.0.0",
66
- "uint8arrays": "^5.0.1"
61
+ "progress-events": "^1.0.0"
67
62
  },
68
63
  "devDependencies": {
69
- "@libp2p/logger": "^4.0.1",
64
+ "@libp2p/logger": "^4.0.4",
70
65
  "@types/sinon": "^17.0.2",
71
66
  "aegir": "^42.1.0",
72
- "blockstore-core": "^4.3.8",
73
- "delay": "^6.0.0",
74
- "it-all": "^3.0.4",
75
- "it-drain": "^3.0.5",
76
67
  "sinon": "^17.0.1",
77
68
  "sinon-ts": "^2.0.0"
78
69
  }
package/src/bitswap.ts CHANGED
@@ -10,7 +10,7 @@ import type { ProgressOptions } from 'progress-events'
10
10
  interface BitswapComponents {
11
11
  libp2p: Libp2p
12
12
  blockstore: Blockstore
13
- hashers: MultihashHasher[]
13
+ hashers: Record<string, MultihashHasher>
14
14
  }
15
15
 
16
16
  export interface BitswapInit extends BitswapOptions {
@@ -29,9 +29,15 @@ ProgressOptions<BitswapWantBlockProgressEvents>
29
29
  this.bitswap = createBitswap(libp2p, blockstore, {
30
30
  hashLoader: {
31
31
  getHasher: async (codecOrName: string | number): Promise<MultihashHasher<number>> => {
32
- const hasher = hashers.find(hasher => {
33
- return hasher.code === codecOrName || hasher.name === codecOrName
34
- })
32
+ let hasher: MultihashHasher | undefined
33
+
34
+ if (typeof codecOrName === 'string') {
35
+ hasher = Object.values(hashers).find(hasher => {
36
+ return hasher.name === codecOrName
37
+ })
38
+ } else {
39
+ hasher = hashers[codecOrName]
40
+ }
35
41
 
36
42
  if (hasher != null) {
37
43
  return hasher
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { bitswap } from './bitswap.js'
2
2
  export { trustlessGateway } from './trustless-gateway/index.js'
3
- export { NetworkedStorage } from './utils/networked-storage.js'
@@ -1,3 +0,0 @@
1
- import type { MultihashHasher } from 'multiformats/hashes/interface';
2
- export declare function defaultHashers(hashers?: MultihashHasher[]): MultihashHasher[];
3
- //# sourceMappingURL=default-hashers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-hashers.d.ts","sourceRoot":"","sources":["../../../src/utils/default-hashers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,wBAAgB,cAAc,CAAE,OAAO,GAAE,eAAe,EAAO,GAAG,eAAe,EAAE,CAOlF"}
@@ -1,11 +0,0 @@
1
- import { identity } from 'multiformats/hashes/identity';
2
- import { sha256, sha512 } from 'multiformats/hashes/sha2';
3
- export function defaultHashers(hashers = []) {
4
- return [
5
- sha256,
6
- sha512,
7
- identity,
8
- ...hashers
9
- ];
10
- }
11
- //# sourceMappingURL=default-hashers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-hashers.js","sourceRoot":"","sources":["../../../src/utils/default-hashers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAGzD,MAAM,UAAU,cAAc,CAAE,UAA6B,EAAE;IAC7D,OAAO;QACL,MAAM;QACN,MAAM;QACN,QAAQ;QACR,GAAG,OAAO;KACX,CAAA;AACH,CAAC"}
@@ -1,69 +0,0 @@
1
- import { type ProgressOptions } from 'progress-events';
2
- import type { BlockBroker, Blocks, Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions, BlockRetrievalOptions } from '@helia/interface/blocks';
3
- import type { AbortOptions, ComponentLogger, Startable } from '@libp2p/interface';
4
- import type { Blockstore } from 'interface-blockstore';
5
- import type { AwaitIterable } from 'interface-store';
6
- import type { CID } from 'multiformats/cid';
7
- import type { MultihashHasher } from 'multiformats/hashes/interface';
8
- export interface NetworkedStorageStorageInit {
9
- blockBrokers?: BlockBroker[];
10
- hashers?: MultihashHasher[];
11
- }
12
- export interface GetOptions extends AbortOptions {
13
- progress?(evt: Event): void;
14
- }
15
- export interface NetworkedStorageComponents {
16
- blockstore: Blockstore;
17
- logger: ComponentLogger;
18
- }
19
- /**
20
- * Networked storage wraps a regular blockstore - when getting blocks if the
21
- * blocks are not present Bitswap will be used to fetch them from network peers.
22
- */
23
- export declare class NetworkedStorage implements Blocks, Startable {
24
- private readonly child;
25
- private readonly blockRetrievers;
26
- private readonly blockAnnouncers;
27
- private readonly hashers;
28
- private started;
29
- private readonly log;
30
- /**
31
- * Create a new BlockStorage
32
- */
33
- constructor(components: NetworkedStorageComponents, init: NetworkedStorageStorageInit);
34
- isStarted(): boolean;
35
- start(): Promise<void>;
36
- stop(): Promise<void>;
37
- unwrap(): Blockstore;
38
- /**
39
- * Put a block to the underlying datastore
40
- */
41
- put(cid: CID, block: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>): Promise<CID>;
42
- /**
43
- * Put a multiple blocks to the underlying datastore
44
- */
45
- putMany(blocks: AwaitIterable<{
46
- cid: CID;
47
- block: Uint8Array;
48
- }>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): AsyncIterable<CID>;
49
- /**
50
- * Get a block by cid
51
- */
52
- get(cid: CID, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<Uint8Array>;
53
- /**
54
- * Get multiple blocks back from an (async) iterable of cids
55
- */
56
- getMany(cids: AwaitIterable<CID>, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>): AsyncIterable<Pair>;
57
- /**
58
- * Delete a block from the blockstore
59
- */
60
- delete(cid: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>): Promise<void>;
61
- /**
62
- * Delete multiple blocks from the blockstore
63
- */
64
- deleteMany(cids: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>): AsyncIterable<CID>;
65
- has(cid: CID, options?: AbortOptions): Promise<boolean>;
66
- getAll(options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>): AwaitIterable<Pair>;
67
- }
68
- export declare const getCidBlockVerifierFunction: (cid: CID, hashers: MultihashHasher[]) => Required<BlockRetrievalOptions>['validateFn'];
69
- //# sourceMappingURL=networked-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"networked-storage.d.ts","sourceRoot":"","sources":["../../../src/utils/networked-storage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,iBAAiB,EAAkC,qBAAqB,EAAE,M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,207 +0,0 @@
1
- import { CodeError, start, stop } from '@libp2p/interface';
2
- import { anySignal } from 'any-signal';
3
- import filter from 'it-filter';
4
- import forEach from 'it-foreach';
5
- import { CustomProgressEvent } from 'progress-events';
6
- import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
7
- function isBlockRetriever(b) {
8
- return typeof b.retrieve === 'function';
9
- }
10
- function isBlockAnnouncer(b) {
11
- return typeof b.announce === 'function';
12
- }
13
- /**
14
- * Networked storage wraps a regular blockstore - when getting blocks if the
15
- * blocks are not present Bitswap will be used to fetch them from network peers.
16
- */
17
- export class NetworkedStorage {
18
- child;
19
- blockRetrievers;
20
- blockAnnouncers;
21
- hashers;
22
- started;
23
- log;
24
- /**
25
- * Create a new BlockStorage
26
- */
27
- constructor(components, init) {
28
- this.log = components.logger.forComponent('helia:networked-storage');
29
- this.child = components.blockstore;
30
- this.blockRetrievers = (init.blockBrokers ?? []).filter(isBlockRetriever);
31
- this.blockAnnouncers = (init.blockBrokers ?? []).filter(isBlockAnnouncer);
32
- this.hashers = init.hashers ?? [];
33
- this.started = false;
34
- }
35
- isStarted() {
36
- return this.started;
37
- }
38
- async start() {
39
- await start(this.child, ...new Set([...this.blockRetrievers, ...this.blockAnnouncers]));
40
- this.started = true;
41
- }
42
- async stop() {
43
- await stop(this.child, ...new Set([...this.blockRetrievers, ...this.blockAnnouncers]));
44
- this.started = false;
45
- }
46
- unwrap() {
47
- return this.child;
48
- }
49
- /**
50
- * Put a block to the underlying datastore
51
- */
52
- async put(cid, block, options = {}) {
53
- if (await this.child.has(cid)) {
54
- options.onProgress?.(new CustomProgressEvent('blocks:put:duplicate', cid));
55
- return cid;
56
- }
57
- options.onProgress?.(new CustomProgressEvent('blocks:put:providers:notify', cid));
58
- this.blockAnnouncers.forEach(provider => {
59
- provider.announce(cid, block, options);
60
- });
61
- options.onProgress?.(new CustomProgressEvent('blocks:put:blockstore:put', cid));
62
- return this.child.put(cid, block, options);
63
- }
64
- /**
65
- * Put a multiple blocks to the underlying datastore
66
- */
67
- async *putMany(blocks, options = {}) {
68
- const missingBlocks = filter(blocks, async ({ cid }) => {
69
- const has = await this.child.has(cid);
70
- if (has) {
71
- options.onProgress?.(new CustomProgressEvent('blocks:put-many:duplicate', cid));
72
- }
73
- return !has;
74
- });
75
- const notifyEach = forEach(missingBlocks, ({ cid, block }) => {
76
- options.onProgress?.(new CustomProgressEvent('blocks:put-many:providers:notify', cid));
77
- this.blockAnnouncers.forEach(provider => {
78
- provider.announce(cid, block, options);
79
- });
80
- });
81
- options.onProgress?.(new CustomProgressEvent('blocks:put-many:blockstore:put-many'));
82
- yield* this.child.putMany(notifyEach, options);
83
- }
84
- /**
85
- * Get a block by cid
86
- */
87
- async get(cid, options = {}) {
88
- if (options.offline !== true && !(await this.child.has(cid))) {
89
- // we do not have the block locally, get it from a block provider
90
- options.onProgress?.(new CustomProgressEvent('blocks:get:providers:get', cid));
91
- const block = await raceBlockRetrievers(cid, this.blockRetrievers, this.hashers, {
92
- ...options,
93
- log: this.log
94
- });
95
- options.onProgress?.(new CustomProgressEvent('blocks:get:blockstore:put', cid));
96
- await this.child.put(cid, block, options);
97
- // notify other block providers of the new block
98
- options.onProgress?.(new CustomProgressEvent('blocks:get:providers:notify', cid));
99
- this.blockAnnouncers.forEach(provider => {
100
- provider.announce(cid, block, options);
101
- });
102
- return block;
103
- }
104
- options.onProgress?.(new CustomProgressEvent('blocks:get:blockstore:get', cid));
105
- return this.child.get(cid, options);
106
- }
107
- /**
108
- * Get multiple blocks back from an (async) iterable of cids
109
- */
110
- async *getMany(cids, options = {}) {
111
- options.onProgress?.(new CustomProgressEvent('blocks:get-many:blockstore:get-many'));
112
- yield* this.child.getMany(forEach(cids, async (cid) => {
113
- if (options.offline !== true && !(await this.child.has(cid))) {
114
- // we do not have the block locally, get it from a block provider
115
- options.onProgress?.(new CustomProgressEvent('blocks:get-many:providers:get', cid));
116
- const block = await raceBlockRetrievers(cid, this.blockRetrievers, this.hashers, {
117
- ...options,
118
- log: this.log
119
- });
120
- options.onProgress?.(new CustomProgressEvent('blocks:get-many:blockstore:put', cid));
121
- await this.child.put(cid, block, options);
122
- // notify other block providers of the new block
123
- options.onProgress?.(new CustomProgressEvent('blocks:get-many:providers:notify', cid));
124
- this.blockAnnouncers.forEach(provider => {
125
- provider.announce(cid, block, options);
126
- });
127
- }
128
- }));
129
- }
130
- /**
131
- * Delete a block from the blockstore
132
- */
133
- async delete(cid, options = {}) {
134
- options.onProgress?.(new CustomProgressEvent('blocks:delete:blockstore:delete', cid));
135
- await this.child.delete(cid, options);
136
- }
137
- /**
138
- * Delete multiple blocks from the blockstore
139
- */
140
- async *deleteMany(cids, options = {}) {
141
- options.onProgress?.(new CustomProgressEvent('blocks:delete-many:blockstore:delete-many'));
142
- yield* this.child.deleteMany((async function* () {
143
- for await (const cid of cids) {
144
- yield cid;
145
- }
146
- }()), options);
147
- }
148
- async has(cid, options = {}) {
149
- return this.child.has(cid, options);
150
- }
151
- async *getAll(options = {}) {
152
- options.onProgress?.(new CustomProgressEvent('blocks:get-all:blockstore:get-many'));
153
- yield* this.child.getAll(options);
154
- }
155
- }
156
- export const getCidBlockVerifierFunction = (cid, hashers) => {
157
- const hasher = hashers.find(hasher => hasher.code === cid.multihash.code);
158
- if (hasher == null) {
159
- throw new CodeError(`No hasher configured for multihash code 0x${cid.multihash.code.toString(16)}, please configure one. You can look up which hash this is at https://github.com/multiformats/multicodec/blob/master/table.csv`, 'ERR_UNKNOWN_HASH_ALG');
160
- }
161
- return async (block) => {
162
- // verify block
163
- const hash = await hasher.digest(block);
164
- if (!uint8ArrayEquals(hash.digest, cid.multihash.digest)) {
165
- // if a hash mismatch occurs for a TrustlessGatewayBlockBroker, we should try another gateway
166
- throw new CodeError('Hash of downloaded block did not match multihash from passed CID', 'ERR_HASH_MISMATCH');
167
- }
168
- };
169
- };
170
- /**
171
- * Race block providers cancelling any pending requests once the block has been
172
- * found.
173
- */
174
- async function raceBlockRetrievers(cid, providers, hashers, options) {
175
- const validateFn = getCidBlockVerifierFunction(cid, hashers);
176
- const controller = new AbortController();
177
- const signal = anySignal([controller.signal, options.signal]);
178
- try {
179
- return await Promise.any(providers.map(async (provider) => {
180
- try {
181
- let blocksWereValidated = false;
182
- const block = await provider.retrieve(cid, {
183
- ...options,
184
- signal,
185
- validateFn: async (block) => {
186
- await validateFn(block);
187
- blocksWereValidated = true;
188
- }
189
- });
190
- if (!blocksWereValidated) {
191
- // the blockBroker either did not throw an error when attempting to validate the block
192
- // or did not call the validateFn at all. We should validate the block ourselves
193
- await validateFn(block);
194
- }
195
- return block;
196
- }
197
- catch (err) {
198
- options.log.error('could not retrieve verified block for %c', cid, err);
199
- throw err;
200
- }
201
- }));
202
- }
203
- finally {
204
- signal.clear();
205
- }
206
- }
207
- //# sourceMappingURL=networked-storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"networked-storage.js","sourceRoot":"","sources":["../../../src/utils/networked-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAiB/D,SAAS,gBAAgB,CAAE,CAAM;IAC/B,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzC,CAAC;AAED,SAAS,gBAAgB,CAAE,CAAM;IAC/B,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAA;AACzC,CAAC;AAOD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACV,KAAK,CAAY;IACjB,eAAe,CAAkB;IACjC,eAAe,CAAkB;IACjC,OAAO,CAAmB;IACn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I,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,SAAS,CAAC,GAAG,CAAC,KAAK,EAAC,QAAQ,EAAC,EAAE;YAC7B,IAAI,CAAC;gBACH,IAAI,mBAAmB,GAAG,KAAK,CAAA;gBAC/B,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE;oBACzC,GAAG,OAAO;oBACV,MAAM;oBACN,UAAU,EAAE,KAAK,EAAE,KAAiB,EAAiB,EAAE;wBACrD,MAAM,UAAU,CAAC,KAAK,CAAC,CAAA;wBACvB,mBAAmB,GAAG,IAAI,CAAA;oBAC5B,CAAC;iBACF,CAAC,CAAA;gBAEF,IAAI,CAAC,mBAAmB,EAAE,CAAC;oBACzB,sFAAsF;oBACtF,gFAAgF;oBAChF,MAAM,UAAU,CAAC,KAAK,CAAC,CAAA;gBACzB,CAAC;gBAED,OAAO,KAAK,CAAA;YACd,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,0CAA0C,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;gBACvE,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAA;IAChB,CAAC;AACH,CAAC"}
@@ -1,5 +0,0 @@
1
- {
2
- "NetworkedStorage": "https://ipfs.github.io/helia/classes/_helia_block_brokers.NetworkedStorage.html",
3
- "bitswap": "https://ipfs.github.io/helia/functions/_helia_block_brokers.bitswap.html",
4
- "trustlessGateway": "https://ipfs.github.io/helia/functions/_helia_block_brokers.trustlessGateway.html"
5
- }
@@ -1,12 +0,0 @@
1
- import { identity } from 'multiformats/hashes/identity'
2
- import { sha256, sha512 } from 'multiformats/hashes/sha2'
3
- import type { MultihashHasher } from 'multiformats/hashes/interface'
4
-
5
- export function defaultHashers (hashers: MultihashHasher[] = []): MultihashHasher[] {
6
- return [
7
- sha256,
8
- sha512,
9
- identity,
10
- ...hashers
11
- ]
12
- }