From e7eb59d5695bf1e4723fee44c0039a38b8c4ae50 Mon Sep 17 00:00:00 2001 From: fsb4000 Date: Mon, 27 Jul 2015 13:34:58 +0600 Subject: [PATCH] =?utf8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B5=D0=BE=D1=80=D0=B3=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- backends/bitcoind/blockchain_processor.py | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 7f65aa6..1b8d92f 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -620,14 +620,19 @@ class BlockchainProcessor(Processor): self.up_to_date = True break + # fixme: this is unsafe, if we revert when the undo info is not yet written + revert = (random.randint(1, 100) == 1) if self.test_reorgs else False + # not done.. self.up_to_date = False - next_block = self.bitcoind('getblockbynumber', [self.storage.height + 1, True]) - next_block_hash = next_block.get('hash') - self.mtime('daemon') + try: + next_block = self.bitcoind('getblockbynumber', [self.storage.height + 1, True]) + next_block_hash = next_block.get('hash') + except BaseException, e: + revert = True + next_block = next_block.get(self.storage.last_hash) - # fixme: this is unsafe, if we revert when the undo info is not yet written - revert = (random.randint(1, 100) == 1) if self.test_reorgs else False + self.mtime('daemon') if (next_block.get('previousblockhash') == self.storage.last_hash) and not revert: -- 1.7.1