Skip to content

Commit

Permalink
fix(network): correct msg processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 12, 2016
1 parent 1f0fbfe commit ee5e6c4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/network/index.js
Expand Up @@ -47,14 +47,12 @@ module.exports = class Network {
}

_onConnection (conn) {
log('connected')
pull(
conn,
lp.decode(),
pull.collect((err, msgs) => msgs.forEach((data) => {
pull.through((data) => {
log('raw message', data)
if (err) {
return this.bitswap._receiveError(err)
}
let msg
try {
msg = Message.fromProto(data)
Expand All @@ -67,7 +65,12 @@ module.exports = class Network {
}
this.bitswap._receiveMessage(peerInfo.id, msg)
})
}))
}),
pull.onEnd((err) => {
if (err) {
return this.bitswap._receiveError(err)
}
})
)
}

Expand Down Expand Up @@ -105,6 +108,7 @@ module.exports = class Network {
}

this.libp2p.dialByPeerInfo(peerInfo, PROTOCOL_IDENTIFIER, (err, conn) => {
log('dialed %s', peerInfo.id.toB58String(), err)
if (err) {
return cb(err)
}
Expand Down

0 comments on commit ee5e6c4

Please sign in to comment.