@helia/utils 2.5.0 → 2.5.1-35b081c7

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/src/storage.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { start, stop } from '@libp2p/interface'
2
2
  import createMortice from 'mortice'
3
3
  import { BlockPinnedError } from './errors.ts'
4
+ import type { Routing } from '@helia/interface'
4
5
  import type { Blocks, Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions, SessionBlockstore } from '@helia/interface/blocks'
5
6
  import type { Pins } from '@helia/interface/pins'
6
7
  import type { AbortOptions, Startable } from '@libp2p/interface'
@@ -27,14 +28,16 @@ export class BlockStorage implements Blocks, Startable {
27
28
  public lock: Mortice
28
29
  private readonly child: Blocks
29
30
  private readonly pins: Pins
31
+ private readonly routing: Routing
30
32
  private started: boolean
31
33
 
32
34
  /**
33
35
  * Create a new BlockStorage
34
36
  */
35
- constructor (blockstore: Blocks, pins: Pins, options: BlockStorageInit = {}) {
37
+ constructor (blockstore: Blocks, pins: Pins, routing: Routing, options: BlockStorageInit = {}) {
36
38
  this.child = blockstore
37
39
  this.pins = pins
40
+ this.routing = routing
38
41
  this.lock = createMortice({
39
42
  singleProcess: options.holdGcLock
40
43
  })
@@ -127,6 +130,9 @@ export class BlockStorage implements Blocks, Startable {
127
130
  throw new BlockPinnedError('Block was pinned - please unpin and try again')
128
131
  }
129
132
 
133
+ // stop re-providing this CID if necessary
134
+ await this.routing.cancelReprovide(cid, options)
135
+
130
136
  await this.child.delete(cid, options)
131
137
  } finally {
132
138
  releaseLock()
@@ -149,6 +155,9 @@ export class BlockStorage implements Blocks, Startable {
149
155
  throw new BlockPinnedError('Block was pinned - please unpin and try again')
150
156
  }
151
157
 
158
+ // stop re-providing this CID if necessary
159
+ await storage.routing.cancelReprovide(cid, options)
160
+
152
161
  yield cid
153
162
  }
154
163
  }()), options)
@@ -1,19 +0,0 @@
1
- {
2
- "GraphWalker": "https://ipfs.github.io/helia/interfaces/_helia_car.GraphWalker.html",
3
- "breadthFirstWalker": "https://ipfs.github.io/helia/functions/_helia_car.breadthFirstWalker.html",
4
- "depthFirstWalker": "https://ipfs.github.io/helia/functions/_helia_car.depthFirstWalker.html",
5
- "naturalOrderWalker": "https://ipfs.github.io/helia/functions/_helia_car.naturalOrderWalker.html",
6
- "AbstractSession": "https://ipfs.github.io/helia/classes/_helia_utils.AbstractSession.html",
7
- "Helia": "https://ipfs.github.io/helia/classes/_helia_utils.Helia.html",
8
- ".:Helia": "https://ipfs.github.io/helia/classes/_helia_utils.Helia.html",
9
- "AbstractCreateSessionOptions": "https://ipfs.github.io/helia/interfaces/_helia_utils.AbstractCreateSessionOptions.html",
10
- "AbstractSessionComponents": "https://ipfs.github.io/helia/interfaces/_helia_utils.AbstractSessionComponents.html",
11
- "BlockStorage": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockStorage.html",
12
- "BlockStorageInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockStorageInit.html",
13
- "BlockstoreSessionEvents": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockstoreSessionEvents.html",
14
- "GraphNode": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphNode.html",
15
- "GraphWalkerComponents": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphWalkerComponents.html",
16
- "GraphWalkerInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphWalkerInit.html",
17
- "HeliaInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.HeliaInit.html",
18
- ".:HeliaInit": "https://ipfs.github.io/helia/interfaces/helia.HeliaInit.html"
19
- }