1
1
import { randomBytes } from '@libp2p/crypto'
2
- import { ProtocolError , TimeoutError , setMaxListeners } from '@libp2p/interface'
2
+ import { ProtocolError , TimeoutError , serviceCapabilities , setMaxListeners } from '@libp2p/interface'
3
3
import { byteStream } from 'it-byte-stream'
4
4
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5
5
import { PROTOCOL_PREFIX , PROTOCOL_NAME , PING_LENGTH , PROTOCOL_VERSION , TIMEOUT , MAX_INBOUND_STREAMS , MAX_OUTBOUND_STREAMS } from './constants.js'
6
- import type { PingServiceComponents , PingServiceInit , PingService as PingServiceInterface } from './index.js'
6
+ import type { PingComponents , PingInit , Ping as PingInterface } from './index.js'
7
7
import type { AbortOptions , Logger , Stream , PeerId , Startable , IncomingStreamData } from '@libp2p/interface'
8
8
import type { Multiaddr } from '@multiformats/multiaddr'
9
9
10
- export class PingService implements Startable , PingServiceInterface {
10
+ export class Ping implements Startable , PingInterface {
11
11
public readonly protocol : string
12
- private readonly components : PingServiceComponents
12
+ private readonly components : PingComponents
13
13
private started : boolean
14
14
private readonly timeout : number
15
15
private readonly maxInboundStreams : number
16
16
private readonly maxOutboundStreams : number
17
17
private readonly runOnLimitedConnection : boolean
18
18
private readonly log : Logger
19
19
20
- constructor ( components : PingServiceComponents , init : PingServiceInit = { } ) {
20
+ constructor ( components : PingComponents , init : PingInit = { } ) {
21
21
this . components = components
22
22
this . log = components . logger . forComponent ( 'libp2p:ping' )
23
23
this . started = false
@@ -32,6 +32,10 @@ export class PingService implements Startable, PingServiceInterface {
32
32
33
33
readonly [ Symbol . toStringTag ] = '@libp2p/ping'
34
34
35
+ readonly [ serviceCapabilities ] : string [ ] = [
36
+ '@libp2p/ping'
37
+ ]
38
+
35
39
async start ( ) : Promise < void > {
36
40
await this . components . registrar . handle ( this . protocol , this . handleMessage , {
37
41
maxInboundStreams : this . maxInboundStreams ,
0 commit comments