Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed Jul 15, 2020
1 parent d67190b commit d76fe0c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/identify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ class IdentifyService {
* @param {Array<Connection>} connections
* @returns {Promise<void>}
*/
push (connections) {
async push (connections) {
const signedPeerRecord = await this._getSelfPeerRecord()
const listenAddrs = this._libp2p.multiaddrs.map((ma) => ma.buffer)
const protocols = Array.from(this._protocols.keys())
const pushes = connections.map(async connection => {
try {
const { stream } = await connection.newStream(MULTICODEC_IDENTIFY_PUSH)
const signedPeerRecord = await this._getSelfPeerRecord()

await pipe(
[{
listenAddrs: this._libp2p.multiaddrs.map((ma) => ma.buffer),
listenAddrs,
signedPeerRecord,
protocols: Array.from(this._protocols.keys())
protocols
}],
pb.encode(Message),
stream,
Expand Down Expand Up @@ -189,7 +191,7 @@ class IdentifyService {

addresses = peerRecord.multiaddrs
} catch (err) {
log('received invalid envelope, discard it and fallback to listenAddrs is available')
log('received invalid envelope, discard it and fallback to listenAddrs is available', err)
// Try Legacy
addresses = listenAddrs
}
Expand Down Expand Up @@ -298,7 +300,7 @@ class IdentifyService {

addresses = peerRecord.multiaddrs
} catch (err) {
log('received invalid envelope, discard it and fallback to listenAddrs is available')
log('received invalid envelope, discard it and fallback to listenAddrs is available', err)
// Try Legacy
addresses = message.listenAddrs
}
Expand Down

0 comments on commit d76fe0c

Please sign in to comment.