initialize TX_COUNTS_STATE from existing TX_COUNT_PREFIX

This commit is contained in:
Jack Robison 2020-12-01 17:01:46 -05:00
parent c03b1b5a93
commit ede167bb56
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 5 additions and 3 deletions

View file

@ -131,7 +131,7 @@ class Ledger(metaclass=LedgerRegistry):
self._on_transaction_controller = StreamController()
self.on_transaction = self._on_transaction_controller.stream
self.on_transaction.listen(
lambda e: log.info(
lambda e: log.debug(
'(%s) on_transaction: address=%s, height=%s, is_verified=%s, tx.id=%s',
self.get_id(), e.address, e.tx.height, e.tx.is_verified, e.tx.id
)

View file

@ -74,9 +74,11 @@ class RocksReaderContext:
def update_state(self):
tx_counts = array.array("L")
counts = self.db.get(TX_COUNTS_STATE)
if counts:
if not counts:
self.tx_counts = list(map(unpack_be_uint64, self.db.iterator(prefix=TX_COUNT_PREFIX, include_key=False)))
else:
tx_counts.frombytes(counts)
self.tx_counts = tx_counts.tolist()
self.tx_counts = tx_counts.tolist()
def ctx_tx_hash(self, tx_num):
tx_height = bisect_right(self.tx_counts, tx_num)