Skip to content

Commit

Permalink
Tweak use of self.ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Oct 20, 2021
1 parent 7d12c95 commit 903cb72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions electrumx/server/block_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def __init__(self, env, db, daemon, notifications):
self.coin = env.coin

self.caught_up = False
self.ok = False
self.ok = True
self.touched = set()
# A count >= 0 is a user-forced reorg; < 0 is a natural reorg
self.reorg_count = None
Expand Down Expand Up @@ -498,12 +498,12 @@ def advance_block(self, block):
to_le_uint32 = pack_le_uint32
to_le_uint64 = pack_le_uint64

self.ok = False
with block as block:
if self.coin.header_prevhash(block.header) != self.state.tip:
self.reorg_count = -1
return

self.ok = False
for tx, tx_hash in block.iter_txs():
hashXs = []
append_hashX = hashXs.append
Expand Down Expand Up @@ -573,6 +573,7 @@ def backup_block(self, block):

count = 0
with block as block:
self.ok = False
for tx, tx_hash in block.iter_txs_reversed():
for idx, txout in enumerate(tx.outputs):
# Spend the TX outputs. Be careful with unspendable
Expand Down Expand Up @@ -606,6 +607,7 @@ def backup_block(self, block):
# self.touched can include other addresses which is harmless, but remove None.
self.touched.discard(None)
self.db.flush_backup(self.flush_data(), self.touched)
self.ok = True

'''An in-memory UTXO cache, representing all changes to UTXO state
since the last DB flush.
Expand Down

0 comments on commit 903cb72

Please sign in to comment.