@@ -61,9 +61,8 @@ export class Libp2pServer extends Server {
6161 peerInfo : await this . createPeerInfo ( ) ,
6262 bootnodes : this . bootnodes ,
6363 } )
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 ] } `
6766 this . node ! . handle ( protocol , async ( _ : any , connection : any ) => {
6867 try {
6968 const peerInfo = await this . getPeerInfo ( connection )
@@ -79,7 +78,6 @@ export class Libp2pServer extends Server {
7978 } )
8079 } )
8180 }
82- // eslint-disable-next-line no-extra-semi
8381 this . node . on ( 'peer:discovery' , async ( peerInfo : any ) => {
8482 try {
8583 const id = peerInfo . id . toB58String ( )
@@ -102,12 +100,7 @@ export class Libp2pServer extends Server {
102100 this . error ( e )
103101 }
104102 } )
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 ( )
111104 this . node . peerInfo . multiaddrs . toArray ( ) . map ( ( ma : any ) => {
112105 this . emit ( 'listening' , {
113106 transport : this . name ,
@@ -123,12 +116,7 @@ export class Libp2pServer extends Server {
123116 */
124117 async stop ( ) : Promise < boolean > {
125118 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 ( )
132120 await super . stop ( )
133121 this . started = false
134122 }
@@ -178,8 +166,7 @@ export class Libp2pServer extends Server {
178166 if ( err ) {
179167 return reject ( err )
180168 }
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 ) )
183170 resolve ( peerInfo )
184171 }
185172 if ( this . key ) {
0 commit comments