From: CryptoManiac Date: Mon, 27 Jul 2015 07:55:04 +0000 (+0300) Subject: Merge pull request #3 from fsb4000/master X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=83c23065055998912c661ff49edf93568c488689;hp=c1bac19595bfadc2620216ce89255a6f68b20198 Merge pull request #3 from fsb4000/master обработка исключения при реорге --- 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: