From e88ea91e89fd4cc8523c189702ae3c3af41a6784 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 14 Dec 2016 21:38:37 +0900 Subject: [PATCH] Defer address notifications whilst processing a block Partial fix of #70 --- server/mempool.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/mempool.py b/server/mempool.py index 36fa664..35cf702 100644 --- a/server/mempool.py +++ b/server/mempool.py @@ -88,7 +88,8 @@ class MemPool(util.LoggedClass): if unprocessed: await process_some(unprocessed) - if self.touched: + # Avoid double notifications if processing a block + if self.touched and not self.processing_new_block(): self.touched_event.set() if not unprocessed: @@ -101,6 +102,10 @@ class MemPool(util.LoggedClass): except DaemonError as e: self.logger.info('ignoring daemon error: {}'.format(e)) + def processing_new_block(self): + '''Return True if we're processing a new block.''' + return self.daemon.cached_height() > self.db.db_height + async def new_hashes(self, unprocessed, unfetched): '''Get the current list of hashes in the daemon's mempool.