commit bb3b3a559506c359321194f01c10b8e62d8ba448
parent e0a7f86247dbacccaab12fc4159bec6071058b78
Author: parazyd <parazyd@dyne.org>
Date: Fri, 12 Mar 2021 23:41:29 +0100
Add stub for scripthash subscription.
Diffstat:
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/electrum/synchronizer.py b/electrum/synchronizer.py
@@ -83,7 +83,7 @@ class SynchronizerBase(NetworkJobOnDefaultServer):
await group.spawn(self.main())
finally:
# we are being cancelled now
- # TODO: libbitcoin
+ # TODO: libbitcoin (this would be handled by zeromq.Client.stop()
print("self.session.unsubscribe(self.status_queue)")
def _reset_request_counters(self):
@@ -109,14 +109,12 @@ class SynchronizerBase(NetworkJobOnDefaultServer):
h = address_to_scripthash(addr)
self.scripthash_to_address[h] = addr
self._requests_sent += 1
- try:
- async with self._network_request_semaphore:
- # TODO: libbitcoin
- print("await self.session.subscribe('blockchain.scripthash.subscribe', [h], self.status_queue)")
- except RPCError as e:
- if e.message == 'history too large': # no unique error code
- raise GracefulDisconnect(e, log_level=logging.ERROR) from e
- raise
+ async with self._network_request_semaphore:
+ # TODO: libbitcoin
+ print("await self.session.subscribe('blockchain.scripthash.subscribe', [h], self.status_queue)")
+ # TODO: libbitcoin XXX: Review this, it's probably incorrect
+ print(f"DEBUG: network: subscribe_to_address: {h}")
+ await self.interface.client._subscribe_to_scripthash(h, self.status_queue)
self._requests_answered += 1
self.requested_addrs.remove(addr)
diff --git a/electrum/zeromq.py b/electrum/zeromq.py
@@ -364,6 +364,17 @@ class Client:
# nonce = blockheader[76:80]
queue.put_nowait((seq, height, block_header))
+ async def _subscribe_to_scripthash(self, sh, queue):
+ __("Zeromq Client: _subscribe_to_scripthash (stub)")
+ # TODO: libbitcoin here get history and make status (also review this entire func)
+ # https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-subscribe
+ # https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html#status
+ # https://parazyd.org/git/electrum-obelisk/file/electrumobelisk/protocol.py.html#l57
+ # queue.put_nowait((something,))
+ # while True:
+ # recv and put in queue
+
+
async def block_header(self, index):
"""Fetches the block header by height or integer index"""
__("Zeromq Client: block_header")