Skip to content

Commit 1868cac

Browse files
deps(dev): bump aegir from 38.1.8 to 39.0.7 (#576)
* deps(dev): bump aegir from 38.1.8 to 39.0.7 Bumps [aegir](https://github.com/ipfs/aegir) from 38.1.8 to 39.0.7. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](ipfs/aegir@v38.1.8...v39.0.7) --- updated-dependencies: - dependency-name: aegir dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore: fix linting and deps * chore: linting again --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain <[email protected]>
1 parent 9a8bbf7 commit 1868cac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+188
-213
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
node_modules
2+
build
23
dist
34
.docs
45
.coverage
6+
node_modules
57
package-lock.json
68
yarn.lock
9+
.vscode

benchmarks/put-get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint max-nested-callbacks: ["error", 5] */
22
/* eslint-disable no-console */
33

4-
import Benchmark from 'benchmark'
54
import assert from 'assert'
5+
import Benchmark from 'benchmark'
66
import all from 'it-all'
77
import drain from 'it-drain'
88
import { makeBlocks } from '../test/utils/make-blocks.js'

package.json

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,8 @@
1717
"libp2p",
1818
"p2p"
1919
],
20-
"engines": {
21-
"node": ">=16.0.0",
22-
"npm": ">=7.0.0"
23-
},
2420
"type": "module",
2521
"types": "./dist/src/index.d.ts",
26-
"typesVersions": {
27-
"*": {
28-
"*": [
29-
"*",
30-
"dist/*",
31-
"dist/src/*",
32-
"dist/src/*/index"
33-
],
34-
"src/*": [
35-
"*",
36-
"dist/*",
37-
"dist/src/*",
38-
"dist/src/*/index"
39-
]
40-
}
41-
},
4222
"files": [
4323
"src",
4424
"dist",
@@ -177,7 +157,6 @@
177157
"abortable-iterator": "^4.0.2",
178158
"any-signal": "^3.0.0",
179159
"blockstore-core": "^4.0.0",
180-
"events": "^3.3.0",
181160
"interface-blockstore": "^5.0.0",
182161
"interface-store": "^5.1.0",
183162
"it-foreach": "^2.0.2",
@@ -203,9 +182,13 @@
203182
"@libp2p/peer-id-factory": "^2.0.0",
204183
"@libp2p/tcp": "^6.0.0",
205184
"@nodeutils/defaults-deep": "^1.1.0",
185+
"@types/lodash.difference": "^4.5.7",
186+
"@types/lodash.flatten": "^4.4.7",
187+
"@types/lodash.range": "^3.2.7",
188+
"@types/sinon": "^10.0.15",
206189
"@types/stats-lite": "^2.2.0",
207190
"@types/varint": "^6.0.0",
208-
"aegir": "^38.1.0",
191+
"aegir": "^39.0.7",
209192
"benchmark": "^2.1.4",
210193
"delay": "^5.0.0",
211194
"iso-random-stream": "^2.0.0",

src/bitswap.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { WantManager } from './want-manager/index.js'
1+
import { anySignal } from 'any-signal'
2+
import forEach from 'it-foreach'
3+
import { CID } from 'multiformats/cid'
4+
import { DecisionEngine, type PeerLedger } from './decision-engine/index.js'
25
import { Network } from './network.js'
3-
import { DecisionEngine, PeerLedger } from './decision-engine/index.js'
46
import { Notifications } from './notifications.js'
5-
import { logger } from './utils/index.js'
67
import { Stats } from './stats/index.js'
7-
import { anySignal } from 'any-signal'
8-
import { CID } from 'multiformats/cid'
9-
import forEach from 'it-foreach'
8+
import { logger } from './utils/index.js'
9+
import { WantManager } from './want-manager/index.js'
1010
import type { BitswapOptions, Bitswap, MultihashHasherLoader, WantListEntry, BitswapWantProgressEvents, BitswapNotifyProgressEvents } from './index.js'
11+
import type { BitswapMessage } from './message/index.js'
1112
import type { Libp2p } from '@libp2p/interface-libp2p'
12-
import type { Blockstore, Pair } from 'interface-blockstore'
13-
import type { Logger } from '@libp2p/logger'
1413
import type { PeerId } from '@libp2p/interface-peer-id'
15-
import type { BitswapMessage } from './message/index.js'
14+
import type { Logger } from '@libp2p/logger'
1615
import type { AbortOptions } from '@multiformats/multiaddr'
17-
import type { ProgressOptions } from 'progress-events'
16+
import type { Blockstore, Pair } from 'interface-blockstore'
1817
import type { AwaitIterable } from 'interface-store'
18+
import type { ProgressOptions } from 'progress-events'
1919

2020
const hashLoader: MultihashHasherLoader = {
2121
async getHasher () {
@@ -225,7 +225,7 @@ export class DefaultBitswap implements Bitswap {
225225
// so no need to remove the blocks from the wantlist after we have it
226226
this.wm.wantBlocks([cid], options)
227227

228-
return await this.notifications.wantBlock(cid, options)
228+
return this.notifications.wantBlock(cid, options)
229229
}
230230

231231
let promptedNetwork = false

src/decision-engine/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { CID } from 'multiformats/cid'
1+
import { trackedMap } from '@libp2p/tracked-map'
22
import { base58btc } from 'multiformats/bases/base58'
3+
import { CID } from 'multiformats/cid'
34
import { BitswapMessage as Message } from '../message/index.js'
5+
import { logger } from '../utils/index.js'
46
import { Wantlist } from '../wantlist/index.js'
57
import { Ledger } from './ledger.js'
68
import { RequestQueue } from './req-queue.js'
79
import { DefaultTaskMerger } from './task-merger.js'
8-
import { logger } from '../utils/index.js'
9-
import { trackedMap } from '@libp2p/tracked-map'
10-
import type { Message as PBMessage } from '../message/message.js'
1110
import type { BitswapMessageEntry } from '../message/entry.js'
12-
import type { PeerId } from '@libp2p/interface-peer-id'
13-
import type { Blockstore } from 'interface-blockstore'
11+
import type { Message as PBMessage } from '../message/message.js'
1412
import type { Network } from '../network.js'
1513
import type { Stats } from '../stats/index.js'
14+
import type { WantListEntry } from '../wantlist/entry.js'
1615
import type { Libp2p } from '@libp2p/interface-libp2p'
16+
import type { PeerId } from '@libp2p/interface-peer-id'
1717
import type { Logger } from '@libp2p/logger'
18-
import type { WantListEntry } from '../wantlist/entry.js'
18+
import type { Blockstore } from 'interface-blockstore'
1919

2020
export interface TaskMerger {
2121
/**

src/decision-engine/ledger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { PeerId } from '@libp2p/interface-peer-id'
2-
import type { CID } from 'multiformats/cid'
1+
import { Wantlist } from '../wantlist/index.js'
32
import type { Message } from '../message/message.js'
43
import type { WantListEntry } from '../wantlist/entry.js'
5-
import { Wantlist } from '../wantlist/index.js'
4+
import type { PeerId } from '@libp2p/interface-peer-id'
5+
import type { CID } from 'multiformats/cid'
66

77
export class Ledger {
88
public partner: PeerId

src/decision-engine/req-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { PeerId } from '@libp2p/interface-peer-id'
21
import { SortedMap } from '../utils/sorted-map.js'
32
import type { Task, TaskMerger } from './index.js'
3+
import type { PeerId } from '@libp2p/interface-peer-id'
44

55
export interface PopTaskResult {
66
peerId?: PeerId

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { DefaultBitswap } from './bitswap.js'
2-
import type { Blockstore } from 'interface-blockstore'
3-
import type { PeerId } from '@libp2p/interface-peer-id'
4-
import type { CID } from 'multiformats/cid'
52
import type { Message } from './message/message'
6-
import type { IMovingAverage } from '@vascosantos/moving-average'
7-
import type { MultihashHasher } from 'multiformats/hashes/interface'
3+
import type { BitswapNetworkNotifyProgressEvents, BitswapNetworkWantProgressEvents } from './network.js'
84
import type { Libp2p } from '@libp2p/interface-libp2p'
5+
import type { PeerId } from '@libp2p/interface-peer-id'
96
import type { AbortOptions } from '@libp2p/interfaces'
107
import type { Startable } from '@libp2p/interfaces/startable'
8+
import type { IMovingAverage } from '@vascosantos/moving-average'
9+
import type { Blockstore } from 'interface-blockstore'
10+
import type { CID } from 'multiformats/cid'
11+
import type { MultihashHasher } from 'multiformats/hashes/interface'
1112
import type { ProgressEvent, ProgressOptions } from 'progress-events'
12-
import type { BitswapNetworkNotifyProgressEvents, BitswapNetworkWantProgressEvents } from './network.js'
1313

1414
export interface WantListEntry {
1515
cid: CID

src/message/entry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { base58btc } from 'multiformats/bases/base58'
2-
import type { CID } from 'multiformats/cid'
3-
import type { Message } from './message.js'
42
import { WantListEntry } from '../wantlist/entry.js'
3+
import type { Message } from './message.js'
4+
import type { CID } from 'multiformats/cid'
55

66
export class BitswapMessageEntry {
77
public entry: WantListEntry

src/message/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { CodeError } from '@libp2p/interfaces/errors'
2+
import { base58btc } from 'multiformats/bases/base58'
13
import { CID } from 'multiformats/cid'
24
import { sha256 } from 'multiformats/hashes/sha2'
3-
import { base58btc } from 'multiformats/bases/base58'
45
// @ts-expect-error no types
56
import vd from 'varint-decoder'
6-
import ve from '../utils/varint-encoder.js'
77
import { isMapEqual } from '../utils/index.js'
8-
import { Message } from './message.js'
8+
import ve from '../utils/varint-encoder.js'
99
import { BitswapMessageEntry as Entry } from './entry.js'
10-
import { CodeError } from '@libp2p/interfaces/errors'
10+
import { Message } from './message.js'
1111
import type { MultihashHasherLoader } from '../index.js'
1212

1313
export class BitswapMessage {

src/network.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1+
import { createTopology } from '@libp2p/topology'
2+
import { abortableSource } from 'abortable-iterator'
3+
import drain from 'it-drain'
14
import * as lp from 'it-length-prefixed'
5+
import map from 'it-map'
26
import { pipe } from 'it-pipe'
3-
import { createTopology } from '@libp2p/topology'
4-
import { BitswapMessage as Message } from './message/index.js'
7+
import take from 'it-take'
8+
import { type ProgressEvent, CustomProgressEvent, type ProgressOptions } from 'progress-events'
9+
import { TimeoutController } from 'timeout-abort-controller'
510
import * as CONSTANTS from './constants.js'
11+
import { BitswapMessage as Message } from './message/index.js'
612
import { logger } from './utils/index.js'
7-
import { TimeoutController } from 'timeout-abort-controller'
8-
import { abortableSource } from 'abortable-iterator'
9-
import type { Libp2p } from '@libp2p/interface-libp2p'
10-
import type { PeerId } from '@libp2p/interface-peer-id'
11-
import type { Multiaddr } from '@multiformats/multiaddr'
12-
import type { MultihashHasherLoader } from './index.js'
1313
import type { DefaultBitswap } from './bitswap.js'
14+
import type { MultihashHasherLoader } from './index.js'
1415
import type { Stats } from './stats/index.js'
15-
import type { Logger } from '@libp2p/logger'
16-
import type { IncomingStreamData } from '@libp2p/interface-registrar'
17-
import type { CID } from 'multiformats/cid'
18-
import type { AbortOptions } from '@libp2p/interfaces'
1916
import type { Connection } from '@libp2p/interface-connection'
17+
import type { Libp2p } from '@libp2p/interface-libp2p'
18+
import type { PeerId } from '@libp2p/interface-peer-id'
2019
import type { PeerInfo } from '@libp2p/interface-peer-info'
21-
import { ProgressEvent, CustomProgressEvent, ProgressOptions } from 'progress-events'
22-
import take from 'it-take'
23-
import drain from 'it-drain'
24-
import map from 'it-map'
20+
import type { IncomingStreamData } from '@libp2p/interface-registrar'
21+
import type { AbortOptions } from '@libp2p/interfaces'
22+
import type { Logger } from '@libp2p/logger'
23+
import type { Multiaddr } from '@multiformats/multiaddr'
24+
import type { CID } from 'multiformats/cid'
2525

2626
export interface Provider {
2727
id: PeerId
@@ -206,7 +206,7 @@ export class Network {
206206
async findAndConnect (cid: CID, options?: AbortOptions & ProgressOptions<BitswapNetworkWantProgressEvents>): Promise<void> {
207207
await drain(
208208
take(
209-
map(this.findProviders(cid, options), async provider => await this.connectTo(provider.id, options)
209+
map(this.findProviders(cid, options), async provider => this.connectTo(provider.id, options)
210210
.catch(err => {
211211
// Prevent unhandled promise rejection
212212
this._log.error(err)
@@ -252,7 +252,8 @@ export class Network {
252252
}
253253

254254
options.onProgress?.(new CustomProgressEvent<PeerId>('bitswap:network:dial', peer))
255-
return await this._libp2p.dial(peer, options)
255+
// @ts-expect-error types are not aligned
256+
return this._libp2p.dial(peer, options)
256257
}
257258

258259
_updateSentStats (peer: PeerId, blocks: Map<string, Uint8Array>): void {

src/notifications.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { PeerId } from '@libp2p/interface-peer-id'
2-
import type { AbortOptions } from '@libp2p/interfaces'
3-
import type { Logger } from '@libp2p/logger'
41
import { EventEmitter } from 'events'
5-
import type { CID } from 'multiformats/cid'
6-
import { CustomProgressEvent, ProgressOptions } from 'progress-events'
2+
import { CustomProgressEvent, type ProgressOptions } from 'progress-events'
73
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
84
import * as CONSTANTS from './constants.js'
9-
import type { BitswapWantBlockProgressEvents } from './index.js'
105
import { logger } from './utils/index.js'
6+
import type { BitswapWantBlockProgressEvents } from './index.js'
7+
import type { PeerId } from '@libp2p/interface-peer-id'
8+
import type { AbortOptions } from '@libp2p/interfaces'
9+
import type { Logger } from '@libp2p/logger'
10+
import type { CID } from 'multiformats/cid'
1111

1212
const unwantEvent = (cid: CID): string => `unwant:${uint8ArrayToString(cid.multihash.bytes, 'base64')}`
1313

@@ -53,7 +53,7 @@ export class Notifications extends EventEmitter {
5353

5454
this._log(`wantBlock:${cid}`)
5555

56-
return await new Promise((resolve, reject) => {
56+
return new Promise((resolve, reject) => {
5757
const onUnwant = (): void => {
5858
this.removeListener(blockEvt, onBlock)
5959

src/stats/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { EventEmitter } from 'events'
2-
import { Stat } from './stat.js'
32
import { trackedMap } from '@libp2p/tracked-map'
4-
import type { Libp2p } from 'libp2p'
3+
import { Stat } from './stat.js'
54
import type { PeerId } from '@libp2p/interface-peer-id'
65
import type { IMovingAverage } from '@vascosantos/moving-average'
6+
import type { Libp2p } from 'libp2p'
77

88
/**
99
* @typedef {import('multiformats').CID} CID

src/stats/stat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter } from 'events'
2-
import MovingAverage, { IMovingAverage } from '@vascosantos/moving-average'
2+
import MovingAverage, { type IMovingAverage } from '@vascosantos/moving-average'
33

44
export type Op = [string, number, number]
55

src/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { PeerId } from '@libp2p/interface-peer-id'
2-
import { logger as createLogger, Logger } from '@libp2p/logger'
1+
import { logger as createLogger, type Logger } from '@libp2p/logger'
32
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
43
import { BitswapMessageEntry } from '../message/entry.js'
4+
import type { PeerId } from '@libp2p/interface-peer-id'
55

66
/**
77
* Creates a logger for the given subsystem

src/want-manager/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

2+
import { trackedMap } from '@libp2p/tracked-map'
3+
import { base58btc } from 'multiformats/bases/base58'
4+
import * as CONSTANTS from '../constants.js'
25
import { BitswapMessage as Message } from '../message/index.js'
6+
import { logger } from '../utils/index.js'
37
import { Wantlist } from '../wantlist/index.js'
4-
import * as CONSTANTS from '../constants.js'
58
import { MsgQueue } from './msg-queue.js'
6-
import { logger } from '../utils/index.js'
7-
import { base58btc } from 'multiformats/bases/base58'
8-
import { trackedMap } from '@libp2p/tracked-map'
9-
import type { PeerId } from '@libp2p/interface-peer-id'
9+
import type { BitswapWantBlockProgressEvents } from '../index.js'
1010
import type { Network } from '../network.js'
1111
import type { Stats } from '../stats/index.js'
1212
import type { Libp2p } from '@libp2p/interface-libp2p'
13+
import type { PeerId } from '@libp2p/interface-peer-id'
1314
import type { Logger } from '@libp2p/logger'
14-
import type { CID } from 'multiformats/cid'
1515
import type { AbortOptions } from '@multiformats/multiaddr'
16+
import type { CID } from 'multiformats/cid'
1617
import type { ProgressOptions } from 'progress-events'
17-
import type { BitswapWantBlockProgressEvents } from '../index.js'
1818

1919
export class WantManager {
2020
private readonly peers: Map<string, MsgQueue>

src/want-manager/msg-queue.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import debounce from 'just-debounce-it'
2+
import { wantlistSendDebounceMs } from '../constants.js'
23
import { BitswapMessage as Message } from '../message/index.js'
34
import { logger } from '../utils/index.js'
4-
import { wantlistSendDebounceMs } from '../constants.js'
5-
import type { PeerId } from '@libp2p/interface-peer-id'
5+
import type { BitswapWantBlockProgressEvents } from '../index.js'
66
import type { BitswapNetworkWantProgressEvents, Network } from '../network.js'
7-
import type { CID } from 'multiformats/cid'
7+
import type { PeerId } from '@libp2p/interface-peer-id'
88
import type { Logger } from '@libp2p/logger'
9+
import type { CID } from 'multiformats/cid'
910
import type { ProgressOptions } from 'progress-events'
10-
import type { BitswapWantBlockProgressEvents } from '../index.js'
1111

1212
export class MsgQueue {
1313
public peerId: PeerId

src/wantlist/entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import { base58btc } from 'multiformats/bases/base58'
3-
import type { CID } from 'multiformats/cid'
43
import type { Message } from '../message/message'
4+
import type { CID } from 'multiformats/cid'
55

66
export class WantListEntry {
77
private _refCounter: number

src/wantlist/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
import { WantListEntry as Entry } from './entry.js'
2+
import { trackedMap } from '@libp2p/tracked-map'
33
import { base58btc } from 'multiformats/bases/base58'
44
import { Message } from '../message/message.js'
5-
import { trackedMap } from '@libp2p/tracked-map'
5+
import { WantListEntry as Entry } from './entry.js'
66
import type { Stats } from '../stats/index.js'
77
import type { Libp2p } from '@libp2p/interface-libp2p'
88
import type { CID } from 'multiformats/cid'

0 commit comments

Comments
 (0)