@@ -61,9 +61,8 @@ export class Libp2pServer extends Server {
61
61
peerInfo : await this . createPeerInfo ( ) ,
62
62
bootnodes : this . bootnodes ,
63
63
} )
64
- this . protocols . forEach ( async ( p : any ) => {
65
- //@ts -ignore
66
- const protocol : any = `/${ p . name } /${ p . versions [ 0 ] } `
64
+ this . protocols . forEach ( async ( p ) => {
65
+ const protocol = `/${ p . name } /${ p . versions [ 0 ] } `
67
66
this . node ! . handle ( protocol , async ( _ : any , connection : any ) => {
68
67
try {
69
68
const peerInfo = await this . getPeerInfo ( connection )
@@ -79,7 +78,6 @@ export class Libp2pServer extends Server {
79
78
} )
80
79
} )
81
80
}
82
- // eslint-disable-next-line no-extra-semi
83
81
this . node . on ( 'peer:discovery' , async ( peerInfo : any ) => {
84
82
try {
85
83
const id = peerInfo . id . toB58String ( )
@@ -102,12 +100,7 @@ export class Libp2pServer extends Server {
102
100
this . error ( e )
103
101
}
104
102
} )
105
- await new Promise ( ( resolve , reject ) =>
106
- this . node ! . start ( ( err : any ) => {
107
- if ( err ) reject ( err )
108
- resolve ( )
109
- } )
110
- )
103
+ await this . node . asyncStart ( )
111
104
this . node . peerInfo . multiaddrs . toArray ( ) . map ( ( ma : any ) => {
112
105
this . emit ( 'listening' , {
113
106
transport : this . name ,
@@ -123,12 +116,7 @@ export class Libp2pServer extends Server {
123
116
*/
124
117
async stop ( ) : Promise < boolean > {
125
118
if ( this . started ) {
126
- await new Promise ( ( resolve , reject ) =>
127
- this . node ! . stop ( ( err : any ) => {
128
- if ( err ) reject ( err )
129
- resolve ( )
130
- } )
131
- )
119
+ await this . node ! . asyncStop ( )
132
120
await super . stop ( )
133
121
this . started = false
134
122
}
@@ -178,8 +166,7 @@ export class Libp2pServer extends Server {
178
166
if ( err ) {
179
167
return reject ( err )
180
168
}
181
- // eslint-disable-next-line no-extra-semi
182
- this . multiaddrs . forEach ( ( ma : any ) => peerInfo . multiaddrs . add ( ma ) )
169
+ this . multiaddrs . forEach ( ( ma ) => peerInfo . multiaddrs . add ( ma ) )
183
170
resolve ( peerInfo )
184
171
}
185
172
if ( this . key ) {
0 commit comments