Move flush_state() to db.py
This commit is contained in:
parent
d1510b1192
commit
d3f9ba386c
@ -160,7 +160,6 @@ class BlockProcessor(electrumx.server.db.DB):
|
||||
|
||||
# Meta
|
||||
self.next_cache_check = 0
|
||||
self.last_flush = time.time()
|
||||
self.touched = set()
|
||||
self.reorg_count = 0
|
||||
|
||||
@ -313,14 +312,6 @@ class BlockProcessor(electrumx.server.db.DB):
|
||||
|
||||
return start, count
|
||||
|
||||
def flush_state(self, batch):
|
||||
'''Flush chain state to the batch.'''
|
||||
now = time.time()
|
||||
self.wall_time += now - self.last_flush
|
||||
self.last_flush = now
|
||||
self.last_flush_tx_count = self.tx_count
|
||||
self.write_utxo_state(batch)
|
||||
|
||||
def assert_flushed(self):
|
||||
'''Asserts state is fully flushed.'''
|
||||
assert not self.undo_infos
|
||||
@ -725,7 +716,6 @@ class BlockProcessor(electrumx.server.db.DB):
|
||||
self.height = self.db_height
|
||||
self.tip = self.db_tip
|
||||
self.tx_count = self.db_tx_count
|
||||
self.last_flush_tx_count = self.tx_count
|
||||
|
||||
# --- External API
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@ class DB(object):
|
||||
self.history = History()
|
||||
self.utxo_db = None
|
||||
self.tx_counts = None
|
||||
self.last_flush = time.time()
|
||||
|
||||
self.logger.info(f'using {self.env.db_engine} for DB backend')
|
||||
|
||||
@ -232,6 +233,14 @@ class DB(object):
|
||||
self.db_tx_count = to_tx_count
|
||||
self.db_tip = to_tip
|
||||
|
||||
def flush_state(self, batch):
|
||||
'''Flush chain state to the batch.'''
|
||||
now = time.time()
|
||||
self.wall_time += now - self.last_flush
|
||||
self.last_flush = now
|
||||
self.last_flush_tx_count = self.fs_tx_count
|
||||
self.write_utxo_state(batch)
|
||||
|
||||
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
|
||||
@ -441,6 +450,7 @@ class DB(object):
|
||||
# These are our state as we move ahead of DB state
|
||||
self.fs_height = self.db_height
|
||||
self.fs_tx_count = self.db_tx_count
|
||||
self.last_flush_tx_count = self.fs_tx_count
|
||||
|
||||
# Log some stats
|
||||
self.logger.info('DB version: {:d}'.format(self.db_version))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user