Skip to content

Commit

Permalink
Merge pull request #3 from fsb4000/master
Browse files Browse the repository at this point in the history
обработка исключения при реорге
  • Loading branch information
CryptoManiac committed Jul 27, 2015
2 parents c1bac19 + e7eb59d commit 83c2306
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions backends/bitcoind/blockchain_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,19 @@ def catch_up(self, sync=True):
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:

Expand Down

0 comments on commit 83c2306

Please sign in to comment.