tprotocol: Keep chain tip state. - obelisk - Electrum server using libbitcoin as its backend HTML git clone https://git.parazyd.org/obelisk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 90a851773b817fdc4d19bcd2d1bc72c4e8905c8d DIR parent b9f545ba5ccef32b51b7cc5e32f95891716d0aa2 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 19 Apr 2021 12:18:45 +0200 protocol: Keep chain tip state. Diffstat: M obelisk/protocol.py | 3 +++ 1 file changed, 3 insertions(+), 0 deletions(-) --- DIR diff --git a/obelisk/protocol.py b/obelisk/protocol.py t@@ -63,6 +63,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.endpoints = endpoints self.server_cfg = server_cfg self.loop = asyncio.get_event_loop() + self.chain_tip = 0 # Consider renaming bx to something else self.bx = Client(log, endpoints, self.loop) self.block_queue = None t@@ -307,6 +308,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.log.debug("error: item from block queue len != 3") continue + self.chain_tip = item[1] header = block_to_header(item[2]) params = [{"height": item[1], "hex": safe_hexlify(header)}] await self._send_notification(writer, t@@ -327,6 +329,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.log.debug("Got error: %s", repr(_ec)) return JsonRPCError.internalerror() + self.chain_tip = height self.tasks.append(asyncio.create_task(self.header_notifier(writer))) ret = {"height": height, "hex": safe_hexlify(tip_header)} return {"result": ret}