Skip to content
Closed
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
23 changes: 18 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,32 @@ class Node {
// Dialing methods
//

// TODO
/**
* Dial a given node by peer id.
* It will try to find a multiaddr in the peerbook and fail
* if none is found.
*
* @param {PeerId} id
* @param {string} [protocol]
* @param {function(Error, Connection)} callback
* @returns {void}
*/
dialById (id, protocol, callback) {
// NOTE: dialById only works if a previous dial was made. This will
// change once we have PeerRouting

assert(this.isOnline, OFFLINE_ERROR_MESSAGE)

if (typeof protocol === 'function') {
callback = protocol
protocol = undefined
}

callback(new Error('not implemented yet'))
let peer
try {
peer = this.peerBook.getByB58String(id.toB58String())
} catch (err) {
return callback(new Error('No multiaddr found for this id'))
}

this.dialByPeerInfo(peer, protocol, callback)
}

dialByMultiaddr (maddr, protocol, callback) {
Expand Down