Browse Source

blockchain.headers.subscribe: raw defaults to True in 1.3

Update docs for this and other omissions.
patch-2
Neil Booth 7 years ago
parent
commit
7c82d1fe5f
  1. 16
      docs/protocol-changes.rst
  2. 105
      docs/protocol-methods.rst
  3. 1
      docs/protocol.rst
  4. 9
      electrumx/server/session.py

16
docs/protocol-changes.rst

@ -86,6 +86,17 @@ Deprecated methods
Version 1.3 Version 1.3
=========== ===========
Changes
-------
* :func:`blockchain.headers.subscribe` argument *raw* switches default to
:const:`True`
New methods
-----------
* :func:`blockchain.block.header`
Removed methods Removed methods
--------------- ---------------
@ -95,11 +106,6 @@ Removed methods
* :func:`blockchain.address.listunspent` * :func:`blockchain.address.listunspent`
* :func:`blockchain.address.subscribe` * :func:`blockchain.address.subscribe`
New methods
-----------
* :func:`blockchain.block.header`
Deprecated methods Deprecated methods
------------------ ------------------

105
docs/protocol-methods.rst

@ -2,104 +2,6 @@
Protocol Methods 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 <status>` of the address.
**Notifications**
As this is a subcription, the client will receive a notification
when the :ref:`status <status>` of the address changes. Its
signature is
.. function:: blockchain.address.subscribe(address, status)
blockchain.block.get_header blockchain.block.get_header
=========================== ===========================
@ -171,6 +73,7 @@ Return the block header at the given height.
**Signature** **Signature**
.. function:: blockchain.block.header(height) .. function:: blockchain.block.header(height)
.. versionadded:: 1.3
*height* *height*
@ -268,9 +171,11 @@ Subscribe to receive block headers when a new block is found.
**Signature** **Signature**
.. function:: blockchain.headers.subscribe(raw=False) .. function:: blockchain.headers.subscribe(raw=True)
.. versionchanged:: 1.2 .. 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* * *raw*

1
docs/protocol.rst

@ -10,3 +10,4 @@ alike.
protocol-basics protocol-basics
protocol-methods protocol-methods
protocol-changes protocol-changes
protocol-removed

9
electrumx/server/session.py

@ -217,13 +217,17 @@ class ElectrumX(SessionBase):
return {'hex': raw_header.hex(), 'height': height} return {'hex': raw_header.hex(), 'height': height}
return self.controller.electrum_header(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.''' '''Subscribe to get headers of new blocks.'''
self.subscribe_headers = True self.subscribe_headers = True
self.subscribe_headers_raw = self.assert_boolean(raw) self.subscribe_headers_raw = self.assert_boolean(raw)
self.notified_height = self.height() self.notified_height = self.height()
return self.subscribe_headers_result(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): async def add_peer(self, features):
'''Add a peer (but only if the peer resolves to the source).''' '''Add a peer (but only if the peer resolves to the source).'''
peer_mgr = self.controller.peer_mgr peer_mgr = self.controller.peer_mgr
@ -433,7 +437,6 @@ class ElectrumX(SessionBase):
'blockchain.block.get_chunk': self.block_get_chunk, 'blockchain.block.get_chunk': self.block_get_chunk,
'blockchain.block.get_header': controller.block_get_header, 'blockchain.block.get_header': controller.block_get_header,
'blockchain.estimatefee': controller.estimatefee, 'blockchain.estimatefee': controller.estimatefee,
'blockchain.headers.subscribe': self.headers_subscribe,
'blockchain.relayfee': controller.relayfee, 'blockchain.relayfee': controller.relayfee,
'blockchain.scripthash.get_balance': 'blockchain.scripthash.get_balance':
controller.scripthash_get_balance, controller.scripthash_get_balance,
@ -468,9 +471,11 @@ class ElectrumX(SessionBase):
if ptuple >= (1, 3): if ptuple >= (1, 3):
handlers.update({ handlers.update({
'blockchain.block.header': self.block_header, 'blockchain.block.header': self.block_header,
'blockchain.headers.subscribe': self.headers_subscribe,
}) })
else: else:
handlers.update({ handlers.update({
'blockchain.headers.subscribe': self.headers_subscribe_old,
'blockchain.address.get_balance': 'blockchain.address.get_balance':
controller.address_get_balance, controller.address_get_balance,
'blockchain.address.get_history': 'blockchain.address.get_history':

Loading…
Cancel
Save