Move DB undo code to db.py
This commit is contained in:
parent
a5fb9618d6
commit
95a2de6dae
@ -452,18 +452,6 @@ class BlockProcessor(server.db.DB):
|
|||||||
if utxo_MB >= self.utxo_MB or hist_MB >= self.hist_MB:
|
if utxo_MB >= self.utxo_MB or hist_MB >= self.hist_MB:
|
||||||
self.flush(utxo_MB >= self.utxo_MB)
|
self.flush(utxo_MB >= self.utxo_MB)
|
||||||
|
|
||||||
def undo_key(self, height):
|
|
||||||
'''DB key for undo information at the given height.'''
|
|
||||||
return b'U' + pack('>I', height)
|
|
||||||
|
|
||||||
def write_undo_info(self, height, undo_info):
|
|
||||||
'''Write out undo information for the current height.'''
|
|
||||||
self.db.put(self.undo_key(height), undo_info)
|
|
||||||
|
|
||||||
def read_undo_info(self, height):
|
|
||||||
'''Read undo information from a file for the current height.'''
|
|
||||||
return self.db.get(self.undo_key(height))
|
|
||||||
|
|
||||||
def fs_advance_block(self, header, tx_hashes, txs):
|
def fs_advance_block(self, header, tx_hashes, txs):
|
||||||
'''Update unflushed FS state for a new block.'''
|
'''Update unflushed FS state for a new block.'''
|
||||||
prior_tx_count = self.tx_counts[-1] if self.tx_counts else 0
|
prior_tx_count = self.tx_counts[-1] if self.tx_counts else 0
|
||||||
|
|||||||
12
server/db.py
12
server/db.py
@ -188,6 +188,18 @@ class DB(LoggedClass):
|
|||||||
keys.append(key)
|
keys.append(key)
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
|
def undo_key(self, height):
|
||||||
|
'''DB key for undo information at the given height.'''
|
||||||
|
return b'U' + pack('>I', height)
|
||||||
|
|
||||||
|
def write_undo_info(self, height, undo_info):
|
||||||
|
'''Write out undo information for the current height.'''
|
||||||
|
self.db.put(self.undo_key(height), undo_info)
|
||||||
|
|
||||||
|
def read_undo_info(self, height):
|
||||||
|
'''Read undo information from a file for the current height.'''
|
||||||
|
return self.db.get(self.undo_key(height))
|
||||||
|
|
||||||
def open_file(self, filename, create=False):
|
def open_file(self, filename, create=False):
|
||||||
'''Open the file name. Return its handle.'''
|
'''Open the file name. Return its handle.'''
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user