helia 6.1.4 → 7.0.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/dist/index.min.js +65 -55
- package/dist/index.min.js.map +4 -4
- package/dist/src/block-storage.d.ts +62 -0
- package/dist/src/block-storage.d.ts.map +1 -0
- package/dist/src/block-storage.js +159 -0
- package/dist/src/block-storage.js.map +1 -0
- package/dist/src/datastore-version.d.ts +3 -0
- package/dist/src/datastore-version.d.ts.map +1 -0
- package/dist/src/datastore-version.js +20 -0
- package/dist/src/datastore-version.js.map +1 -0
- package/dist/src/get-codec.d.ts +4 -0
- package/dist/src/get-codec.d.ts.map +1 -0
- package/dist/src/get-codec.js +31 -0
- package/dist/src/get-codec.js.map +1 -0
- package/dist/src/get-crypto.d.ts +4 -0
- package/dist/src/get-crypto.d.ts.map +1 -0
- package/dist/src/get-crypto.js +35 -0
- package/dist/src/get-crypto.js.map +1 -0
- package/dist/src/get-hasher.d.ts +4 -0
- package/dist/src/get-hasher.d.ts.map +1 -0
- package/dist/src/get-hasher.js +31 -0
- package/dist/src/get-hasher.js.map +1 -0
- package/dist/src/helia.d.ts +165 -0
- package/dist/src/helia.d.ts.map +1 -0
- package/dist/src/helia.js +165 -0
- package/dist/src/helia.js.map +1 -0
- package/dist/src/index.d.ts +30 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +78 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/networked-storage.d.ts +28 -0
- package/dist/src/networked-storage.d.ts.map +1 -0
- package/dist/src/networked-storage.js +52 -0
- package/dist/src/networked-storage.js.map +1 -0
- package/dist/src/pins.d.ts +21 -0
- package/dist/src/pins.d.ts.map +1 -0
- package/dist/src/pins.js +140 -0
- package/dist/src/pins.js.map +1 -0
- package/dist/src/routing.d.ts +51 -0
- package/dist/src/routing.d.ts.map +1 -0
- package/dist/src/routing.js +311 -0
- package/dist/src/routing.js.map +1 -0
- package/dist/src/session-storage.d.ts +47 -0
- package/dist/src/session-storage.d.ts.map +1 -0
- package/dist/src/session-storage.js +148 -0
- package/dist/src/session-storage.js.map +1 -0
- package/dist/src/storage.d.ts +55 -0
- package/dist/src/storage.d.ts.map +1 -0
- package/dist/src/storage.js +225 -0
- package/dist/src/storage.js.map +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/typedoc-urls.json +3 -6
- package/package.json +38 -41
- package/src/block-storage.ts +194 -0
- package/src/datastore-version.ts +25 -0
- package/src/get-codec.ts +39 -0
- package/src/get-crypto.ts +44 -0
- package/src/get-hasher.ts +39 -0
- package/src/helia.ts +364 -0
- package/src/index.ts +58 -30
- package/src/networked-storage.ts +74 -0
- package/src/pins.ts +208 -0
- package/src/routing.ts +389 -0
- package/src/session-storage.ts +174 -0
- package/src/storage.ts +294 -0
- package/src/version.ts +1 -1
- package/dist/src/utils/bootstrappers.d.ts +0 -4
- package/dist/src/utils/bootstrappers.d.ts.map +0 -1
- package/dist/src/utils/bootstrappers.js +0 -13
- package/dist/src/utils/bootstrappers.js.map +0 -1
- package/dist/src/utils/helia-defaults.d.ts +0 -48
- package/dist/src/utils/helia-defaults.d.ts.map +0 -1
- package/dist/src/utils/helia-defaults.js +0 -85
- package/dist/src/utils/helia-defaults.js.map +0 -1
- package/dist/src/utils/libp2p-defaults.browser.d.ts +0 -19
- package/dist/src/utils/libp2p-defaults.browser.d.ts.map +0 -1
- package/dist/src/utils/libp2p-defaults.browser.js +0 -73
- package/dist/src/utils/libp2p-defaults.browser.js.map +0 -1
- package/dist/src/utils/libp2p-defaults.d.ts +0 -49
- package/dist/src/utils/libp2p-defaults.d.ts.map +0 -1
- package/dist/src/utils/libp2p-defaults.js +0 -113
- package/dist/src/utils/libp2p-defaults.js.map +0 -1
- package/dist/src/utils/libp2p.d.ts +0 -19
- package/dist/src/utils/libp2p.d.ts.map +0 -1
- package/dist/src/utils/libp2p.js +0 -19
- package/dist/src/utils/libp2p.js.map +0 -1
- package/src/utils/bootstrappers.ts +0 -12
- package/src/utils/helia-defaults.ts +0 -92
- package/src/utils/libp2p-defaults.browser.ts +0 -92
- package/src/utils/libp2p-defaults.ts +0 -137
- package/src/utils/libp2p.ts +0 -42
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* This module contains utility code that is shared between various Helia
|
|
5
|
+
* modules such as `helia`, `@helia/http`, etc.
|
|
6
|
+
*/
|
|
7
|
+
import { InvalidConfigurationError } from '@helia/utils';
|
|
8
|
+
import { keychain } from '@ipshipyard/keychain';
|
|
9
|
+
import { start, stop } from '@libp2p/interface';
|
|
10
|
+
import { dns } from '@multiformats/dns';
|
|
11
|
+
import { defaultLogger } from 'birnam';
|
|
12
|
+
import { MemoryBlockstore } from 'blockstore-core';
|
|
13
|
+
import { MemoryDatastore } from 'datastore-core';
|
|
14
|
+
import drain from 'it-drain';
|
|
15
|
+
import { TypedEventEmitter } from 'main-event';
|
|
16
|
+
import { CustomProgressEvent } from 'progress-events';
|
|
17
|
+
import { BlockStorage } from "./block-storage.js";
|
|
18
|
+
import { assertDatastoreVersionIsCurrent } from "./datastore-version.js";
|
|
19
|
+
import { getCodec } from "./get-codec.js";
|
|
20
|
+
import { getCrypto } from "./get-crypto.js";
|
|
21
|
+
import { getHasher } from "./get-hasher.js";
|
|
22
|
+
import { NetworkedStorage } from "./networked-storage.js";
|
|
23
|
+
import { PinsImpl } from "./pins.js";
|
|
24
|
+
import { Routing as RoutingClass } from "./routing.js";
|
|
25
|
+
export class Helia {
|
|
26
|
+
info;
|
|
27
|
+
blockstore;
|
|
28
|
+
datastore;
|
|
29
|
+
events;
|
|
30
|
+
pins;
|
|
31
|
+
logger;
|
|
32
|
+
routing;
|
|
33
|
+
getCodec;
|
|
34
|
+
getHasher;
|
|
35
|
+
getCrypto;
|
|
36
|
+
dns;
|
|
37
|
+
keychain;
|
|
38
|
+
metrics;
|
|
39
|
+
status;
|
|
40
|
+
log;
|
|
41
|
+
blockBrokers;
|
|
42
|
+
mixins;
|
|
43
|
+
constructor(init) {
|
|
44
|
+
this.info = {
|
|
45
|
+
name: init.name,
|
|
46
|
+
version: init.version
|
|
47
|
+
};
|
|
48
|
+
this.logger = init.logger ?? defaultLogger();
|
|
49
|
+
this.log = this.logger.forComponent('helia');
|
|
50
|
+
this.getHasher = getHasher(init.hashers, init.loadHasher);
|
|
51
|
+
this.getCodec = getCodec(init.codecs, init.loadCodec);
|
|
52
|
+
this.getCrypto = getCrypto(init.cryptos, init.loadCrypto);
|
|
53
|
+
this.dns = init.dns ?? dns();
|
|
54
|
+
this.metrics = init.metrics;
|
|
55
|
+
this.events = new TypedEventEmitter();
|
|
56
|
+
this.status = 'stopped';
|
|
57
|
+
this.mixins = [];
|
|
58
|
+
// @ts-expect-error routing and keychain are not set
|
|
59
|
+
const components = {
|
|
60
|
+
blockstore: init.blockstore ?? new MemoryBlockstore(),
|
|
61
|
+
datastore: init.datastore ?? new MemoryDatastore(),
|
|
62
|
+
logger: this.logger,
|
|
63
|
+
blockBrokers: [],
|
|
64
|
+
getHasher: this.getHasher,
|
|
65
|
+
getCodec: this.getCodec,
|
|
66
|
+
getCrypto: this.getCrypto,
|
|
67
|
+
dns: this.dns,
|
|
68
|
+
metrics: this.metrics,
|
|
69
|
+
...(init.components ?? {})
|
|
70
|
+
};
|
|
71
|
+
this.keychain = components.keychain = keychain()(components);
|
|
72
|
+
this.routing = components.routing = new RoutingClass(components, {
|
|
73
|
+
routers: (init.routers ?? []).flatMap((router) => {
|
|
74
|
+
if (typeof router === 'function') {
|
|
75
|
+
router = router(components);
|
|
76
|
+
}
|
|
77
|
+
// if the router itself is a router
|
|
78
|
+
const routers = [
|
|
79
|
+
router
|
|
80
|
+
];
|
|
81
|
+
return routers;
|
|
82
|
+
}),
|
|
83
|
+
providerLookupConcurrency: init.providerLookupConcurrency
|
|
84
|
+
});
|
|
85
|
+
this.blockBrokers = components.blockBrokers = (init.blockBrokers ?? []).map((broker) => {
|
|
86
|
+
if (typeof broker === 'function') {
|
|
87
|
+
broker = broker(components);
|
|
88
|
+
}
|
|
89
|
+
return broker;
|
|
90
|
+
});
|
|
91
|
+
const networkedStorage = new NetworkedStorage(components, init);
|
|
92
|
+
this.pins = new PinsImpl(components.datastore, networkedStorage, this.getCodec);
|
|
93
|
+
this.blockstore = new BlockStorage(networkedStorage, this.pins, this.routing, {
|
|
94
|
+
holdGcLock: init.holdGcLock ?? true
|
|
95
|
+
});
|
|
96
|
+
this.datastore = components.datastore;
|
|
97
|
+
}
|
|
98
|
+
hasRouter(name) {
|
|
99
|
+
return this.routing.hasRouter(name);
|
|
100
|
+
}
|
|
101
|
+
addRouter(router) {
|
|
102
|
+
this.routing.addRouter(router);
|
|
103
|
+
}
|
|
104
|
+
hasBlockBroker(name) {
|
|
105
|
+
return this.blockBrokers.findIndex(b => b.name === name) !== -1;
|
|
106
|
+
}
|
|
107
|
+
addBlockBroker(blockBroker) {
|
|
108
|
+
this.blockBrokers.push(blockBroker);
|
|
109
|
+
}
|
|
110
|
+
addMixin(mixin) {
|
|
111
|
+
if (this.mixins.find(m => m.name === mixin.name) != null) {
|
|
112
|
+
throw new InvalidConfigurationError(`A mixin with the name "${mixin.name} is already present`);
|
|
113
|
+
}
|
|
114
|
+
this.mixins.push(mixin);
|
|
115
|
+
}
|
|
116
|
+
async start() {
|
|
117
|
+
this.status = 'starting';
|
|
118
|
+
await assertDatastoreVersionIsCurrent(this.datastore);
|
|
119
|
+
await start(this.blockstore, this.datastore, this.routing, ...this.blockBrokers);
|
|
120
|
+
for (const mixin of this.mixins) {
|
|
121
|
+
await mixin.start?.(this);
|
|
122
|
+
}
|
|
123
|
+
this.status = 'started';
|
|
124
|
+
this.events.dispatchEvent(new CustomEvent('start', { detail: this }));
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
async stop() {
|
|
128
|
+
this.status = 'stopping';
|
|
129
|
+
for (const mixin of this.mixins) {
|
|
130
|
+
await mixin.stop?.(this);
|
|
131
|
+
}
|
|
132
|
+
await stop(this.blockstore, this.datastore, this.routing, ...this.blockBrokers);
|
|
133
|
+
this.status = 'stopped';
|
|
134
|
+
this.events.dispatchEvent(new CustomEvent('stop', { detail: this }));
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
async gc(options = {}) {
|
|
138
|
+
const releaseLock = await this.blockstore.lock.writeLock();
|
|
139
|
+
try {
|
|
140
|
+
const helia = this;
|
|
141
|
+
const blockstore = this.blockstore.unwrap();
|
|
142
|
+
this.log('gc start');
|
|
143
|
+
await drain(blockstore.deleteMany((async function* () {
|
|
144
|
+
for await (const { cid } of blockstore.getAll()) {
|
|
145
|
+
try {
|
|
146
|
+
if (await helia.pins.isPinned(cid, options)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
yield cid;
|
|
150
|
+
options.onProgress?.(new CustomProgressEvent('helia:gc:deleted', cid));
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
helia.log.error('error during gc - %e', err);
|
|
154
|
+
options.onProgress?.(new CustomProgressEvent('helia:gc:error', err));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}())));
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
releaseLock();
|
|
161
|
+
}
|
|
162
|
+
this.log('gc finished');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=helia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helia.js","sourceRoot":"","sources":["../../src/helia.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OA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;wBAED,MAAM,GAAG,CAAA;wBAET,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAM,kBAAkB,EAAE,GAAG,CAAC,CAAC,CAAA;oBAC7E,CAAC;oBAAC,OAAO,GAAQ,EAAE,CAAC;wBAClB,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;wBAC5C,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAQ,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAA;oBAC7E,CAAC;gBACH,CAAC;YACH,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACR,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,CAAA;QACf,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IACzB,CAAC;CACF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,26 +18,10 @@
|
|
|
18
18
|
* fs.cat(CID.parse('bafyFoo'))
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
import {
|
|
22
|
-
import { libp2pDefaults } from './utils/libp2p-defaults.ts';
|
|
23
|
-
import type { DefaultLibp2pServices } from './utils/libp2p-defaults.ts';
|
|
24
|
-
import type { Libp2pDefaultsOptions } from './utils/libp2p.ts';
|
|
21
|
+
import type { HeliaInit } from './helia.ts';
|
|
25
22
|
import type { Helia } from '@helia/interface';
|
|
26
|
-
import type { HeliaInit } from '@helia/utils';
|
|
27
|
-
import type { Libp2p } from '@libp2p/interface';
|
|
28
|
-
import type { CID } from 'multiformats/cid';
|
|
29
23
|
export * from '@helia/interface';
|
|
30
24
|
export type { HeliaInit };
|
|
31
|
-
export type { DefaultLibp2pServices, Libp2pDefaultsOptions };
|
|
32
|
-
export { libp2pDefaults };
|
|
33
|
-
export { heliaDefaults };
|
|
34
|
-
/**
|
|
35
|
-
* DAGWalkers take a block and yield CIDs encoded in that block
|
|
36
|
-
*/
|
|
37
|
-
export interface DAGWalker {
|
|
38
|
-
codec: number;
|
|
39
|
-
walk(block: Uint8Array): Generator<CID, void, undefined>;
|
|
40
|
-
}
|
|
41
25
|
/**
|
|
42
26
|
* Create and return a Helia node
|
|
43
27
|
*
|
|
@@ -59,6 +43,33 @@ export interface DAGWalker {
|
|
|
59
43
|
* }
|
|
60
44
|
* ```
|
|
61
45
|
*/
|
|
62
|
-
export declare function createHelia
|
|
63
|
-
|
|
46
|
+
export declare function createHelia(init?: HeliaInit): Helia;
|
|
47
|
+
/**
|
|
48
|
+
* Create and return a Helia node without and routing or block broker config.
|
|
49
|
+
*
|
|
50
|
+
* The only supported codecs are `dag-pb` and `raw`, and the only supported
|
|
51
|
+
* hashes are `sha2-256` and `identity`.
|
|
52
|
+
*
|
|
53
|
+
* This allows more flexible customization and the smallest possible bundle size
|
|
54
|
+
* in web browsers.
|
|
55
|
+
*
|
|
56
|
+
* @example Creating a Helia node
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { createHeliaLight } from 'helia'
|
|
60
|
+
* import { unixfs } from '@helia/unixfs'
|
|
61
|
+
* import { CID } from 'multiformats/cid'
|
|
62
|
+
*
|
|
63
|
+
* const helia = await createHeliaLight()
|
|
64
|
+
* const fs = unixfs(helia)
|
|
65
|
+
* const cid = CID.parse('QmFoo...')
|
|
66
|
+
*
|
|
67
|
+
* for await (const buf of fs.cat(cid, {
|
|
68
|
+
* signal: AbortSignal.timeout(5_000)
|
|
69
|
+
* })) {
|
|
70
|
+
* console.info(buf)
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function createHeliaLight(init?: HeliaInit): Helia;
|
|
64
75
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAWH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAI7C,cAAc,kBAAkB,CAAA;AAEhC,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAE,IAAI,GAAE,SAAc,GAAG,KAAK,CAcxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,GAAE,SAAc,GAAG,KAAK,CAQ7D"}
|
package/dist/src/index.js
CHANGED
|
@@ -18,21 +18,87 @@
|
|
|
18
18
|
* fs.cat(CID.parse('bafyFoo'))
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
21
|
+
import { withBitswap } from '@helia/bitswap';
|
|
22
|
+
import { withHTTP } from '@helia/http';
|
|
23
|
+
import { withLibp2p } from '@helia/libp2p';
|
|
24
|
+
import * as dagCbor from '@ipld/dag-cbor';
|
|
25
|
+
import * as dagJson from '@ipld/dag-json';
|
|
26
|
+
import * as json from 'multiformats/codecs/json';
|
|
27
|
+
import { sha512 } from 'multiformats/hashes/sha2';
|
|
28
|
+
import { Helia as HeliaClass } from "./helia.js";
|
|
29
|
+
import { name, version } from "./version.js";
|
|
24
30
|
// re-export interface types so people don't have to depend on @helia/interface
|
|
25
31
|
// if they don't want to
|
|
26
32
|
export * from '@helia/interface';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Create and return a Helia node
|
|
35
|
+
*
|
|
36
|
+
* @example Creating a Helia node
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { createHelia } from 'helia'
|
|
40
|
+
* import { unixfs } from '@helia/unixfs'
|
|
41
|
+
* import { CID } from 'multiformats/cid'
|
|
42
|
+
*
|
|
43
|
+
* const helia = await createHelia()
|
|
44
|
+
* const fs = unixfs(helia)
|
|
45
|
+
* const cid = CID.parse('QmFoo...')
|
|
46
|
+
*
|
|
47
|
+
* for await (const buf of fs.cat(cid, {
|
|
48
|
+
* signal: AbortSignal.timeout(5_000)
|
|
49
|
+
* })) {
|
|
50
|
+
* console.info(buf)
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function createHelia(init = {}) {
|
|
55
|
+
return withBitswap(withLibp2p(withHTTP(createHeliaLight({
|
|
56
|
+
...init,
|
|
57
|
+
codecs: [
|
|
58
|
+
dagCbor,
|
|
59
|
+
dagJson,
|
|
60
|
+
json,
|
|
61
|
+
...(init.codecs ?? [])
|
|
62
|
+
],
|
|
63
|
+
hashers: [
|
|
64
|
+
sha512,
|
|
65
|
+
...(init.hashers ?? [])
|
|
66
|
+
]
|
|
67
|
+
}))));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create and return a Helia node without and routing or block broker config.
|
|
71
|
+
*
|
|
72
|
+
* The only supported codecs are `dag-pb` and `raw`, and the only supported
|
|
73
|
+
* hashes are `sha2-256` and `identity`.
|
|
74
|
+
*
|
|
75
|
+
* This allows more flexible customization and the smallest possible bundle size
|
|
76
|
+
* in web browsers.
|
|
77
|
+
*
|
|
78
|
+
* @example Creating a Helia node
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { createHeliaLight } from 'helia'
|
|
82
|
+
* import { unixfs } from '@helia/unixfs'
|
|
83
|
+
* import { CID } from 'multiformats/cid'
|
|
84
|
+
*
|
|
85
|
+
* const helia = await createHeliaLight()
|
|
86
|
+
* const fs = unixfs(helia)
|
|
87
|
+
* const cid = CID.parse('QmFoo...')
|
|
88
|
+
*
|
|
89
|
+
* for await (const buf of fs.cat(cid, {
|
|
90
|
+
* signal: AbortSignal.timeout(5_000)
|
|
91
|
+
* })) {
|
|
92
|
+
* console.info(buf)
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export function createHeliaLight(init = {}) {
|
|
97
|
+
const helia = new HeliaClass({
|
|
98
|
+
name,
|
|
99
|
+
version,
|
|
100
|
+
...init
|
|
101
|
+
});
|
|
36
102
|
return helia;
|
|
37
103
|
}
|
|
38
104
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAI5C,+EAA+E;AAC/E,wBAAwB;AACxB,cAAc,kBAAkB,CAAA;AAIhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAE,OAAkB,EAAE;IAC/C,OAAO,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACtD,GAAG,IAAI;QACP,MAAM,EAAE;YACN,OAAO;YACP,OAAO;YACP,IAAI;YACJ,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;SACvB;QACD,OAAO,EAAE;YACP,MAAM;YACN,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;SACxB;KACF,CAAC,CAAC,CAAC,CAAC,CAAA;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,gBAAgB,CAAE,OAAkB,EAAE;IACpD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC;QAC3B,IAAI;QACJ,OAAO;QACP,GAAG,IAAI;KACR,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Storage } from './storage.ts';
|
|
2
|
+
import type { StorageComponents, StorageInit } from './storage.ts';
|
|
3
|
+
import type { BlockBroker, Blocks, CreateSessionOptions, SessionBlockstore } from '@helia/interface';
|
|
4
|
+
import type { Startable } from '@libp2p/interface';
|
|
5
|
+
import type { AbortOptions } from 'abort-error';
|
|
6
|
+
import type { Blockstore } from 'interface-blockstore';
|
|
7
|
+
import type { CID } from 'multiformats/cid';
|
|
8
|
+
export interface GetOptions extends AbortOptions {
|
|
9
|
+
progress?(evt: Event): void;
|
|
10
|
+
}
|
|
11
|
+
export type NetworkedStorageComponents = StorageComponents<BlockBroker>;
|
|
12
|
+
/**
|
|
13
|
+
* Networked storage wraps a regular blockstore - when getting blocks if the
|
|
14
|
+
* blocks are not present, the configured BlockBrokers will be used to fetch them.
|
|
15
|
+
*/
|
|
16
|
+
export declare class NetworkedStorage extends Storage<BlockBroker> implements Blocks, Startable {
|
|
17
|
+
private started;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new BlockStorage
|
|
20
|
+
*/
|
|
21
|
+
constructor(components: NetworkedStorageComponents, init?: StorageInit);
|
|
22
|
+
isStarted(): boolean;
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
stop(): Promise<void>;
|
|
25
|
+
unwrap(): Blockstore;
|
|
26
|
+
createSession(root: CID, options?: CreateSessionOptions): SessionBlockstore;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=networked-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networked-storage.d.ts","sourceRoot":"","sources":["../../src/networked-storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAA;AAEvE;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,OAAO,CAAC,WAAW,CAAE,YAAW,MAAM,EAAE,SAAS;IACrF,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;gBACU,UAAU,EAAE,0BAA0B,EAAE,IAAI,GAAE,WAAgB;IAM3E,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAKvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAK5B,MAAM,IAAK,UAAU;IAIrB,aAAa,CAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,iBAAiB;CAsB7E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { InvalidConfigurationError } from '@helia/utils';
|
|
2
|
+
import { start, stop } from '@libp2p/interface';
|
|
3
|
+
import { SessionStorage } from "./session-storage.js";
|
|
4
|
+
import { Storage } from "./storage.js";
|
|
5
|
+
/**
|
|
6
|
+
* Networked storage wraps a regular blockstore - when getting blocks if the
|
|
7
|
+
* blocks are not present, the configured BlockBrokers will be used to fetch them.
|
|
8
|
+
*/
|
|
9
|
+
export class NetworkedStorage extends Storage {
|
|
10
|
+
started;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new BlockStorage
|
|
13
|
+
*/
|
|
14
|
+
constructor(components, init = {}) {
|
|
15
|
+
super(components, init);
|
|
16
|
+
this.started = false;
|
|
17
|
+
}
|
|
18
|
+
isStarted() {
|
|
19
|
+
return this.started;
|
|
20
|
+
}
|
|
21
|
+
async start() {
|
|
22
|
+
await start(this.child, ...this.blockBrokers);
|
|
23
|
+
this.started = true;
|
|
24
|
+
}
|
|
25
|
+
async stop() {
|
|
26
|
+
await stop(this.child, ...this.blockBrokers);
|
|
27
|
+
this.started = false;
|
|
28
|
+
}
|
|
29
|
+
unwrap() {
|
|
30
|
+
return this.child;
|
|
31
|
+
}
|
|
32
|
+
createSession(root, options) {
|
|
33
|
+
if (this.blockBrokers.length === 0) {
|
|
34
|
+
throw new InvalidConfigurationError('No block brokers configured');
|
|
35
|
+
}
|
|
36
|
+
const blockBrokers = this.blockBrokers
|
|
37
|
+
.map(broker => broker.createSession?.(options))
|
|
38
|
+
.filter(broker => broker != null);
|
|
39
|
+
if (blockBrokers.length === 0) {
|
|
40
|
+
throw new InvalidConfigurationError(`No configured block brokers support sessions - tried ${this.blockBrokers.map(b => b.name).join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
return new SessionStorage({
|
|
43
|
+
blockstore: this.child,
|
|
44
|
+
blockBrokers,
|
|
45
|
+
getHasher: this.getHasher,
|
|
46
|
+
logger: this.logger
|
|
47
|
+
}, {
|
|
48
|
+
root
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=networked-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networked-storage.js","sourceRoot":"","sources":["../../src/networked-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AActC;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,OAAoB;IAChD,OAAO,CAAS;IAExB;;OAEG;IACH,YAAa,UAAsC,EAAE,OAAoB,EAAE;QACzE,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAEvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,aAAa,CAAE,IAAS,EAAE,OAA8B;QACtD,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,yBAAyB,CAAC,6BAA6B,CAAC,CAAA;QACpE,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY;aACnC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,CAAC;aAC9C,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,IAAI,CAAC,CAAA;QAEnC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,yBAAyB,CAAC,wDAAwD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9I,CAAC;QAED,OAAO,IAAI,cAAc,CAAC;YACxB,UAAU,EAAE,IAAI,CAAC,KAAK;YACtB,YAAY;YACZ,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,EAAE;YACD,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import type { CodecLoader } from '@helia/interface';
|
|
3
|
+
import type { AddOptions, IsPinnedOptions, LsOptions, Pin, Pins, RmOptions } from '@helia/interface';
|
|
4
|
+
import type { AbortOptions } from '@libp2p/interface';
|
|
5
|
+
import type { Blockstore } from 'interface-blockstore';
|
|
6
|
+
import type { Datastore } from 'interface-datastore';
|
|
7
|
+
import type { Version } from 'multiformats/cid';
|
|
8
|
+
export declare class PinsImpl implements Pins {
|
|
9
|
+
#private;
|
|
10
|
+
private readonly datastore;
|
|
11
|
+
private readonly blockstore;
|
|
12
|
+
private readonly getCodec;
|
|
13
|
+
constructor(datastore: Datastore, blockstore: Blockstore, getCodec: CodecLoader);
|
|
14
|
+
add(cid: CID<unknown, number, number, Version>, options?: AddOptions): AsyncGenerator<CID, void, undefined>;
|
|
15
|
+
rm(cid: CID<unknown, number, number, Version>, options?: RmOptions): AsyncGenerator<CID, void, undefined>;
|
|
16
|
+
ls(options?: LsOptions): AsyncGenerator<Pin, void, undefined>;
|
|
17
|
+
isPinned(cid: CID, options?: IsPinnedOptions): Promise<boolean>;
|
|
18
|
+
get(cid: CID, options?: AbortOptions): Promise<Pin>;
|
|
19
|
+
setMetadata(cid: CID, metadata: Record<string, string | number | boolean> | undefined, options?: AbortOptions): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=pins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA0C/C,qBAAa,QAAS,YAAW,IAAI;;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;gBAEzB,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW;IAMxE,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;IA8EhH,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;IA2B9G,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;IAMpE,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAOpD,WAAW,CAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CASrI"}
|
package/dist/src/pins.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AlreadyPinnedError, depthFirstWalker } from '@helia/utils';
|
|
2
|
+
import { InvalidParametersError } from '@libp2p/interface';
|
|
3
|
+
import * as cborg from 'cborg';
|
|
4
|
+
import { Key } from 'interface-datastore';
|
|
5
|
+
import { base36 } from 'multiformats/bases/base36';
|
|
6
|
+
import { CID } from 'multiformats/cid';
|
|
7
|
+
import { CustomProgressEvent } from 'progress-events';
|
|
8
|
+
import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
|
|
9
|
+
const DATASTORE_PIN_PREFIX = '/pin/';
|
|
10
|
+
const DATASTORE_BLOCK_PREFIX = '/pinned-block/';
|
|
11
|
+
const DATASTORE_ENCODING = base36;
|
|
12
|
+
function toDSKey(cid) {
|
|
13
|
+
if (cid.version === 0) {
|
|
14
|
+
cid = cid.toV1();
|
|
15
|
+
}
|
|
16
|
+
return new Key(`${DATASTORE_PIN_PREFIX}${cid.toString(DATASTORE_ENCODING)}`);
|
|
17
|
+
}
|
|
18
|
+
export class PinsImpl {
|
|
19
|
+
datastore;
|
|
20
|
+
blockstore;
|
|
21
|
+
getCodec;
|
|
22
|
+
constructor(datastore, blockstore, getCodec) {
|
|
23
|
+
this.datastore = datastore;
|
|
24
|
+
this.blockstore = blockstore;
|
|
25
|
+
this.getCodec = getCodec;
|
|
26
|
+
}
|
|
27
|
+
async *add(cid, options = {}) {
|
|
28
|
+
const pinKey = toDSKey(cid);
|
|
29
|
+
if (await this.datastore.has(pinKey)) {
|
|
30
|
+
throw new AlreadyPinnedError('Already pinned');
|
|
31
|
+
}
|
|
32
|
+
const depth = Math.round(options.depth ?? Infinity);
|
|
33
|
+
if (depth < 0) {
|
|
34
|
+
throw new InvalidParametersError('Depth must be greater than or equal to 0');
|
|
35
|
+
}
|
|
36
|
+
const walker = (options.walker ?? depthFirstWalker())({
|
|
37
|
+
blockstore: this.blockstore,
|
|
38
|
+
getCodec: this.getCodec
|
|
39
|
+
});
|
|
40
|
+
for await (const node of walker.walk(cid, { ...options, depth })) {
|
|
41
|
+
const childCid = node.block.cid;
|
|
42
|
+
await this.#updatePinnedBlock(childCid, (pinnedBlock) => {
|
|
43
|
+
// do not update pinned block if this block is already pinned by this CID
|
|
44
|
+
if (pinnedBlock.pinnedBy.find(c => uint8ArrayEquals(c, cid.bytes)) != null) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
pinnedBlock.pinCount++;
|
|
48
|
+
pinnedBlock.pinnedBy.push(cid.bytes);
|
|
49
|
+
return true;
|
|
50
|
+
}, options);
|
|
51
|
+
yield childCid;
|
|
52
|
+
}
|
|
53
|
+
const pin = {
|
|
54
|
+
depth,
|
|
55
|
+
metadata: options.metadata ?? {}
|
|
56
|
+
};
|
|
57
|
+
await this.datastore.put(pinKey, cborg.encode(pin), options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Update the pin count for the CID
|
|
61
|
+
*/
|
|
62
|
+
async #updatePinnedBlock(cid, withPinnedBlock, options) {
|
|
63
|
+
const blockKey = new Key(`${DATASTORE_BLOCK_PREFIX}${DATASTORE_ENCODING.encode(cid.multihash.bytes)}`);
|
|
64
|
+
let pinnedBlock = {
|
|
65
|
+
pinCount: 0,
|
|
66
|
+
pinnedBy: []
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
pinnedBlock = cborg.decode(await this.datastore.get(blockKey, options));
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (err.name !== 'NotFoundError') {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const shouldContinue = withPinnedBlock(pinnedBlock);
|
|
77
|
+
if (!shouldContinue) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (pinnedBlock.pinCount === 0) {
|
|
81
|
+
if (await this.datastore.has(blockKey)) {
|
|
82
|
+
await this.datastore.delete(blockKey);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
await this.datastore.put(blockKey, cborg.encode(pinnedBlock), options);
|
|
87
|
+
options.onProgress?.(new CustomProgressEvent('helia:pin:add', cid));
|
|
88
|
+
}
|
|
89
|
+
async *rm(cid, options = {}) {
|
|
90
|
+
const pinKey = toDSKey(cid);
|
|
91
|
+
const buf = await this.datastore.get(pinKey, options);
|
|
92
|
+
const pin = cborg.decode(buf);
|
|
93
|
+
await this.datastore.delete(pinKey, options);
|
|
94
|
+
const walker = (options.walker ?? depthFirstWalker())({
|
|
95
|
+
blockstore: this.blockstore,
|
|
96
|
+
getCodec: this.getCodec
|
|
97
|
+
});
|
|
98
|
+
for await (const node of walker.walk(cid, { ...options, depth: pin.depth })) {
|
|
99
|
+
const childCid = node.block.cid;
|
|
100
|
+
await this.#updatePinnedBlock(childCid, (pinnedBlock) => {
|
|
101
|
+
pinnedBlock.pinCount--;
|
|
102
|
+
pinnedBlock.pinnedBy = pinnedBlock.pinnedBy.filter(c => uint8ArrayEquals(c, cid.bytes));
|
|
103
|
+
return true;
|
|
104
|
+
}, {
|
|
105
|
+
...options,
|
|
106
|
+
depth: pin.depth
|
|
107
|
+
});
|
|
108
|
+
yield childCid;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async *ls(options = {}) {
|
|
112
|
+
for await (const { key, value } of this.datastore.query({
|
|
113
|
+
prefix: DATASTORE_PIN_PREFIX + (options.cid != null ? `${options.cid.toString(base36)}` : '')
|
|
114
|
+
}, options)) {
|
|
115
|
+
const cid = CID.parse(key.toString().substring(5), base36);
|
|
116
|
+
const pin = cborg.decode(value);
|
|
117
|
+
yield {
|
|
118
|
+
cid,
|
|
119
|
+
...pin
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async isPinned(cid, options = {}) {
|
|
124
|
+
const blockKey = new Key(`${DATASTORE_BLOCK_PREFIX}${DATASTORE_ENCODING.encode(cid.multihash.bytes)}`);
|
|
125
|
+
return this.datastore.has(blockKey, options);
|
|
126
|
+
}
|
|
127
|
+
async get(cid, options) {
|
|
128
|
+
const pinKey = toDSKey(cid);
|
|
129
|
+
const buf = await this.datastore.get(pinKey, options);
|
|
130
|
+
return cborg.decode(buf);
|
|
131
|
+
}
|
|
132
|
+
async setMetadata(cid, metadata, options) {
|
|
133
|
+
const pinKey = toDSKey(cid);
|
|
134
|
+
const buf = await this.datastore.get(pinKey, options);
|
|
135
|
+
const pin = cborg.decode(buf);
|
|
136
|
+
pin.metadata = metadata ?? {};
|
|
137
|
+
await this.datastore.put(pinKey, cborg.encode(pin), options);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=pins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.js","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAoC/D,MAAM,oBAAoB,GAAG,OAAO,CAAA;AACpC,MAAM,sBAAsB,GAAG,gBAAgB,CAAA;AAC/C,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC,SAAS,OAAO,CAAE,GAAQ;IACxB,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACtB,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC;IAED,OAAO,IAAI,GAAG,CAAC,GAAG,oBAAoB,GAAG,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;AAC9E,CAAC;AAED,MAAM,OAAO,QAAQ;IACF,SAAS,CAAW;IACpB,UAAU,CAAY;IACtB,QAAQ,CAAa;IAEtC,YAAa,SAAoB,EAAE,UAAsB,EAAE,QAAqB;QAC9E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC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