diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index 54328fe255..b164856e50 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -26,10 +26,15 @@ module.exports = function libp2p (self) { self._libp2pNode = new Node(self._peerInfo, self._peerInfoBook, options) self._libp2pNode.on('peer:discovery', (peerInfo) => { - if (self.isOnline()) { + const dial = () => { self._peerInfoBook.put(peerInfo) self._libp2pNode.dial(peerInfo, () => {}) } + if (self.isOnline()) { + dial() + } else { + self._libp2pNode.once('online', dial) + } }) self._libp2pNode.on('peer:connect', (peerInfo) => {