Browse Source

Add server.ping RPC call

patch-2
Neil Booth 7 years ago
parent
commit
bab8d9f915
  1. 1
      .gitignore
  2. 1
      docs/protocol-changes.rst
  3. 26
      docs/protocol-methods.rst
  4. 7
      server/session.py

1
.gitignore

@ -5,6 +5,7 @@ tests/*/__pycache__/
*.#* *.#*
*# *#
*~ *~
docs/_build
/build /build
/dist /dist
/electrumx.egg-info /electrumx.egg-info

1
docs/protocol-changes.rst

@ -58,6 +58,7 @@ New methods
* :func:`blockchain.block.headers` * :func:`blockchain.block.headers`
* :func:`mempool.get_fee_histogram` * :func:`mempool.get_fee_histogram`
* :func:`server.ping`
Deprecated methods Deprecated methods
------------------ ------------------

26
docs/protocol-methods.rst

@ -745,8 +745,8 @@ Return the address paid to by a UTXO.
mempool.get_fee_histogram mempool.get_fee_histogram
------------------------- -------------------------
Return a histogram of the fee rates paid by transactions in the Return a histogram of the fee rates paid by transactions in the memory
memory pool, weighted by transaction size. pool, weighted by transaction size.
**Signature** **Signature**
@ -776,8 +776,8 @@ mempool.get_fee_histogram
server.add_peer server.add_peer
--------------- ---------------
This call is intended for a new server to get itself into a server's A newly-started server uses this call to get itself into other servers'
peers list, and should not be used by wallet clients. peers lists. It sould not be used by wallet clients.
**Signature** **Signature**
@ -949,6 +949,21 @@ server.peers.subscribe
the default port for the coin network is implied. If 's' or 't' is the default port for the coin network is implied. If 's' or 't' is
missing then the server does not support that transport. missing then the server does not support that transport.
server.ping
-----------
Ping the server to ensure it is responding, and to keep the session
alive. The server may disconnect clients that have sent no requests
for roughly 10 minutes.
**Signature**
.. function:: server.ping()
.. versionadded:: 1.2
**Result**
Returns :const:`null`.
server.version server.version
-------------- --------------
@ -960,6 +975,9 @@ server.version
.. function:: server.version(client_name="", protocol_version="1.1") .. function:: server.version(client_name="", protocol_version="1.1")
.. versionchanged:: 1.1 .. versionchanged:: 1.1
*protocol_version* is not ignored. *protocol_version* is not ignored.
.. versionchanged:: 1.2
Use :func:`server.ping` rather than sending version requests as a
ping mechanism.
* *client_name* * *client_name*

7
server/session.py

@ -329,6 +329,12 @@ class ElectrumX(SessionBase):
return banner return banner
def ping(self):
'''Serves as a connection keep-alive mechanism and for the client to
confirm the server is still responding.
'''
return None
def server_version(self, client_name=None, protocol_version=None): def server_version(self, client_name=None, protocol_version=None):
'''Returns the server version as a string. '''Returns the server version as a string.
@ -463,6 +469,7 @@ class ElectrumX(SessionBase):
'mempool.get_fee_histogram': 'mempool.get_fee_histogram':
controller.mempool_get_fee_histogram, controller.mempool_get_fee_histogram,
'blockchain.block.headers': self.block_headers, 'blockchain.block.headers': self.block_headers,
'server.ping': self.ping,
}) })
self.electrumx_handlers = handlers self.electrumx_handlers = handlers

Loading…
Cancel
Save