From 1405057096c3d9c1b721ed4183bce909c5c28f9d Mon Sep 17 00:00:00 2001 From: Johann Bauer Date: Wed, 9 Nov 2016 18:07:25 +0100 Subject: [PATCH 1/4] Fix getting the number of watched addresses Resolves #13 --- server/protocol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/protocol.py b/server/protocol.py index 0ea78f6..5f5ae54 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -331,8 +331,8 @@ class ElectrumX(JSONRPC): @classmethod def watched_address_count(cls): - sessions = self.SESSION_MGR.sessions - return sum(len(session.hash168s) for session in session + sessions = cls.SESSION_MGR.sessions + return sum(len(session.hash168s) for session in sessions if isinstance(session, cls)) @classmethod From 06b6d695c2d9bb54ce13785f44f7a5f10c27dd76 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 10 Nov 2016 07:32:39 +0900 Subject: [PATCH 2/4] Only attempt to flush if cancelled --- server/block_processor.py | 3 ++- server/db.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/block_processor.py b/server/block_processor.py index feb4eee..2238aae 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -382,8 +382,9 @@ class BlockProcessor(server.db.DB): while True: await self._wait_for_update() await asyncio.sleep(0) # Yield - finally: + except asyncio.CancelledError: self.flush(True) + raise async def _wait_for_update(self): '''Wait for the prefetcher to deliver blocks or a mempool update. diff --git a/server/db.py b/server/db.py index 414eb75..51b2c59 100644 --- a/server/db.py +++ b/server/db.py @@ -119,7 +119,6 @@ class DB(LoggedClass): if tx_height > self.db_height: return None, tx_height - raise self.DBError('tx_num {:,d} is not on disk') file_pos = tx_num * 32 file_num, offset = divmod(file_pos, self.tx_hash_file_size) From 1737bb83545918b90bf688aea0f84a9b89af96d9 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 10 Nov 2016 07:41:56 +0900 Subject: [PATCH 3/4] Move some code back to correct place Fixes #12 --- server/block_processor.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/block_processor.py b/server/block_processor.py index 2238aae..1eee6b1 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -536,6 +536,9 @@ class BlockProcessor(server.db.DB): self.height - self.db_height)) self.utxo_cache.flush(batch) self.utxo_flush_count = self.flush_count + self.db_tx_count = self.tx_count + self.db_height = self.height + self.db_tip = self.tip def assert_flushed(self): '''Asserts state is fully flushed.''' @@ -573,13 +576,6 @@ class BlockProcessor(server.db.DB): self.flush_state(batch) self.logger.info('committing transaction...') - # Update our in-memory state after successful flush - self.db_tx_count = self.tx_count - self.db_height = self.height - self.db_tip = self.tip - self.tx_hashes = [] - self.headers = [] - # Update and put the wall time again - otherwise we drop the # time it took to commit the batch self.flush_state(self.db) @@ -671,6 +667,8 @@ class BlockProcessor(server.db.DB): os.sync() + self.tx_hashes = [] + self.headers = [] self.logger.info('FS flush took {:.1f} seconds' .format(time.time() - flush_start)) From bf6a8f58d5caab2a1d27c511dbd11e8dc81986af Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Thu, 10 Nov 2016 07:43:07 +0900 Subject: [PATCH 4/4] Hotfixes for two issues in 0.2.2 --- docs/RELEASE-NOTES | 7 +++++++ server/version.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/RELEASE-NOTES b/docs/RELEASE-NOTES index cf34aed..aea65ec 100644 --- a/docs/RELEASE-NOTES +++ b/docs/RELEASE-NOTES @@ -1,3 +1,10 @@ +Version 0.2.2.1 +--------------- + +- fixes issues #12, #13 +- only attempt to flush on asyncio.CancelledError to avoid spurious + secondary errors + Version 0.2.2 ------------- diff --git a/server/version.py b/server/version.py index 79efc29..e6541a2 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.2.2" +VERSION = "ElectrumX 0.2.2.1"