diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml
index 2c7a14bb..2e3db88e 100644
--- a/.github/workflows/js-test-and-release.yml
+++ b/.github/workflows/js-test-and-release.yml
@@ -3,7 +3,7 @@ name: test & maybe release
on:
push:
branches:
- - master
+ - main
pull_request:
workflow_dispatch:
@@ -16,10 +16,189 @@ concurrency:
cancel-in-progress: true
jobs:
- js-test-and-release:
- uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0
- secrets:
- DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
- DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
+ check:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present lint
+ - run: npm run --if-present dep-check
+ - run: npm run --if-present doc-check
+
+ test-node:
+ needs: check
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [windows-latest, ubuntu-latest, macos-latest]
+ node: [lts/*]
+ fail-fast: true
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node }}
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:node
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: node
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-chrome:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:chrome
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: chrome
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-chrome-webworker:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:chrome-webworker
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: chrome-webworker
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-firefox:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:firefox
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: firefox
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-firefox-webworker:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:firefox-webworker
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: firefox-webworker
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-webkit:
+ needs: check
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ node: [lts/*]
+ fail-fast: true
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:webkit
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: webkit
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-webkit-webworker:
+ needs: check
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ node: [lts/*]
+ fail-fast: true
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npm run --if-present test:webkit-webworker
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: webkit-webworker
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-electron-main:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npx xvfb-maybe npm run --if-present test:electron-main
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: electron-main
+ files: .coverage/*,packages/*/.coverage/*
+
+ test-electron-renderer:
+ needs: check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - run: npx xvfb-maybe npm run --if-present test:electron-renderer
+ - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
+ with:
+ flags: electron-renderer
+ files: .coverage/*,packages/*/.coverage/*
+
+ release:
+ needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer]
+ runs-on: ubuntu-latest
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
+ permissions:
+ id-token: write
+ contents: write
+ pull-requests: write
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-node@v3
+ with:
+ node-version: lts/*
+ - uses: ipfs/aegir/actions/cache-node-modules@master
+ - uses: ipfs/aegir/actions/docker-login@master
+ with:
+ docker-token: ${{ secrets.DOCKER_TOKEN }}
+ docker-username: ${{ secrets.DOCKER_USERNAME }}
+ - run: npm run --if-present release
+ env:
+ GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml
new file mode 100644
index 00000000..bd00f090
--- /dev/null
+++ b/.github/workflows/semantic-pull-request.yml
@@ -0,0 +1,12 @@
+name: Semantic PR
+
+on:
+ pull_request_target:
+ types:
+ - opened
+ - edited
+ - synchronize
+
+jobs:
+ main:
+ uses: pl-strflt/.github/.github/workflows/reusable-semantic-pull-request.yml@v0.3
diff --git a/README.md b/README.md
index f0eaf182..7edf816d 100644
--- a/README.md
+++ b/README.md
@@ -1,33 +1,17 @@
-# ipfs-bitswap
-
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-bitswap.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-bitswap)
-[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-bitswap/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
+[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-bitswap/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> JavaScript implementation of the Bitswap data exchange protocol used by IPFS
-## Table of contents
-
-- [Install](#install)
- - [Browser `
```
-## Stats
-
-```js
-const bitswapNode = // ...
-
-const stats = bitswapNode.stats
-```
-
-Stats contains a snapshot accessor, a moving average acessor and a peer accessor.
-
-Besides that, it emits "update" events every time it is updated.
-
-```js
-stats.on('update', (stats) => {
- console.log('latest stats snapshot: %j', stats)
-})
-```
-
-### Peer accessor:
-
-You can get the stats for a specific peer by doing:
-
-```js
-const peerStats = stats.forPeer(peerId)
-```
-
-The returned object behaves like the root stats accessor (has a snapshot, a moving average accessors and is an event emitter).
-
-### Global snapshot accessor:
-
-```js
-const snapshot = stats.snapshot
-console.log('stats: %j', snapshot)
-```
-
-the snapshot will contain the following keys, with the values being [bignumber.js](https://github.com/MikeMcl/bignumber.js#readme) instances:
-
-```js
-// stats: {
-// "dataReceived":"96",
-// "blocksReceived":"2",
-// "dataReceived":"96",
-// "dupBlksReceived":"0",
-// "dupDataReceived":"0",
-// "blocksSent":"0",
-// "dataSent":"0",
-// "providesBufferLength":"0",
-// "wantListLength":"0",
-// "peerCount":"1"
-// }
-```
-
-### Moving average accessor:
-
-```js
-const movingAverages = stats.movingAverages
-```
-
-This object contains these properties:
-
-- 'blocksReceived',
-- 'dataReceived',
-- 'dupBlksReceived',
-- 'dupDataReceived',
-- 'blocksSent',
-- 'dataSent',
-- 'providesBufferLength',
-- 'wantListLength',
-- 'peerCount'
-
-```js
-const dataReceivedMovingAverages = movingAverages.dataReceived
-```
-
-Each one of these will contain one key per interval (miliseconds), being the default intervals defined:
-
-- 60000 (1 minute)
-- 300000 (5 minutes)
-- 900000 (15 minutes)
-
-You can then select one of them
-
-```js
-const oneMinuteDataReceivedMovingAverages = dataReceivedMovingAverages[60000]
-```
-
-This object will be a [movingAverage](https://github.com/pgte/moving-average#readme) instance.
-
-## Performance tests
-
-You can run performance tests like this:
-
-```
-$ npm run benchmarks
-```
-
-### Profiling
-
-You can run each of the individual performance tests with a profiler like 0x.
-
-To do that, you need to install 0x:
-
-```bash
-$ npm install 0x --global
-```
-
-And then run the test:
-
-```bash
-$ 0x test/benchmarks/get-many
-```
-
-This will output a flame graph and print the location for it.
-Use the browser Chrome to open and inspect the generated graph.
-
-![Flame graph](https://ipfs.io/ipfs/QmVbyLgYfkLewNtzTAFwAEMmP2hTJgs8sSqsRTBNBjyQ1y)
-
-## API Docs
+# API Docs
-
-## License
+# License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](LICENSE-MIT) / )
-## Contribute
+# Contribute
Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-bitswap/issues).
diff --git a/package.json b/package.json
index 4b0c2d47..234a98d4 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,10 @@
"bugs": {
"url": "https://github.com/ipfs/js-ipfs-bitswap/issues"
},
+ "publishConfig": {
+ "access": "public",
+ "provenance": true
+ },
"keywords": [
"exchange",
"ipfs",
@@ -44,7 +48,7 @@
},
"release": {
"branches": [
- "master"
+ "main"
],
"plugins": [
[
@@ -144,8 +148,10 @@
"docs": "aegir docs"
},
"dependencies": {
- "@libp2p/interface": "^0.1.1",
- "@libp2p/logger": "^3.0.1",
+ "@libp2p/identify": "^1.0.0",
+ "@libp2p/interface": "^1.0.0",
+ "@libp2p/logger": "^4.0.0",
+ "@libp2p/utils": "^5.0.0",
"@multiformats/multiaddr": "^12.1.0",
"@vascosantos/moving-average": "^1.1.0",
"any-signal": "^4.1.1",
@@ -169,17 +175,17 @@
"varint-decoder": "^1.0.0"
},
"devDependencies": {
- "@chainsafe/libp2p-noise": "^13.0.0",
- "@libp2p/kad-dht": "^10.0.2",
- "@libp2p/mplex": "^9.0.2",
- "@libp2p/peer-id": "^3.0.1",
+ "@chainsafe/libp2p-noise": "^14.0.0",
+ "@libp2p/kad-dht": "^11.0.0",
+ "@libp2p/mplex": "^10.0.0",
+ "@libp2p/peer-id": "^4.0.0",
"@libp2p/peer-id-factory": "^3.0.2",
- "@libp2p/tcp": "^8.0.2",
+ "@libp2p/tcp": "^9.0.0",
"@nodeutils/defaults-deep": "^1.1.0",
"@types/lodash.difference": "^4.5.7",
"@types/lodash.flatten": "^4.4.7",
"@types/lodash.range": "^3.2.7",
- "@types/sinon": "^10.0.15",
+ "@types/sinon": "^17.0.2",
"@types/stats-lite": "^2.2.0",
"@types/varint": "^6.0.0",
"aegir": "^41.0.0",
@@ -188,7 +194,7 @@
"iso-random-stream": "^2.0.0",
"it-all": "^3.0.1",
"it-drain": "^3.0.1",
- "libp2p": "^0.46.3",
+ "libp2p": "^1.0.0",
"lodash.difference": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.range": "^3.2.0",
diff --git a/src/bitswap.ts b/src/bitswap.ts
index 7117e285..ed011fd0 100644
--- a/src/bitswap.ts
+++ b/src/bitswap.ts
@@ -9,8 +9,7 @@ import { logger } from './utils/index.js'
import { WantManager } from './want-manager/index.js'
import type { BitswapOptions, Bitswap, MultihashHasherLoader, WantListEntry, BitswapWantProgressEvents, BitswapNotifyProgressEvents } from './index.js'
import type { BitswapMessage } from './message/index.js'
-import type { Libp2p } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { AbortOptions } from '@multiformats/multiaddr'
import type { Blockstore, Pair } from 'interface-blockstore'
diff --git a/src/decision-engine/index.ts b/src/decision-engine/index.ts
index e189c498..3f3e7024 100644
--- a/src/decision-engine/index.ts
+++ b/src/decision-engine/index.ts
@@ -1,4 +1,4 @@
-import { trackedMap } from '@libp2p/interface/metrics/tracked-map'
+import { trackedMap } from '@libp2p/utils/tracked-map'
import { base58btc } from 'multiformats/bases/base58'
import { CID } from 'multiformats/cid'
import { BitswapMessage as Message } from '../message/index.js'
@@ -12,8 +12,7 @@ import type { Message as PBMessage } from '../message/message.js'
import type { Network } from '../network.js'
import type { Stats } from '../stats/index.js'
import type { WantListEntry } from '../wantlist/entry.js'
-import type { Libp2p } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { Blockstore } from 'interface-blockstore'
diff --git a/src/decision-engine/ledger.ts b/src/decision-engine/ledger.ts
index 0a551de4..fcbe8960 100644
--- a/src/decision-engine/ledger.ts
+++ b/src/decision-engine/ledger.ts
@@ -1,7 +1,7 @@
import { Wantlist } from '../wantlist/index.js'
import type { Message } from '../message/message.js'
import type { WantListEntry } from '../wantlist/entry.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
import type { CID } from 'multiformats/cid'
export class Ledger {
diff --git a/src/decision-engine/req-queue.ts b/src/decision-engine/req-queue.ts
index cb056129..41fae6bc 100644
--- a/src/decision-engine/req-queue.ts
+++ b/src/decision-engine/req-queue.ts
@@ -1,6 +1,6 @@
import { SortedMap } from '../utils/sorted-map.js'
import type { Task, TaskMerger } from './index.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
export interface PopTaskResult {
peerId?: PeerId
diff --git a/src/index.ts b/src/index.ts
index d6169d3a..df7e5fa2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,9 +1,13 @@
+/**
+ * @packageDocumentation
+ *
+ * This module implements the [Bitswap protocol](https://docs.ipfs.tech/concepts/bitswap/) in TypeScript.
+ */
+
import { DefaultBitswap } from './bitswap.js'
import type { Message } from './message/message'
import type { BitswapNetworkNotifyProgressEvents, BitswapNetworkWantProgressEvents } from './network.js'
-import type { Libp2p, AbortOptions } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
-import type { Startable } from '@libp2p/interface/startable'
+import type { Libp2p, AbortOptions, PeerId, Startable } from '@libp2p/interface'
import type { IMovingAverage } from '@vascosantos/moving-average'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'
diff --git a/src/message/index.ts b/src/message/index.ts
index 03b5a939..be8ff412 100644
--- a/src/message/index.ts
+++ b/src/message/index.ts
@@ -1,4 +1,4 @@
-import { CodeError } from '@libp2p/interface/errors'
+import { CodeError } from '@libp2p/interface'
import { base58btc } from 'multiformats/bases/base58'
import { CID } from 'multiformats/cid'
import { sha256 } from 'multiformats/hashes/sha2'
diff --git a/src/network.ts b/src/network.ts
index cde9c96b..63b66b21 100644
--- a/src/network.ts
+++ b/src/network.ts
@@ -1,4 +1,4 @@
-import { CodeError } from '@libp2p/interface/errors'
+import { CodeError } from '@libp2p/interface'
import drain from 'it-drain'
import * as lp from 'it-length-prefixed'
import map from 'it-map'
@@ -12,12 +12,7 @@ import { logger } from './utils/index.js'
import type { DefaultBitswap } from './bitswap.js'
import type { MultihashHasherLoader } from './index.js'
import type { Stats } from './stats/index.js'
-import type { Libp2p, AbortOptions } from '@libp2p/interface'
-import type { Connection } from '@libp2p/interface/connection'
-import type { PeerId } from '@libp2p/interface/peer-id'
-import type { PeerInfo } from '@libp2p/interface/peer-info'
-import type { IncomingStreamData } from '@libp2p/interface/stream-handler'
-import type { Topology } from '@libp2p/interface/topology'
+import type { Libp2p, AbortOptions, Connection, PeerId, PeerInfo, IncomingStreamData, Topology } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { CID } from 'multiformats/cid'
diff --git a/src/notifications.ts b/src/notifications.ts
index 658a518c..a886b7c1 100644
--- a/src/notifications.ts
+++ b/src/notifications.ts
@@ -4,8 +4,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import * as CONSTANTS from './constants.js'
import { logger } from './utils/index.js'
import type { BitswapWantBlockProgressEvents } from './index.js'
-import type { AbortOptions } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { AbortOptions, PeerId } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { CID } from 'multiformats/cid'
diff --git a/src/stats/index.ts b/src/stats/index.ts
index 231a21c8..3d27272d 100644
--- a/src/stats/index.ts
+++ b/src/stats/index.ts
@@ -1,7 +1,7 @@
import { EventEmitter } from 'events'
-import { trackedMap } from '@libp2p/interface/metrics/tracked-map'
+import { trackedMap } from '@libp2p/utils/tracked-map'
import { Stat } from './stat.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
import type { IMovingAverage } from '@vascosantos/moving-average'
import type { Libp2p } from 'libp2p'
diff --git a/src/utils/index.ts b/src/utils/index.ts
index f541bdf4..ba9b7bfe 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,7 +1,7 @@
import { logger as createLogger, type Logger } from '@libp2p/logger'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { BitswapMessageEntry } from '../message/entry.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
/**
* Creates a logger for the given subsystem
diff --git a/src/want-manager/index.ts b/src/want-manager/index.ts
index 8911d74f..ca2c08f8 100644
--- a/src/want-manager/index.ts
+++ b/src/want-manager/index.ts
@@ -1,4 +1,4 @@
-import { trackedMap } from '@libp2p/interface/metrics/tracked-map'
+import { trackedMap } from '@libp2p/utils/tracked-map'
import { base58btc } from 'multiformats/bases/base58'
import * as CONSTANTS from '../constants.js'
import { BitswapMessage as Message } from '../message/index.js'
@@ -8,8 +8,7 @@ import { MsgQueue } from './msg-queue.js'
import type { BitswapWantBlockProgressEvents } from '../index.js'
import type { Network } from '../network.js'
import type { Stats } from '../stats/index.js'
-import type { Libp2p } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { AbortOptions } from '@multiformats/multiaddr'
import type { CID } from 'multiformats/cid'
diff --git a/src/want-manager/msg-queue.ts b/src/want-manager/msg-queue.ts
index 2ff46b2f..f0afd4be 100644
--- a/src/want-manager/msg-queue.ts
+++ b/src/want-manager/msg-queue.ts
@@ -4,7 +4,7 @@ import { BitswapMessage as Message } from '../message/index.js'
import { logger } from '../utils/index.js'
import type { BitswapWantBlockProgressEvents } from '../index.js'
import type { BitswapNetworkWantProgressEvents, Network } from '../network.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
import type { Logger } from '@libp2p/logger'
import type { CID } from 'multiformats/cid'
import type { ProgressOptions } from 'progress-events'
diff --git a/src/wantlist/index.ts b/src/wantlist/index.ts
index 07317bfa..14edda58 100644
--- a/src/wantlist/index.ts
+++ b/src/wantlist/index.ts
@@ -1,4 +1,4 @@
-import { trackedMap } from '@libp2p/interface/metrics/tracked-map'
+import { trackedMap } from '@libp2p/utils/tracked-map'
import { base58btc } from 'multiformats/bases/base58'
import { Message } from '../message/message.js'
import { WantListEntry as Entry } from './entry.js'
diff --git a/test/bitswap-mock-internals.ts b/test/bitswap-mock-internals.ts
index 1850183e..b1371e41 100644
--- a/test/bitswap-mock-internals.ts
+++ b/test/bitswap-mock-internals.ts
@@ -1,7 +1,7 @@
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 5] */
-import { isPeerId, type PeerId } from '@libp2p/interface/peer-id'
+import { isPeerId, type PeerId } from '@libp2p/interface'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { expect } from 'aegir/chai'
import { MemoryBlockstore } from 'blockstore-core/memory'
diff --git a/test/bitswap-stats.ts b/test/bitswap-stats.ts
index 2768ccde..7c4308fc 100644
--- a/test/bitswap-stats.ts
+++ b/test/bitswap-stats.ts
@@ -8,8 +8,7 @@ import { BitswapMessage as Message } from '../src/message/index.js'
import { createLibp2pNode } from './utils/create-libp2p-node.js'
import { makeBlocks } from './utils/make-blocks.js'
import { makePeerIds } from './utils/make-peer-id.js'
-import type { Libp2p } from '@libp2p/interface'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { Libp2p, PeerId } from '@libp2p/interface'
import type { CID } from 'multiformats/cid'
const expectedStats = [
@@ -75,7 +74,7 @@ describe('bitswap stats', () => {
expectedStats.forEach((key) => {
expect(snapshot).to.have.property(key)
- expect(snapshot[key]).to.equal(BigInt(0))
+ expect(snapshot[key]).to.equal(0n)
})
const movingAverages = stats.movingAverages
@@ -92,15 +91,15 @@ describe('bitswap stats', () => {
it('updates blocks received', (done) => {
bs.stats.once('update', (stats) => {
- expect(stats.blocksReceived).to.equal(BigInt(2))
- expect(stats.dataReceived).to.equal(BigInt(96))
- expect(stats.dupBlksReceived).to.equal(BigInt(0))
- expect(stats.dupDataReceived).to.equal(BigInt(0))
- expect(stats.blocksSent).to.equal(BigInt(0))
- expect(stats.dataSent).to.equal(BigInt(0))
- expect(stats.providesBufferLength).to.equal(BigInt(0))
- expect(stats.wantListLength).to.equal(BigInt(0))
- expect(stats.peerCount).to.equal(BigInt(1))
+ expect(stats.blocksReceived).to.equal(2n)
+ expect(stats.dataReceived).to.equal(96n)
+ expect(stats.dupBlksReceived).to.equal(0n)
+ expect(stats.dupDataReceived).to.equal(0n)
+ expect(stats.blocksSent).to.equal(0n)
+ expect(stats.dataSent).to.equal(0n)
+ expect(stats.providesBufferLength).to.equal(0n)
+ expect(stats.wantListLength).to.equal(0n)
+ expect(stats.peerCount).to.equal(1n)
// test moving averages
const movingAverages = bs.stats.movingAverages
@@ -132,13 +131,13 @@ describe('bitswap stats', () => {
it('updates duplicate blocks counters', (done) => {
bs.stats.once('update', (stats) => {
- expect(stats.blocksReceived).to.equal(BigInt(4))
- expect(stats.dataReceived).to.equal(BigInt(192))
- expect(stats.dupBlksReceived).to.equal(BigInt(2))
- expect(stats.dupDataReceived).to.equal(BigInt(96))
- expect(stats.blocksSent).to.equal(BigInt(0))
- expect(stats.dataSent).to.equal(BigInt(0))
- expect(stats.providesBufferLength).to.equal(BigInt(0))
+ expect(stats.blocksReceived).to.equal(4n)
+ expect(stats.dataReceived).to.equal(192n)
+ expect(stats.dupBlksReceived).to.equal(2n)
+ expect(stats.dupDataReceived).to.equal(96n)
+ expect(stats.blocksSent).to.equal(0n)
+ expect(stats.dataSent).to.equal(0n)
+ expect(stats.providesBufferLength).to.equal(0n)
done()
})
@@ -173,15 +172,15 @@ describe('bitswap stats', () => {
it('updates stats on transfer', async () => {
const originalStats = bs.stats.snapshot
- expect(originalStats.blocksReceived).to.equal(BigInt(4))
- expect(originalStats.dataReceived).to.equal(BigInt(192))
- expect(originalStats.dupBlksReceived).to.equal(BigInt(2))
- expect(originalStats.dupDataReceived).to.equal(BigInt(96))
- expect(originalStats.blocksSent).to.equal(BigInt(0))
- expect(originalStats.dataSent).to.equal(BigInt(0))
- expect(originalStats.providesBufferLength).to.equal(BigInt(0))
- expect(originalStats.wantListLength).to.equal(BigInt(0))
- expect(originalStats.peerCount).to.equal(BigInt(1))
+ expect(originalStats.blocksReceived).to.equal(4n)
+ expect(originalStats.dataReceived).to.equal(192n)
+ expect(originalStats.dupBlksReceived).to.equal(2n)
+ expect(originalStats.dupDataReceived).to.equal(96n)
+ expect(originalStats.blocksSent).to.equal(0n)
+ expect(originalStats.dataSent).to.equal(0n)
+ expect(originalStats.providesBufferLength).to.equal(0n)
+ expect(originalStats.wantListLength).to.equal(0n)
+ expect(originalStats.peerCount).to.equal(1n)
const deferred = pEvent(bs.stats, 'update')
@@ -190,15 +189,11 @@ describe('bitswap stats', () => {
const nextStats = await deferred
- expect(nextStats.blocksReceived).to.equal(BigInt(4))
- expect(nextStats.dataReceived).to.equal(BigInt(192))
- expect(nextStats.dupBlksReceived).to.equal(BigInt(2))
- expect(nextStats.dupDataReceived).to.equal(BigInt(96))
- expect(nextStats.blocksSent).to.equal(BigInt(1))
- expect(nextStats.dataSent).to.equal(BigInt(48))
- expect(nextStats.providesBufferLength).to.equal(BigInt(0))
- expect(nextStats.wantListLength).to.equal(BigInt(0))
- expect(nextStats.peerCount).to.equal(BigInt(2))
+ expect(nextStats.blocksReceived).to.equal(4n)
+ expect(nextStats.dataReceived).to.equal(192n)
+ expect(nextStats.dataSent).to.equal(nextStats.blocksSent * BigInt(block.block.byteLength))
+ expect(nextStats.providesBufferLength).to.equal(0n)
+ expect(nextStats.wantListLength).to.equal(0n)
})
it('has peer stats', async () => {
@@ -215,15 +210,15 @@ describe('bitswap stats', () => {
const stats = await pEvent(peerStats, 'update')
- expect(stats.blocksReceived).to.equal(BigInt(1))
- expect(stats.dataReceived).to.equal(BigInt(49))
- expect(stats.dupBlksReceived).to.equal(BigInt(0))
- expect(stats.dupDataReceived).to.equal(BigInt(0))
- expect(stats.blocksSent).to.equal(BigInt(0))
- expect(stats.dataSent).to.equal(BigInt(0))
- expect(stats.providesBufferLength).to.equal(BigInt(0))
- expect(stats.wantListLength).to.equal(BigInt(0))
- expect(stats.peerCount).to.equal(BigInt(1))
+ expect(stats.blocksReceived).to.equal(1n)
+ expect(stats.dataReceived).to.equal(49n)
+ expect(stats.dupBlksReceived).to.equal(0n)
+ expect(stats.dupDataReceived).to.equal(0n)
+ expect(stats.blocksSent).to.equal(0n)
+ expect(stats.dataSent).to.equal(0n)
+ expect(stats.providesBufferLength).to.equal(0n)
+ expect(stats.wantListLength).to.equal(0n)
+ expect(stats.peerCount).to.equal(1n)
const ma = peerStats.movingAverages.dataReceived[60000]
expect(ma.movingAverage()).to.be.above(0)
diff --git a/test/decision-engine/decision-engine.ts b/test/decision-engine/decision-engine.ts
index cbe72848..87c357ec 100644
--- a/test/decision-engine/decision-engine.ts
+++ b/test/decision-engine/decision-engine.ts
@@ -20,7 +20,7 @@ import { makeBlocks } from '../utils/make-blocks.js'
import { makePeerId, makePeerIds } from '../utils/make-peer-id.js'
import { mockNetwork } from '../utils/mocks.js'
import type { Network } from '../../src/network.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
import type { Blockstore } from 'interface-blockstore'
const sum = (nums: number[]): number => nums.reduce((a, b) => a + b, 0)
diff --git a/test/decision-engine/ledger.spec.ts b/test/decision-engine/ledger.spec.ts
index fbf121c7..a96c8216 100644
--- a/test/decision-engine/ledger.spec.ts
+++ b/test/decision-engine/ledger.spec.ts
@@ -3,7 +3,7 @@
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { expect } from 'aegir/chai'
import { Ledger } from '../../src/decision-engine/ledger.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
describe('Ledger', () => {
/** @type {} */
diff --git a/test/decision-engine/req-queue.spec.ts b/test/decision-engine/req-queue.spec.ts
index a8695776..6bbe40b7 100644
--- a/test/decision-engine/req-queue.spec.ts
+++ b/test/decision-engine/req-queue.spec.ts
@@ -3,7 +3,7 @@
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { expect } from 'aegir/chai'
import { RequestQueue } from '../../src/decision-engine/req-queue.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
describe('Request Queue', () => {
let peerIds: PeerId[]
diff --git a/test/decision-engine/task-merger.spec.ts b/test/decision-engine/task-merger.spec.ts
index 98f77a2e..47a9badc 100644
--- a/test/decision-engine/task-merger.spec.ts
+++ b/test/decision-engine/task-merger.spec.ts
@@ -4,7 +4,7 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { expect } from 'aegir/chai'
import { RequestQueue } from '../../src/decision-engine/req-queue.js'
import { DefaultTaskMerger } from '../../src/decision-engine/task-merger.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
interface Task {
topic: string
diff --git a/test/notifications.spec.ts b/test/notifications.spec.ts
index 2416ba89..30cb92f4 100644
--- a/test/notifications.spec.ts
+++ b/test/notifications.spec.ts
@@ -7,7 +7,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { Notifications } from '../src/notifications.js'
import { makeBlocks } from './utils/make-blocks.js'
import { makePeerId } from './utils/make-peer-id.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
describe('Notifications', () => {
let blocks: Array<{ cid: CID, block: Uint8Array }>
diff --git a/test/utils/create-libp2p-node.ts b/test/utils/create-libp2p-node.ts
index 07697fce..c27d6bf2 100644
--- a/test/utils/create-libp2p-node.ts
+++ b/test/utils/create-libp2p-node.ts
@@ -1,4 +1,5 @@
import { noise } from '@chainsafe/libp2p-noise'
+import { identify } from '@libp2p/identify'
import { type DualKadDHT, kadDHT } from '@libp2p/kad-dht'
import { mplex } from '@libp2p/mplex'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
@@ -6,7 +7,6 @@ import { tcp } from '@libp2p/tcp'
// @ts-expect-error no types
import defaultsDeep from '@nodeutils/defaults-deep'
import { createLibp2p, type Libp2pOptions } from 'libp2p'
-import { identifyService } from 'libp2p/identify'
import type { Libp2p, ServiceMap } from '@libp2p/interface'
export interface NodeOptions extends Libp2pOptions {
@@ -15,7 +15,7 @@ export interface NodeOptions extends Libp2pOptions {
export async function createLibp2pNode (options: NodeOptions = {}): Promise> {
const services: ServiceMap = {
- identify: identifyService()
+ identify: identify()
}
if (options.DHT === true) {
diff --git a/test/utils/make-peer-id.ts b/test/utils/make-peer-id.ts
index 1027917d..5f83b7c1 100644
--- a/test/utils/make-peer-id.ts
+++ b/test/utils/make-peer-id.ts
@@ -1,5 +1,5 @@
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
export async function makePeerId (): Promise {
return (await makePeerIds(1))[0]
diff --git a/test/utils/mocks.ts b/test/utils/mocks.ts
index 7590d757..cbf487ab 100644
--- a/test/utils/mocks.ts
+++ b/test/utils/mocks.ts
@@ -9,9 +9,7 @@ import { Stats } from '../../src/stats/index.js'
import { createLibp2pNode } from './create-libp2p-node.js'
import type { Bitswap } from '../../src/index.js'
import type { BitswapMessage } from '../../src/message/index.js'
-import type { Libp2p } from '@libp2p/interface'
-import type { Connection } from '@libp2p/interface/connection'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { Libp2p, Connection, PeerId } from '@libp2p/interface'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'
diff --git a/test/wantmanager/msg-queue.spec.ts b/test/wantmanager/msg-queue.spec.ts
index e1607f64..c756ffb7 100644
--- a/test/wantmanager/msg-queue.spec.ts
+++ b/test/wantmanager/msg-queue.spec.ts
@@ -7,7 +7,7 @@ import { MsgQueue } from '../../src/want-manager/msg-queue.js'
import { makeBlocks } from '../utils/make-blocks.js'
import { makePeerId } from '../utils/make-peer-id.js'
import { mockNetwork } from '../utils/mocks.js'
-import type { PeerId } from '@libp2p/interface/peer-id'
+import type { PeerId } from '@libp2p/interface'
import type { CID } from 'multiformats/cid'
describe('MessageQueue', () => {