From aa6e4ad92285d24517c22a84fb05089752378533 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 5 Nov 2016 13:31:33 +0900 Subject: [PATCH 1/2] Raise on chain reorgs In 0.06 advance_block() returned None instead of True. Cleaner to throw. --- server/block_processor.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/server/block_processor.py b/server/block_processor.py index 34c9bce..6a64d15 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -138,8 +138,14 @@ class Prefetcher(LoggedClass): return blocks, size + class MissingUTXOError(Exception): - pass + '''Raised if a mempool tx input UTXO couldn't be found.''' + + +class ChainReorg(Exception): + '''Raised on a blockchain reorganisation.''' + class MemPool(LoggedClass): '''Representation of the daemon's mempool. @@ -374,14 +380,14 @@ class BlockProcessor(LoggedClass): ''' blocks, mempool_hashes = await self.prefetcher.get_blocks() caught_up = mempool_hashes is not None - for block in blocks: - if self.advance_block(block, caught_up): - await self.handle_chain_reorg() - return - await asyncio.sleep(0) # Yield - - if caught_up: - await self.caught_up(mempool_hashes) + try: + for block in blocks: + self.advance_block(block, caught_up) + await asyncio.sleep(0) # Yield + if caught_up: + await self.caught_up(mempool_hashes) + except ChainReorg: + await self.handle_chain_reorg() async def caught_up(self, mempool_hashes): '''Called after each deamon poll if caught up.''' @@ -711,7 +717,7 @@ class BlockProcessor(LoggedClass): header, tx_hashes, txs = self.coin.read_block(block) prev_hash, header_hash = self.coin.header_hashes(header) if prev_hash != self.tip: - return None + raise ChainReorg touched = set() self.fs_cache.advance_block(header, tx_hashes, txs) From 7019b29baf25db4782e9689db8d1bc88a4ccc02a Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 5 Nov 2016 13:33:34 +0900 Subject: [PATCH 2/2] Release notes --- RELEASE-NOTES | 5 +++++ server/version.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index eba9cdf..f4af83c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,8 @@ +Version 0.07 +------------ + +- fixed a bug introduced in 0.06 at the last minute + Version 0.06 ------------ diff --git a/server/version.py b/server/version.py index 8acc7f9..74c926d 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.06" +VERSION = "ElectrumX 0.07"