def get_tx_metadata(db, state_code, txhash: bytes): try: tx_metadata = db.get(str(state_code) + bin2hstr(txhash)) except Exception: return None if tx_metadata is None: return None txn_json, block_number, _ = tx_metadata return Transaction.from_json(txn_json), block_number
def get_txn_count(db, state_code, addr): try: return db.get(state_code + b'txn_count_' + addr) except KeyError: pass except Exception as e: # FIXME: Review logger.error('Exception in get_txn_count') logger.exception(e) return 0
def get_last_txs(db, state_code) -> list: try: last_txn = db.get(state_code + b'last_txn') except: # noqa return [] txs = [] for tx_metadata in last_txn: tx_json, block_num, block_ts = tx_metadata tx = Transaction.from_json(tx_json) txs.append(tx) return txs
def get_state_version(db, state_code): try: return db.get(state_code + b'state_version') except KeyError: return 0