Skip to content

Commit

Permalink
feat(p2p): life peers exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Mar 9, 2018
1 parent 9177691 commit 8035e57
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/background/p2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class p2p {
}
})

// new peer with peer exchange
this.on('peer', (peer) => {
this.add(peer)
})

// ignore local addresses
const ifaces = os.networkInterfaces();
Object.keys(ifaces).forEach((ifname) => {
Expand Down Expand Up @@ -154,6 +159,10 @@ class p2p {

// success
clearTimeout(protocolTimeout)

// send some peers with pears exchange
this.emit('peer', address)

// add to peers
address.emit = emit
address.disconnect = () => rawSocket.destroy()
Expand Down

0 comments on commit 8035e57

Please sign in to comment.