Skip to content

Commit b9c05d0

Browse files
committed
refactor!: extract ping service into separate module
BREAKING CHANGE: imports from `libp2p/ping` must be updated to `@libp2p/ping`
1 parent 9a15061 commit b9c05d0

File tree

17 files changed

+394
-339
lines changed

17 files changed

+394
-339
lines changed

doc/CONFIGURATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,14 +987,14 @@ Changing the protocol name prefix can isolate default public network (IPFS) for
987987
```js
988988
import { createLibp2p } from 'libp2p'
989989
import { identifyService } from 'libp2p/identify'
990-
import { pingService } from 'libp2p/ping'
990+
import { ping } from 'libp2p/@ping'
991991

992992
const node = await createLibp2p({
993993
services: {
994994
identify: identifyService({
995995
protocolPrefix: 'ipfs' // default
996996
}),
997-
ping: pingService({
997+
ping: ping({
998998
protocolPrefix: 'ipfs' // default
999999
})
10001000
}

doc/migrations/v0.46-v1.0.0.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A migration guide for refactoring your application code from libp2p `v0.46` to `
66
## Table of Contents <!-- omit in toc -->
77

88
- [AutoNAT](#autonat)
9+
- [Ping](#ping)
910
- [KeyChain](#keychain)
1011
- [UPnPNat](#upnpnat)
1112
- [Pnet](#pnet)
@@ -41,6 +42,36 @@ const node = await createLibp2p({
4142
})
4243
```
4344

45+
## Ping
46+
47+
The Ping service is now published in its own package.
48+
49+
**Before**
50+
51+
```ts
52+
import { createLibp2p } from 'libp2p'
53+
import { pingService } from 'libp2p/ping'
54+
55+
const node = await createLibp2p({
56+
services: {
57+
ping: pingService()
58+
}
59+
})
60+
```
61+
62+
**After**
63+
64+
```ts
65+
import { createLibp2p } from 'libp2p'
66+
import { ping } from '@libp2p/ping'
67+
68+
const node = await createLibp2p({
69+
services: {
70+
ping: ping()
71+
}
72+
})
73+
```
74+
4475
## KeyChain
4576

4677
The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired.

packages/libp2p/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
"./insecure": {
6868
"types": "./dist/src/insecure/index.d.ts",
6969
"import": "./dist/src/insecure/index.js"
70-
},
71-
"./ping": {
72-
"types": "./dist/src/ping/index.d.ts",
73-
"import": "./dist/src/ping/index.js"
7470
}
7571
},
7672
"eslintConfig": {

packages/libp2p/test/ping/index.spec.ts

Lines changed: 0 additions & 136 deletions
This file was deleted.

packages/libp2p/test/ping/ping.node.ts

Lines changed: 0 additions & 152 deletions
This file was deleted.

packages/libp2p/typedoc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"./src/dcutr/index.ts",
66
"./src/fetch/index.ts",
77
"./src/identify/index.ts",
8-
"./src/insecure/index.ts",
9-
"./src/ping/index.ts"
8+
"./src/insecure/index.ts"
109
]
1110
}

packages/protocol-ping/LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This project is dual licensed under MIT and Apache-2.0.
2+
3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

0 commit comments

Comments
 (0)