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 Aug 12, 2020
1 parent a798c65 commit 40e4e94
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/identify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,20 @@ 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 +192,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 @@ -299,7 +302,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 40e4e94

Please sign in to comment.