X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=blobdiff_plain;f=backends%2Fbitcoind%2Fblockchain_processor.py;fp=backends%2Fbitcoind%2Fblockchain_processor.py;h=1b8d92fd7202dac063c7d99cc23d743672fffc18;hp=7f65aa68aba05c2d38698560a1146a3e021b0861;hb=83c23065055998912c661ff49edf93568c488689;hpb=c1bac19595bfadc2620216ce89255a6f68b20198 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: