helia 3.0.1 → 4.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.
- package/dist/index.min.js +39 -61
- package/dist/src/helia-p2p.d.ts +18 -0
- package/dist/src/helia-p2p.d.ts.map +1 -0
- package/dist/src/helia-p2p.js +22 -0
- package/dist/src/helia-p2p.js.map +1 -0
- package/dist/src/index.d.ts +9 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/libp2p-defaults.browser.d.ts +0 -2
- package/dist/src/utils/libp2p-defaults.browser.d.ts.map +1 -1
- package/dist/src/utils/libp2p-defaults.browser.js +1 -3
- package/dist/src/utils/libp2p-defaults.browser.js.map +1 -1
- package/dist/src/utils/libp2p-defaults.d.ts +0 -2
- package/dist/src/utils/libp2p-defaults.d.ts.map +1 -1
- package/dist/src/utils/libp2p-defaults.js +0 -2
- package/dist/src/utils/libp2p-defaults.js.map +1 -1
- package/dist/src/utils/libp2p.d.ts.map +1 -1
- package/dist/src/utils/libp2p.js +14 -6
- package/dist/src/utils/libp2p.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +17 -27
- package/src/helia-p2p.ts +37 -0
- package/src/index.ts +30 -10
- package/src/utils/libp2p-defaults.browser.ts +1 -5
- package/src/utils/libp2p-defaults.ts +0 -4
- package/src/utils/libp2p.ts +17 -8
- package/src/version.ts +1 -1
- package/dist/src/helia.d.ts +0 -26
- package/dist/src/helia.d.ts.map +0 -1
- package/dist/src/helia.js +0 -81
- package/dist/src/helia.js.map +0 -1
- package/dist/src/pins.d.ts +0 -17
- package/dist/src/pins.d.ts.map +0 -1
- package/dist/src/pins.js +0 -166
- package/dist/src/pins.js.map +0 -1
- package/dist/src/storage.d.ts +0 -63
- package/dist/src/storage.d.ts.map +0 -1
- package/dist/src/storage.js +0 -140
- package/dist/src/storage.js.map +0 -1
- package/dist/src/utils/dag-walkers.d.ts +0 -27
- package/dist/src/utils/dag-walkers.d.ts.map +0 -1
- package/dist/src/utils/dag-walkers.js +0 -157
- package/dist/src/utils/dag-walkers.js.map +0 -1
- package/dist/src/utils/datastore-version.d.ts +0 -3
- package/dist/src/utils/datastore-version.d.ts.map +0 -1
- package/dist/src/utils/datastore-version.js +0 -19
- package/dist/src/utils/datastore-version.js.map +0 -1
- package/dist/src/utils/default-hashers.d.ts +0 -3
- package/dist/src/utils/default-hashers.d.ts.map +0 -1
- package/dist/src/utils/default-hashers.js +0 -11
- package/dist/src/utils/default-hashers.js.map +0 -1
- package/dist/typedoc-urls.json +0 -10
- package/src/helia.ts +0 -107
- package/src/pins.ts +0 -239
- package/src/storage.ts +0 -172
- package/src/utils/dag-walkers.ts +0 -181
- package/src/utils/datastore-version.ts +0 -23
- package/src/utils/default-hashers.ts +0 -12
package/src/utils/libp2p.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { createLibp2p as create } from 'libp2p'
|
|
|
5
5
|
import { libp2pDefaults } from './libp2p-defaults.js'
|
|
6
6
|
import type { DefaultLibp2pServices } from './libp2p-defaults.js'
|
|
7
7
|
import type { ComponentLogger, Libp2p, PeerId } from '@libp2p/interface'
|
|
8
|
-
import type { KeychainInit } from '@libp2p/keychain'
|
|
8
|
+
import type { Keychain, KeychainInit } from '@libp2p/keychain'
|
|
9
9
|
import type { Datastore } from 'interface-datastore'
|
|
10
10
|
import type { Libp2pOptions } from 'libp2p'
|
|
11
11
|
|
|
@@ -23,31 +23,40 @@ export interface Libp2pDefaultsOptions {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export async function createLibp2p <T extends Record<string, unknown> = DefaultLibp2pServices> (options: CreateLibp2pOptions<T>): Promise<Libp2p<T>> {
|
|
26
|
-
|
|
26
|
+
const peerId = options.libp2p?.peerId
|
|
27
27
|
const logger = options.logger ?? defaultLogger()
|
|
28
|
+
const selfKey = new Key('/pkcs8/self')
|
|
29
|
+
let chain: Keychain | undefined
|
|
28
30
|
|
|
29
31
|
// if no peer id was passed, try to load it from the keychain
|
|
30
|
-
if (peerId == null) {
|
|
31
|
-
|
|
32
|
+
if (peerId == null && options.datastore != null) {
|
|
33
|
+
chain = keychain(options.keychain)({
|
|
32
34
|
datastore: options.datastore,
|
|
33
35
|
logger
|
|
34
36
|
})
|
|
35
37
|
|
|
36
|
-
const selfKey = new Key('/pkcs8/self')
|
|
37
|
-
|
|
38
38
|
if (await options.datastore.has(selfKey)) {
|
|
39
39
|
// load the peer id from the keychain
|
|
40
|
-
|
|
40
|
+
options.libp2p = options.libp2p ?? {}
|
|
41
|
+
options.libp2p.peerId = await chain.exportPeerId('self')
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const defaults = libp2pDefaults(options)
|
|
46
|
+
defaults.datastore = defaults.datastore ?? options.datastore
|
|
45
47
|
options = options ?? {}
|
|
46
48
|
|
|
47
49
|
// @ts-expect-error derived ServiceMap is not compatible with ServiceFactoryMap
|
|
48
|
-
|
|
50
|
+
const node = await create({
|
|
49
51
|
...defaults,
|
|
50
52
|
...options.libp2p,
|
|
51
53
|
start: false
|
|
52
54
|
})
|
|
55
|
+
|
|
56
|
+
if (peerId == null && chain != null && !await options.datastore.has(selfKey)) {
|
|
57
|
+
// persist the peer id in the keychain for next time
|
|
58
|
+
await chain.importPeer('self', node.peerId)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return node
|
|
53
62
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '
|
|
1
|
+
export const version = '4.0.0-e554493'
|
|
2
2
|
export const name = 'helia'
|
package/dist/src/helia.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BlockStorage } from './storage.js';
|
|
2
|
-
import type { HeliaInit } from '.';
|
|
3
|
-
import type { GCOptions, Helia } from '@helia/interface';
|
|
4
|
-
import type { Pins } from '@helia/interface/pins';
|
|
5
|
-
import type { ComponentLogger, Libp2p } from '@libp2p/interface';
|
|
6
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
7
|
-
import type { Datastore } from 'interface-datastore';
|
|
8
|
-
interface HeliaImplInit<T extends Libp2p = Libp2p> extends HeliaInit<T> {
|
|
9
|
-
libp2p: T;
|
|
10
|
-
blockstore: Blockstore;
|
|
11
|
-
datastore: Datastore;
|
|
12
|
-
}
|
|
13
|
-
export declare class HeliaImpl implements Helia {
|
|
14
|
-
libp2p: Libp2p;
|
|
15
|
-
blockstore: BlockStorage;
|
|
16
|
-
datastore: Datastore;
|
|
17
|
-
pins: Pins;
|
|
18
|
-
logger: ComponentLogger;
|
|
19
|
-
private readonly log;
|
|
20
|
-
constructor(init: HeliaImplInit);
|
|
21
|
-
start(): Promise<void>;
|
|
22
|
-
stop(): Promise<void>;
|
|
23
|
-
gc(options?: GCOptions): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=helia.d.ts.map
|
package/dist/src/helia.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helia.d.ts","sourceRoot":"","sources":["../../src/helia.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,CAAA;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAU,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGpD,UAAU,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IACrE,MAAM,EAAE,CAAC,CAAA;IACT,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,qBAAa,SAAU,YAAW,KAAK;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,YAAY,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,eAAe,CAAA;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,IAAI,EAAE,aAAa;IAkC1B,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAMvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAKtB,EAAE,CAAE,OAAO,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA+BlD"}
|
package/dist/src/helia.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { bitswap, trustlessGateway, NetworkedStorage } from '@helia/block-brokers';
|
|
2
|
-
import { start, stop } from '@libp2p/interface';
|
|
3
|
-
import drain from 'it-drain';
|
|
4
|
-
import { CustomProgressEvent } from 'progress-events';
|
|
5
|
-
import { PinsImpl } from './pins.js';
|
|
6
|
-
import { BlockStorage } from './storage.js';
|
|
7
|
-
import { assertDatastoreVersionIsCurrent } from './utils/datastore-version.js';
|
|
8
|
-
import { defaultHashers } from './utils/default-hashers.js';
|
|
9
|
-
export class HeliaImpl {
|
|
10
|
-
libp2p;
|
|
11
|
-
blockstore;
|
|
12
|
-
datastore;
|
|
13
|
-
pins;
|
|
14
|
-
logger;
|
|
15
|
-
log;
|
|
16
|
-
constructor(init) {
|
|
17
|
-
this.logger = init.libp2p.logger;
|
|
18
|
-
this.log = this.logger.forComponent('helia');
|
|
19
|
-
const hashers = defaultHashers(init.hashers);
|
|
20
|
-
const components = {
|
|
21
|
-
blockstore: init.blockstore,
|
|
22
|
-
datastore: init.datastore,
|
|
23
|
-
libp2p: init.libp2p,
|
|
24
|
-
hashers,
|
|
25
|
-
logger: init.libp2p.logger
|
|
26
|
-
};
|
|
27
|
-
const blockBrokers = init.blockBrokers?.map((fn) => {
|
|
28
|
-
return fn(components);
|
|
29
|
-
}) ?? [
|
|
30
|
-
bitswap()(components),
|
|
31
|
-
trustlessGateway()(components)
|
|
32
|
-
];
|
|
33
|
-
const networkedStorage = new NetworkedStorage(components, {
|
|
34
|
-
blockBrokers,
|
|
35
|
-
hashers
|
|
36
|
-
});
|
|
37
|
-
this.pins = new PinsImpl(init.datastore, networkedStorage, init.dagWalkers ?? []);
|
|
38
|
-
this.libp2p = init.libp2p;
|
|
39
|
-
this.blockstore = new BlockStorage(networkedStorage, this.pins, {
|
|
40
|
-
holdGcLock: init.holdGcLock
|
|
41
|
-
});
|
|
42
|
-
this.datastore = init.datastore;
|
|
43
|
-
}
|
|
44
|
-
async start() {
|
|
45
|
-
await assertDatastoreVersionIsCurrent(this.datastore);
|
|
46
|
-
await start(this.blockstore);
|
|
47
|
-
await this.libp2p.start();
|
|
48
|
-
}
|
|
49
|
-
async stop() {
|
|
50
|
-
await this.libp2p.stop();
|
|
51
|
-
await stop(this.blockstore);
|
|
52
|
-
}
|
|
53
|
-
async gc(options = {}) {
|
|
54
|
-
const releaseLock = await this.blockstore.lock.writeLock();
|
|
55
|
-
try {
|
|
56
|
-
const helia = this;
|
|
57
|
-
const blockstore = this.blockstore.unwrap();
|
|
58
|
-
this.log('gc start');
|
|
59
|
-
await drain(blockstore.deleteMany((async function* () {
|
|
60
|
-
for await (const { cid } of blockstore.getAll()) {
|
|
61
|
-
try {
|
|
62
|
-
if (await helia.pins.isPinned(cid, options)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
yield cid;
|
|
66
|
-
options.onProgress?.(new CustomProgressEvent('helia:gc:deleted', cid));
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
helia.log.error('Error during gc', err);
|
|
70
|
-
options.onProgress?.(new CustomProgressEvent('helia:gc:error', err));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}())));
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
releaseLock();
|
|
77
|
-
}
|
|
78
|
-
this.log('gc finished');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=helia.js.map
|
package/dist/src/helia.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helia.js","sourceRoot":"","sources":["../../src/helia.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAClF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAe3D,MAAM,OAAO,SAAS;IACb,MAAM,CAAQ;IACd,UAAU,CAAc;IACxB,SAAS,CAAW;IACpB,IAAI,CAAM;IACV,MAAM,CAAiB;IACb,GAAG,CAAQ;IAE5B,YAAa,IAAmB;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE5C,MAAM,UAAU,GAAG;Y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ore';
|
|
2
|
-
import { CID, type Version } from 'multiformats/cid';
|
|
3
|
-
import type { DAGWalker } from './index.js';
|
|
4
|
-
import type { AddOptions, IsPinnedOptions, LsOptions, Pin, Pins, RmOptions } from '@helia/interface/pins';
|
|
5
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
6
|
-
export declare class PinsImpl implements Pins {
|
|
7
|
-
#private;
|
|
8
|
-
private readonly datastore;
|
|
9
|
-
private readonly blockstore;
|
|
10
|
-
private dagWalkers;
|
|
11
|
-
constructor(datastore: Datastore, blockstore: Blockstore, dagWalkers: DAGWalker[]);
|
|
12
|
-
add(cid: CID<unknown, number, number, Version>, options?: AddOptions): AsyncGenerator<CID, void, undefined>;
|
|
13
|
-
rm(cid: CID<unknown, number, number, Version>, options?: RmOptions): AsyncGenerator<CID, void, undefined>;
|
|
14
|
-
ls(options?: LsOptions): AsyncGenerator<Pin, void, undefined>;
|
|
15
|
-
isPinned(cid: CID, options?: IsPinnedOptions): Promise<boolean>;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=pins.d.ts.map
|
package/dist/src/pins.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAO,MAAM,qBAAqB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,YAAY,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAgB,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAuDtD,qBAAa,QAAS,YAAW,IAAI;;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,UAAU,CAA2B;gBAEhC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE;IAU1E,GAAG,CAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAE,UAAe,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;IA6GhH,EAAE,CAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAE,SAAc,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;IA6B9G,EAAE,CAAE,OAAO,GAAE,SAAc,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;IAcpE,QAAQ,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAK3E"}
|
package/dist/src/pins.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Queue } from '@libp2p/utils/queue';
|
|
2
|
-
import * as cborg from 'cborg';
|
|
3
|
-
import { Key } from 'interface-datastore';
|
|
4
|
-
import { base36 } from 'multiformats/bases/base36';
|
|
5
|
-
import { CID } from 'multiformats/cid';
|
|
6
|
-
import { CustomProgressEvent } from 'progress-events';
|
|
7
|
-
import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
|
|
8
|
-
import { dagCborWalker, dagJsonWalker, dagPbWalker, jsonWalker, rawWalker } from './utils/dag-walkers.js';
|
|
9
|
-
const DEFAULT_DAG_WALKERS = [
|
|
10
|
-
rawWalker,
|
|
11
|
-
dagPbWalker,
|
|
12
|
-
dagCborWalker,
|
|
13
|
-
dagJsonWalker,
|
|
14
|
-
jsonWalker
|
|
15
|
-
];
|
|
16
|
-
const DATASTORE_PIN_PREFIX = '/pin/';
|
|
17
|
-
const DATASTORE_BLOCK_PREFIX = '/pinned-block/';
|
|
18
|
-
const DATASTORE_ENCODING = base36;
|
|
19
|
-
const DAG_WALK_QUEUE_CONCURRENCY = 1;
|
|
20
|
-
function toDSKey(cid) {
|
|
21
|
-
if (cid.version === 0) {
|
|
22
|
-
cid = cid.toV1();
|
|
23
|
-
}
|
|
24
|
-
return new Key(`${DATASTORE_PIN_PREFIX}${cid.toString(DATASTORE_ENCODING)}`);
|
|
25
|
-
}
|
|
26
|
-
export class PinsImpl {
|
|
27
|
-
datastore;
|
|
28
|
-
blockstore;
|
|
29
|
-
dagWalkers;
|
|
30
|
-
constructor(datastore, blockstore, dagWalkers) {
|
|
31
|
-
this.datastore = datastore;
|
|
32
|
-
this.blockstore = blockstore;
|
|
33
|
-
this.dagWalkers = {};
|
|
34
|
-
[...DEFAULT_DAG_WALKERS, ...dagWalkers].forEach(dagWalker => {
|
|
35
|
-
this.dagWalkers[dagWalker.codec] = dagWalker;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async *add(cid, options = {}) {
|
|
39
|
-
const pinKey = toDSKey(cid);
|
|
40
|
-
if (await this.datastore.has(pinKey)) {
|
|
41
|
-
throw new Error('Already pinned');
|
|
42
|
-
}
|
|
43
|
-
const depth = Math.round(options.depth ?? Infinity);
|
|
44
|
-
if (depth < 0) {
|
|
45
|
-
throw new Error('Depth must be greater than or equal to 0');
|
|
46
|
-
}
|
|
47
|
-
// use a queue to walk the DAG instead of recursion so we can traverse very large DAGs
|
|
48
|
-
const queue = new Queue({
|
|
49
|
-
concurrency: DAG_WALK_QUEUE_CONCURRENCY
|
|
50
|
-
});
|
|
51
|
-
for await (const childCid of this.#walkDag(cid, queue, {
|
|
52
|
-
...options,
|
|
53
|
-
depth
|
|
54
|
-
})) {
|
|
55
|
-
await this.#updatePinnedBlock(childCid, (pinnedBlock) => {
|
|
56
|
-
// do not update pinned block if this block is already pinned by this CID
|
|
57
|
-
if (pinnedBlock.pinnedBy.find(c => uint8ArrayEquals(c, cid.bytes)) != null) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
pinnedBlock.pinCount++;
|
|
61
|
-
pinnedBlock.pinnedBy.push(cid.bytes);
|
|
62
|
-
return true;
|
|
63
|
-
}, options);
|
|
64
|
-
yield childCid;
|
|
65
|
-
}
|
|
66
|
-
const pin = {
|
|
67
|
-
depth,
|
|
68
|
-
metadata: options.metadata ?? {}
|
|
69
|
-
};
|
|
70
|
-
await this.datastore.put(pinKey, cborg.encode(pin), options);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Walk a DAG in an iterable fashion
|
|
74
|
-
*/
|
|
75
|
-
async *#walkDag(cid, queue, options) {
|
|
76
|
-
if (options.depth === -1) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const dagWalker = this.dagWalkers[cid.code];
|
|
80
|
-
if (dagWalker == null) {
|
|
81
|
-
throw new Error(`No dag walker found for cid codec ${cid.code}`);
|
|
82
|
-
}
|
|
83
|
-
const block = await this.blockstore.get(cid, options);
|
|
84
|
-
yield cid;
|
|
85
|
-
// walk dag, ensure all blocks are present
|
|
86
|
-
for await (const cid of dagWalker.walk(block)) {
|
|
87
|
-
yield* await queue.add(async () => {
|
|
88
|
-
return this.#walkDag(cid, queue, {
|
|
89
|
-
...options,
|
|
90
|
-
depth: options.depth - 1
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Update the pin count for the CID
|
|
97
|
-
*/
|
|
98
|
-
async #updatePinnedBlock(cid, withPinnedBlock, options) {
|
|
99
|
-
const blockKey = new Key(`${DATASTORE_BLOCK_PREFIX}${DATASTORE_ENCODING.encode(cid.multihash.bytes)}`);
|
|
100
|
-
let pinnedBlock = {
|
|
101
|
-
pinCount: 0,
|
|
102
|
-
pinnedBy: []
|
|
103
|
-
};
|
|
104
|
-
try {
|
|
105
|
-
pinnedBlock = cborg.decode(await this.datastore.get(blockKey, options));
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
if (err.code !== 'ERR_NOT_FOUND') {
|
|
109
|
-
throw err;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const shouldContinue = withPinnedBlock(pinnedBlock);
|
|
113
|
-
if (!shouldContinue) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (pinnedBlock.pinCount === 0) {
|
|
117
|
-
if (await this.datastore.has(blockKey)) {
|
|
118
|
-
await this.datastore.delete(blockKey);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
await this.datastore.put(blockKey, cborg.encode(pinnedBlock), options);
|
|
123
|
-
options.onProgress?.(new CustomProgressEvent('helia:pin:add', cid));
|
|
124
|
-
}
|
|
125
|
-
async *rm(cid, options = {}) {
|
|
126
|
-
const pinKey = toDSKey(cid);
|
|
127
|
-
const buf = await this.datastore.get(pinKey, options);
|
|
128
|
-
const pin = cborg.decode(buf);
|
|
129
|
-
await this.datastore.delete(pinKey, options);
|
|
130
|
-
// use a queue to walk the DAG instead of recursion so we can traverse very large DAGs
|
|
131
|
-
const queue = new Queue({
|
|
132
|
-
concurrency: DAG_WALK_QUEUE_CONCURRENCY
|
|
133
|
-
});
|
|
134
|
-
for await (const childCid of this.#walkDag(cid, queue, {
|
|
135
|
-
...options,
|
|
136
|
-
depth: pin.depth
|
|
137
|
-
})) {
|
|
138
|
-
await this.#updatePinnedBlock(childCid, (pinnedBlock) => {
|
|
139
|
-
pinnedBlock.pinCount--;
|
|
140
|
-
pinnedBlock.pinnedBy = pinnedBlock.pinnedBy.filter(c => uint8ArrayEquals(c, cid.bytes));
|
|
141
|
-
return true;
|
|
142
|
-
}, {
|
|
143
|
-
...options,
|
|
144
|
-
depth: pin.depth
|
|
145
|
-
});
|
|
146
|
-
yield childCid;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async *ls(options = {}) {
|
|
150
|
-
for await (const { key, value } of this.datastore.query({
|
|
151
|
-
prefix: DATASTORE_PIN_PREFIX + (options.cid != null ? `${options.cid.toString(base36)}` : '')
|
|
152
|
-
}, options)) {
|
|
153
|
-
const cid = CID.parse(key.toString().substring(5), base36);
|
|
154
|
-
const pin = cborg.decode(value);
|
|
155
|
-
yield {
|
|
156
|
-
cid,
|
|
157
|
-
...pin
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async isPinned(cid, options = {}) {
|
|
162
|
-
const blockKey = new Key(`${DATASTORE_BLOCK_PREFIX}${DATASTORE_ENCODING.encode(cid.multihash.bytes)}`);
|
|
163
|
-
return this.datastore.has(blockKey, options);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=pins.js.map
|
package/dist/src/pins.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pins.js","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAkB,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,GAAG,EAAgB,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAwB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAMzG,MAAM,mBAAmB,GAAG;IAC1B,SAAS;IACT,WAAW;IACX,aAAa;IACb,aAAa;IACb,UAAU;CACX,CAAA;AA8BD,MAAM,oBA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AC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAEtG,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;CACF"}
|
package/dist/src/storage.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Blocks, Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions } from '@helia/interface/blocks';
|
|
2
|
-
import type { Pins } from '@helia/interface/pins';
|
|
3
|
-
import type { AbortOptions, Startable } from '@libp2p/interface';
|
|
4
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
5
|
-
import type { AwaitIterable } from 'interface-store';
|
|
6
|
-
import type { Mortice } from 'mortice';
|
|
7
|
-
import type { CID } from 'multiformats/cid';
|
|
8
|
-
import type { ProgressOptions } from 'progress-events';
|
|
9
|
-
export interface BlockStorageInit {
|
|
10
|
-
holdGcLock?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface GetOptions extends AbortOptions {
|
|
13
|
-
progress?(evt: Event): void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* BlockStorage is a hybrid blockstore that puts/gets blocks from a configured
|
|
17
|
-
* blockstore (that may be on disk, s3, or something else). If the blocks are
|
|
18
|
-
* not present Bitswap will be used to fetch them from network peers.
|
|
19
|
-
*/
|
|
20
|
-
export declare class BlockStorage implements Blocks, Startable {
|
|
21
|
-
lock: Mortice;
|
|
22
|
-
private readonly child;
|
|
23
|
-
private readonly pins;
|
|
24
|
-
private started;
|
|
25
|
-
/**
|
|
26
|
-
* Create a new BlockStorage
|
|
27
|
-
*/
|
|
28
|
-
constructor(blockstore: Blockstore, pins: Pins, options?: BlockStorageInit);
|
|
29
|
-
isStarted(): boolean;
|
|
30
|
-
start(): Promise<void>;
|
|
31
|
-
stop(): Promise<void>;
|
|
32
|
-
unwrap(): Blockstore;
|
|
33
|
-
/**
|
|
34
|
-
* Put a block to the underlying datastore
|
|
35
|
-
*/
|
|
36
|
-
put(cid: CID, block: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>): Promise<CID>;
|
|
37
|
-
/**
|
|
38
|
-
* Put a multiple blocks to the underlying datastore
|
|
39
|
-
*/
|
|
40
|
-
putMany(blocks: AwaitIterable<{
|
|
41
|
-
cid: CID;
|
|
42
|
-
block: Uint8Array;
|
|
43
|
-
}>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): AsyncIterable<CID>;
|
|
44
|
-
/**
|
|
45
|
-
* Get a block by cid
|
|
46
|
-
*/
|
|
47
|
-
get(cid: CID, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<Uint8Array>;
|
|
48
|
-
/**
|
|
49
|
-
* Get multiple blocks back from an (async) iterable of cids
|
|
50
|
-
*/
|
|
51
|
-
getMany(cids: AwaitIterable<CID>, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>): AsyncIterable<Pair>;
|
|
52
|
-
/**
|
|
53
|
-
* Delete a block from the blockstore
|
|
54
|
-
*/
|
|
55
|
-
delete(cid: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Delete multiple blocks from the blockstore
|
|
58
|
-
*/
|
|
59
|
-
deleteMany(cids: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>): AsyncIterable<CID>;
|
|
60
|
-
has(cid: CID, options?: AbortOptions): Promise<boolean>;
|
|
61
|
-
getAll(options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>): AsyncIterable<Pair>;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
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/storage.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { start, stop } from '@libp2p/interface';
|
|
2
|
-
import createMortice from 'mortice';
|
|
3
|
-
/**
|
|
4
|
-
* BlockStorage is a hybrid blockstore that puts/gets blocks from a configured
|
|
5
|
-
* blockstore (that may be on disk, s3, or something else). If the blocks are
|
|
6
|
-
* not present Bitswap will be used to fetch them from network peers.
|
|
7
|
-
*/
|
|
8
|
-
export class BlockStorage {
|
|
9
|
-
lock;
|
|
10
|
-
child;
|
|
11
|
-
pins;
|
|
12
|
-
started;
|
|
13
|
-
/**
|
|
14
|
-
* Create a new BlockStorage
|
|
15
|
-
*/
|
|
16
|
-
constructor(blockstore, pins, options = {}) {
|
|
17
|
-
this.child = blockstore;
|
|
18
|
-
this.pins = pins;
|
|
19
|
-
this.lock = createMortice({
|
|
20
|
-
singleProcess: options.holdGcLock
|
|
21
|
-
});
|
|
22
|
-
this.started = false;
|
|
23
|
-
}
|
|
24
|
-
isStarted() {
|
|
25
|
-
return this.started;
|
|
26
|
-
}
|
|
27
|
-
async start() {
|
|
28
|
-
await start(this.child);
|
|
29
|
-
this.started = true;
|
|
30
|
-
}
|
|
31
|
-
async stop() {
|
|
32
|
-
await stop(this.child);
|
|
33
|
-
this.started = false;
|
|
34
|
-
}
|
|
35
|
-
unwrap() {
|
|
36
|
-
return this.child;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Put a block to the underlying datastore
|
|
40
|
-
*/
|
|
41
|
-
async put(cid, block, options = {}) {
|
|
42
|
-
const releaseLock = await this.lock.readLock();
|
|
43
|
-
try {
|
|
44
|
-
return await this.child.put(cid, block, options);
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
releaseLock();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Put a multiple blocks to the underlying datastore
|
|
52
|
-
*/
|
|
53
|
-
async *putMany(blocks, options = {}) {
|
|
54
|
-
const releaseLock = await this.lock.readLock();
|
|
55
|
-
try {
|
|
56
|
-
yield* this.child.putMany(blocks, options);
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
releaseLock();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get a block by cid
|
|
64
|
-
*/
|
|
65
|
-
async get(cid, options = {}) {
|
|
66
|
-
const releaseLock = await this.lock.readLock();
|
|
67
|
-
try {
|
|
68
|
-
return await this.child.get(cid, options);
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
releaseLock();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get multiple blocks back from an (async) iterable of cids
|
|
76
|
-
*/
|
|
77
|
-
async *getMany(cids, options = {}) {
|
|
78
|
-
const releaseLock = await this.lock.readLock();
|
|
79
|
-
try {
|
|
80
|
-
yield* this.child.getMany(cids, options);
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
releaseLock();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Delete a block from the blockstore
|
|
88
|
-
*/
|
|
89
|
-
async delete(cid, options = {}) {
|
|
90
|
-
const releaseLock = await this.lock.writeLock();
|
|
91
|
-
try {
|
|
92
|
-
if (await this.pins.isPinned(cid)) {
|
|
93
|
-
throw new Error('CID was pinned');
|
|
94
|
-
}
|
|
95
|
-
await this.child.delete(cid, options);
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
releaseLock();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Delete multiple blocks from the blockstore
|
|
103
|
-
*/
|
|
104
|
-
async *deleteMany(cids, options = {}) {
|
|
105
|
-
const releaseLock = await this.lock.writeLock();
|
|
106
|
-
try {
|
|
107
|
-
const storage = this;
|
|
108
|
-
yield* this.child.deleteMany((async function* () {
|
|
109
|
-
for await (const cid of cids) {
|
|
110
|
-
if (await storage.pins.isPinned(cid)) {
|
|
111
|
-
throw new Error('CID was pinned');
|
|
112
|
-
}
|
|
113
|
-
yield cid;
|
|
114
|
-
}
|
|
115
|
-
}()), options);
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
releaseLock();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async has(cid, options = {}) {
|
|
122
|
-
const releaseLock = await this.lock.readLock();
|
|
123
|
-
try {
|
|
124
|
-
return await this.child.has(cid, options);
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
releaseLock();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async *getAll(options = {}) {
|
|
131
|
-
const releaseLock = await this.lock.readLock();
|
|
132
|
-
try {
|
|
133
|
-
yield* this.child.getAll(options);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
releaseLock();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=storage.js.map
|
package/dist/src/storage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,aAAa,MAAM,SAAS,CAAA;AAkBnC;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAChB,IAAI,CAAS;IACH,KAAK,CAAY;IACjB,IAAI,CAAM;IACnB,OAAO,CAAS;IAExB;;OAEG;IACH,YAAa,UAAsB,EAAE,IAAU,EAAE,UAA4B,EAAE;QAC7E,IAAI,CAAC,KAAK,GAAG,UAAU,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC,UAAU;SAClC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED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,EAAE,CAAC;oBAC7B,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;wBACrC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;oBACnC,CAAC;oBAED,MAAM,GAAG,CAAA;gBACX,CAAC;YACH,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;QAChB,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,CAAA;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAE,GAAQ,EAAE,UAAwB,EAAE;QAC7C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;QAE9C,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,CAAA;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAE,MAAM,CAAE,UAAsE,EAAE;QACtF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;QAE9C,IAAI,CAAC;YACH,KAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACpC,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,CAAA;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { DAGWalker } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Dag walker for dag-pb CIDs
|
|
4
|
-
*/
|
|
5
|
-
export declare const dagPbWalker: DAGWalker;
|
|
6
|
-
/**
|
|
7
|
-
* Dag walker for raw CIDs
|
|
8
|
-
*/
|
|
9
|
-
export declare const rawWalker: DAGWalker;
|
|
10
|
-
/**
|
|
11
|
-
* Dag walker for dag-cbor CIDs. Does not actually use dag-cbor since
|
|
12
|
-
* all we are interested in is extracting the the CIDs from the block
|
|
13
|
-
* so we can just use cborg for that.
|
|
14
|
-
*/
|
|
15
|
-
export declare const dagCborWalker: DAGWalker;
|
|
16
|
-
/**
|
|
17
|
-
* Dag walker for dag-json CIDs. Does not actually use dag-json since
|
|
18
|
-
* all we are interested in is extracting the the CIDs from the block
|
|
19
|
-
* so we can just use cborg/json for that.
|
|
20
|
-
*/
|
|
21
|
-
export declare const dagJsonWalker: DAGWalker;
|
|
22
|
-
/**
|
|
23
|
-
* Dag walker for json CIDs. JSON has no facility for linking to
|
|
24
|
-
* external blocks so the walker is a no-op.
|
|
25
|
-
*/
|
|
26
|
-
export declare const jsonWalker: DAGWalker;
|
|
27
|
-
//# sourceMappingURL=dag-walkers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag-walkers.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-walkers.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,SAOzB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAKvB,CAAA;AAKD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAuB3B,CAAA;AAsED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SA6B3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,SAGxB,CAAA"}
|