Move assert_flushed DB logic to db.py

This commit is contained in:
Neil Booth 2018-08-09 07:15:37 +09:00
parent 70319bb22d
commit d87c3dedcf
2 changed files with 8 additions and 3 deletions

View File

@ -324,12 +324,10 @@ class BlockProcessor(electrumx.server.db.DB):
def assert_flushed(self):
'''Asserts state is fully flushed.'''
assert self.tx_count == self.fs_tx_count == self.db_tx_count
assert self.height == self.fs_height == self.db_height
assert not self.undo_infos
assert not self.utxo_cache
assert not self.db_deletes
self.history.assert_flushed()
self.db_assert_flushed(self.tx_count, self.height)
async def flush(self, flush_utxos):
if self.height == self.db_height:

View File

@ -149,6 +149,13 @@ class DB(object):
async def header_branch_and_root(self, length, height):
return await self.header_mc.branch_and_root(length, height)
# Flushing
def db_assert_flushed(self, to_tx_count, to_height):
'''Asserts state is fully flushed.'''
assert to_tx_count == self.fs_tx_count == self.db_tx_count
assert to_height == self.fs_height == self.db_height
self.history.assert_flushed()
def fs_update_header_offsets(self, offset_start, height_start, headers):
if self.coin.STATIC_BLOCK_HEADERS:
return