示例#1
0
 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
示例#2
0
    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
示例#3
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
示例#4
0
 def get_state_version(db, state_code):
     try:
         return db.get(state_code + b'state_version')
     except KeyError:
         return 0