def add(self, tx: Transaction, block_number: int, timestamp: int): tm = qrlstateinfo_pb2.TransactionMetadata(transaction=tx.pbdata, block_number=block_number, timestamp=timestamp) tmp = self._data.tx_metadata[::-1] tmp.append(tm) del self._data.tx_metadata[:] self._data.tx_metadata.extend(tmp[-20:][::-1])
def __init__(self, pbdata=None): self._data = pbdata if not pbdata: self._data = qrlstateinfo_pb2.TransactionMetadata()
def deserialize(data): pbdata = qrlstateinfo_pb2.TransactionMetadata() pbdata.ParseFromString(bytes(data)) return TransactionMetadata(pbdata)