flush_data() must be called with the lock held
This commit is contained in:
parent
967b2de60d
commit
635ffed42b
@ -246,17 +246,19 @@ class BlockProcessor(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
return await self.daemon.raw_blocks(hex_hashes)
|
return await self.daemon.raw_blocks(hex_hashes)
|
||||||
|
|
||||||
|
def flush_backup():
|
||||||
|
# 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)
|
||||||
|
|
||||||
start, last, hashes = await self.reorg_hashes(count)
|
start, last, hashes = await self.reorg_hashes(count)
|
||||||
# Reverse and convert to hex strings.
|
# Reverse and convert to hex strings.
|
||||||
hashes = [hash_to_hex_str(hash) for hash in reversed(hashes)]
|
hashes = [hash_to_hex_str(hash) for hash in reversed(hashes)]
|
||||||
for hex_hashes in chunks(hashes, 50):
|
for hex_hashes in chunks(hashes, 50):
|
||||||
raw_blocks = await get_raw_blocks(last, hex_hashes)
|
raw_blocks = await get_raw_blocks(last, hex_hashes)
|
||||||
await self.run_in_thread_with_lock(self.backup_blocks, raw_blocks)
|
await self.run_in_thread_with_lock(self.backup_blocks, raw_blocks)
|
||||||
# self.touched can include other addresses which is
|
await self.run_in_thread_with_lock(flush_backup)
|
||||||
# harmless, but remove None.
|
|
||||||
self.touched.discard(None)
|
|
||||||
await self.run_in_thread_with_lock(
|
|
||||||
self.db.flush_backup, self.flush_data(), self.touched)
|
|
||||||
last -= len(raw_blocks)
|
last -= len(raw_blocks)
|
||||||
await self.prefetcher.reset_height(self.height)
|
await self.prefetcher.reset_height(self.height)
|
||||||
|
|
||||||
@ -319,14 +321,17 @@ class BlockProcessor(object):
|
|||||||
|
|
||||||
# - Flushing
|
# - Flushing
|
||||||
def flush_data(self):
|
def flush_data(self):
|
||||||
|
'''The data for a flush. The lock must be taken.'''
|
||||||
|
assert self.state_lock.locked()
|
||||||
return FlushData(self.height, self.tx_count, self.headers,
|
return FlushData(self.height, self.tx_count, self.headers,
|
||||||
self.tx_hashes, self.undo_infos, self.utxo_cache,
|
self.tx_hashes, self.undo_infos, self.utxo_cache,
|
||||||
self.db_deletes, self.tip)
|
self.db_deletes, self.tip)
|
||||||
|
|
||||||
async def flush(self, flush_utxos):
|
async def flush(self, flush_utxos):
|
||||||
await self.run_in_thread_with_lock(
|
def flush():
|
||||||
self.db.flush_dbs, self.flush_data(), flush_utxos,
|
self.db.flush_dbs(self.flush_data(), flush_utxos,
|
||||||
self.estimate_txs_remaining)
|
self.estimate_txs_remaining)
|
||||||
|
await self.run_in_thread_with_lock(flush)
|
||||||
|
|
||||||
async def _maybe_flush(self):
|
async def _maybe_flush(self):
|
||||||
# If caught up, flush everything as client queries are
|
# If caught up, flush everything as client queries are
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user