forked from ipfs/helia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpins.ts
63 lines (49 loc) · 1.56 KB
/
pins.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { GetBlockProgressEvents } from './blocks'
import type { AbortOptions } from '@libp2p/interface'
import type { CID } from 'multiformats/cid'
import type { ProgressEvent, ProgressOptions } from 'progress-events'
export type PinType = 'recursive' | 'direct' | 'indirect'
export interface Pin {
cid: CID
depth: number
metadata: Record<string, any>
}
export type AddPinEvents =
ProgressEvent<'helia:pin:add', CID>
export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents | GetBlockProgressEvents> {
/**
* How deeply to pin the DAG, defaults to Infinity
*/
depth?: number
/**
* Optional user-defined metadata to store with the pin
*/
metadata?: Record<string, string | number | boolean>
}
export interface RmOptions extends AbortOptions {
}
export interface LsOptions extends AbortOptions {
cid?: CID
}
export interface IsPinnedOptions extends AbortOptions {
}
export interface Pins {
/**
* Pin a block in the blockstore. It will not be deleted
* when garbage collection is run.
*/
add(cid: CID, options?: AddOptions): AsyncGenerator<CID, void, undefined>
/**
* Unpin the block that corresponds to the passed CID. The block will
* be deleted when garbage collection is run.
*/
rm(cid: CID, options?: RmOptions): AsyncGenerator<CID, void, undefined>
/**
* List all blocks that have been pinned.
*/
ls(options?: LsOptions): AsyncGenerator<Pin, void, undefined>
/**
* Return true if the passed CID is pinned
*/
isPinned(cid: CID, options?: IsPinnedOptions): Promise<boolean>
}