From 7c82d1fe5f7c5cc3b0fd76da19989b5cb95bb5eb Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 12 Jul 2018 11:23:18 +0800 Subject: [PATCH] blockchain.headers.subscribe: raw defaults to True in 1.3 Update docs for this and other omissions. --- docs/protocol-changes.rst | 16 ++++-- docs/protocol-methods.rst | 105 ++---------------------------------- docs/protocol.rst | 1 + electrumx/server/session.py | 9 +++- 4 files changed, 24 insertions(+), 107 deletions(-) diff --git a/docs/protocol-changes.rst b/docs/protocol-changes.rst index f7aa965..4dc17b8 100644 --- a/docs/protocol-changes.rst +++ b/docs/protocol-changes.rst @@ -86,6 +86,17 @@ Deprecated methods Version 1.3 =========== +Changes +------- + + * :func:`blockchain.headers.subscribe` argument *raw* switches default to + :const:`True` + +New methods +----------- + + * :func:`blockchain.block.header` + Removed methods --------------- @@ -95,11 +106,6 @@ Removed methods * :func:`blockchain.address.listunspent` * :func:`blockchain.address.subscribe` -New methods ------------ - - * :func:`blockchain.block.header` - Deprecated methods ------------------ diff --git a/docs/protocol-methods.rst b/docs/protocol-methods.rst index e569a6f..2bd65a0 100644 --- a/docs/protocol-methods.rst +++ b/docs/protocol-methods.rst @@ -2,104 +2,6 @@ Protocol Methods ================== -blockchain.address.get_balance -============================== - -Return the confirmed and unconfirmed balances of a bitcoin address. - -**Signature** - - .. function:: blockchain.address.get_balance(address) - .. deprecated:: 1.2 - - * *address* - - The address as a Base58 string. - -**Result** - - See :func:`blockchain.scripthash.get_balance`. - -blockchain.address.get_history -============================== - -Return the confirmed and unconfirmed history of a bitcoin address. - -**Signature** - - .. function:: blockchain.address.get_history(address) - .. deprecated:: 1.2 - - * *address* - - The address as a Base58 string. - -**Result** - - As for :func:`blockchain.scripthash.get_history`. - -blockchain.address.get_mempool -============================== - -Return the unconfirmed transactions of a bitcoin address. - -**Signature** - - .. function:: blockchain.address.get_mempool(address) - .. deprecated:: 1.2 - - * *address* - - The address as a Base58 string. - -**Result** - - As for :func:`blockchain.scripthash.get_mempool`. - -blockchain.address.listunspent -============================== - -Return an ordered list of UTXOs sent to a bitcoin address. - -**Signature** - - .. function:: blockchain.address.listunspent(address) - .. deprecated:: 1.2 - - * *address* - - The address as a Base58 string. - -**Result** - - As for :func:`blockchain.scripthash.listunspent`. - -blockchain.address.subscribe -============================ - -Subscribe to a bitcoin address. - -**Signature** - - .. function:: blockchain.address.subscribe(address) - .. deprecated:: 1.2 - - *address* - - The address as a Base58 string. - -**Result** - - The :ref:`status ` of the address. - -**Notifications** - - As this is a subcription, the client will receive a notification - when the :ref:`status ` of the address changes. Its - signature is - - .. function:: blockchain.address.subscribe(address, status) - blockchain.block.get_header =========================== @@ -171,6 +73,7 @@ Return the block header at the given height. **Signature** .. function:: blockchain.block.header(height) + .. versionadded:: 1.3 *height* @@ -268,9 +171,11 @@ Subscribe to receive block headers when a new block is found. **Signature** - .. function:: blockchain.headers.subscribe(raw=False) + .. function:: blockchain.headers.subscribe(raw=True) .. versionchanged:: 1.2 - Optional *raw* parameter added. + Optional *raw* parameter added, defaulting to :const:`False`. + .. versionchanged:: 1.3 + *raw* parameter deafults to :const:`True`. * *raw* diff --git a/docs/protocol.rst b/docs/protocol.rst index dc2ff05..e2d6335 100644 --- a/docs/protocol.rst +++ b/docs/protocol.rst @@ -10,3 +10,4 @@ alike. protocol-basics protocol-methods protocol-changes + protocol-removed diff --git a/electrumx/server/session.py b/electrumx/server/session.py index 6abbbda..c18d78a 100644 --- a/electrumx/server/session.py +++ b/electrumx/server/session.py @@ -217,13 +217,17 @@ class ElectrumX(SessionBase): return {'hex': raw_header.hex(), 'height': height} return self.controller.electrum_header(height) - def headers_subscribe(self, raw=False): + def headers_subscribe(self, raw=True): '''Subscribe to get headers of new blocks.''' self.subscribe_headers = True self.subscribe_headers_raw = self.assert_boolean(raw) self.notified_height = self.height() return self.subscribe_headers_result(self.height()) + def headers_subscribe_old(self, raw=False): + '''Subscribe to get headers of new blocks; raw defaults to False.''' + return self.headers_subscribe(raw) + async def add_peer(self, features): '''Add a peer (but only if the peer resolves to the source).''' peer_mgr = self.controller.peer_mgr @@ -433,7 +437,6 @@ class ElectrumX(SessionBase): 'blockchain.block.get_chunk': self.block_get_chunk, 'blockchain.block.get_header': controller.block_get_header, 'blockchain.estimatefee': controller.estimatefee, - 'blockchain.headers.subscribe': self.headers_subscribe, 'blockchain.relayfee': controller.relayfee, 'blockchain.scripthash.get_balance': controller.scripthash_get_balance, @@ -468,9 +471,11 @@ class ElectrumX(SessionBase): if ptuple >= (1, 3): handlers.update({ 'blockchain.block.header': self.block_header, + 'blockchain.headers.subscribe': self.headers_subscribe, }) else: handlers.update({ + 'blockchain.headers.subscribe': self.headers_subscribe_old, 'blockchain.address.get_balance': controller.address_get_balance, 'blockchain.address.get_history':