Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: only dial to unconnected peers #1914

Merged
merged 3 commits into from
Mar 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ module.exports = function libp2p (self, config) {
const libp2p = createBundle({ options, config, datastore, peerInfo, peerBook })
let discoveredPeers = []

const noop = () => {}
const putAndDial = peerInfo => {
peerBook.put(peerInfo)
libp2p.dial(peerInfo, () => {})
peerInfo = peerBook.put(peerInfo)
if (!peerInfo.isConnected()) {
libp2p.dial(peerInfo, noop)
}
}

libp2p.on('start', () => {
Expand Down