Skip to content

Commit

Permalink
feat: add ping to the mix
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Dec 1, 2016
1 parent ee801c9 commit f8c09db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -39,6 +39,7 @@
"pre-commit": "^1.1.1"
},
"dependencies": {
"libp2p-ping": "^0.3.0",
"libp2p-swarm": "^0.26.3",
"mafmt": "^2.1.2",
"multiaddr": "^2.1.1",
Expand All @@ -52,4 +53,4 @@
"Richard Littauer <richard.littauer@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>"
]
}
}
25 changes: 25 additions & 0 deletions src/index.js
Expand Up @@ -8,6 +8,7 @@ const multiaddr = require('multiaddr')
const mafmt = require('mafmt')
const EE = require('events').EventEmitter
const assert = require('assert')
const Ping = require('libp2p-ping')

exports = module.exports

Expand Down Expand Up @@ -70,6 +71,9 @@ class Node {
})
}

// Mount default protocols
Ping.mount(this.swarm)

// Not fully implemented in js-libp2p yet
this.routing = undefined
this.records = undefined
Expand Down Expand Up @@ -123,6 +127,27 @@ class Node {
this.swarm.close(callback)
}

//
// Ping
//

// TODO
pingById (id, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(new Error('not implemented yet'))
}

// TODO
pingByMultiaddr (maddr, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(new Error('not implemented yet'))
}

pingByPeerInfo (peerInfo, callback) {
assert(this.isOnline, OFFLINE_ERROR_MESSAGE)
callback(null, new Ping(this.swarm, peerInfo))
}

//
// Dialing methods
//
Expand Down

0 comments on commit f8c09db

Please sign in to comment.