Skip to content

Commit

Permalink
chore: lint libp2p main (#1566)
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Mar 5, 2023
1 parent 9ed169b commit 2f30e3d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DHTContentRouting } from './dht/dht-content-routing.js'
import { DefaultComponents } from './components.js'
import type { Components } from './components.js'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Connection } from '@libp2p/interface-connection'
import type { Connection, Stream } from '@libp2p/interface-connection'
import type { PeerRouting } from '@libp2p/interface-peer-routing'
import type { ContentRouting } from '@libp2p/interface-content-routing'
import type { PubSub } from '@libp2p/interface-pubsub'
Expand Down Expand Up @@ -273,7 +273,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
/**
* Starts the libp2p node and all its subsystems
*/
async start () {
async start (): Promise<void> {
if (this.started) {
return
}
Expand All @@ -300,7 +300,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {

// start any startables
await Promise.all(
this.services.map(async service => await service.start())
this.services.map(async service => { await service.start() })
)

await Promise.all(
Expand All @@ -322,7 +322,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
/**
* Stop the libp2p node by closing its listeners and open connections
*/
async stop () {
async stop (): Promise<void> {
if (!this.started) {
return
}
Expand All @@ -340,7 +340,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
)

await Promise.all(
this.services.map(async service => await service.stop())
this.services.map(async service => { await service.stop() })
)

await Promise.all(
Expand All @@ -354,7 +354,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
log('libp2p has stopped')
}

isStarted () {
isStarted (): boolean {
return this.started
}

Expand All @@ -376,7 +376,7 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
return await this.components.connectionManager.openConnection(peer, options)
}

async dialProtocol (peer: PeerId | Multiaddr, protocols: string | string[], options: AbortOptions = {}) {
async dialProtocol (peer: PeerId | Multiaddr, protocols: string | string[], options: AbortOptions = {}): Promise<Stream> {
if (protocols == null) {
throw errCode(new Error('no protocols were provided to open a stream'), codes.ERR_INVALID_PROTOCOLS_FOR_STREAM)
}
Expand Down Expand Up @@ -495,15 +495,15 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
return await this.registrar.register(protocol, topology)
}

unregister (id: string) {
unregister (id: string): void {
this.registrar.unregister(id)
}

/**
* Called whenever peer discovery services emit `peer` events.
* Known peers may be emitted.
*/
onDiscoveryPeer (evt: CustomEvent<PeerInfo>) {
onDiscoveryPeer (evt: CustomEvent<PeerInfo>): void {
const { detail: peer } = evt

if (peer.id.toString() === this.peerId.toString()) {
Expand All @@ -512,11 +512,11 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
}

if (peer.multiaddrs.length > 0) {
void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => log.error(err))
void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => { log.error(err) })
}

if (peer.protocols.length > 0) {
void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => log.error(err))
void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => { log.error(err) })
}

this.dispatchEvent(new CustomEvent<PeerInfo>('peer:discovery', { detail: peer }))
Expand Down

0 comments on commit 2f30e3d

Please sign in to comment.