forked from LBRYCommunity/lbry-sdk
add peer_ping
This commit is contained in:
parent
eae97a8133
commit
2903ccaeb4
2 changed files with 28 additions and 0 deletions
|
@ -47,6 +47,7 @@ at anytime.
|
|||
* virtual kademlia network and mock udp transport for dht integration tests
|
||||
* integration tests for bootstrapping the dht
|
||||
* configurable `concurrent_announcers` setting
|
||||
* `peer_ping` command
|
||||
|
||||
### Removed
|
||||
* `announce_all` argument from `blob_announce`
|
||||
|
|
|
@ -48,6 +48,7 @@ from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
|||
from lbrynet.core.Error import InsufficientFundsError, UnknownNameError
|
||||
from lbrynet.core.Error import DownloadDataTimeout, DownloadSDTimeout
|
||||
from lbrynet.core.Error import NullFundsError, NegativeFundsError
|
||||
from lbrynet.dht.error import TimeoutError
|
||||
from lbrynet.core.Peer import Peer
|
||||
from lbrynet.core.SinglePeerDownloader import SinglePeerDownloader
|
||||
from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader
|
||||
|
@ -3040,6 +3041,32 @@ class Daemon(AuthJSONRPCServer):
|
|||
d.addCallback(lambda r: self._render_response(r))
|
||||
return d
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_peer_ping(self, node_id):
|
||||
"""
|
||||
Find and ping a peer by node id
|
||||
|
||||
Usage:
|
||||
peer_ping (<node_id> | --node_id=<node_id>)
|
||||
|
||||
Returns:
|
||||
(str) pong, or {'error': <error message>} if an error is encountered
|
||||
"""
|
||||
|
||||
contact = None
|
||||
try:
|
||||
contact = yield self.session.dht_node.findContact(node_id.decode('hex'))
|
||||
except TimeoutError:
|
||||
result = {'error': 'timeout finding peer'}
|
||||
defer.returnValue(result)
|
||||
if not contact:
|
||||
defer.returnValue({'error': 'peer not found'})
|
||||
try:
|
||||
result = yield contact.ping()
|
||||
except TimeoutError:
|
||||
result = {'error': 'ping timeout'}
|
||||
defer.returnValue(result)
|
||||
|
||||
def jsonrpc_routing_table_get(self):
|
||||
"""
|
||||
Get DHT routing information
|
||||
|
|
Loading…
Reference in a new issue