mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-17 08:00:51 +00:00
feat: add ping to the mix
This commit is contained in:
parent
ee801c9be2
commit
f8c09db20f
@ -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",
|
||||
@ -52,4 +53,4 @@
|
||||
"Richard Littauer <richard.littauer@gmail.com>",
|
||||
"greenkeeperio-bot <support@greenkeeper.io>"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
25
src/index.js
25
src/index.js
@ -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
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user