chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos 2020-10-05 16:49:43 +02:00
parent 29e30c2199
commit 2746b4b025
4 changed files with 8 additions and 7 deletions

View File

@ -449,9 +449,9 @@ const node = await Libp2p.create({
relay: { // Circuit Relay options (this config is part of libp2p core configurations)
enabled: true, // Allows you to dial and accept relayed connections. Does not make you a relay.
autoRelay: {
enabled: false, // Allows you to bind to relays with HOP enabled for improving node dialability
enabled: true, // Allows you to bind to relays with HOP enabled for improving node dialability
maxListeners: 2 // Configure maximum number of HOP relays to use
},
}
}
}
})

View File

@ -68,12 +68,12 @@ class Relay {
await this._libp2p.contentRouting.provide(cid)
} catch (err) {
if (err.code === 'NO_ROUTERS_AVAILABLE') {
log('there are no routers configured to advertise hop relay service')
log.error('a content router, such as a DHT, must be provided in order to advertise the relay service', err)
// Stop the advertise
this.stop()
} else {
log.error(err)
}
// Stop the advertise
this.stop()
return
}

View File

@ -59,7 +59,7 @@ const DefaultConfig = {
enabled: true,
advertise: {
bootDelay: RelayConstants.ADVERTISE_BOOT_DELAY,
enabled: true,
enabled: false,
ttl: RelayConstants.ADVERTISE_TTL
},
hop: {

View File

@ -486,7 +486,8 @@ describe('auto-relay', () => {
relay: {
advertise: {
bootDelay: 1000,
ttl: 1000
ttl: 1000,
enabled: true
},
hop: {
enabled: index === 2