def update_state(self, txn, prev_result, request, is_committed=False): try: payload = get_payload_data(txn) seq_no = get_seq_no(txn) for output in payload[OUTPUTS]: TokenStaticHelper.add_new_output( self.state, self.database_manager.get_store(UTXO_CACHE_LABEL), Output(output["address"], seq_no, output["amount"]), is_committed=is_committed) except UTXOError as ex: error = 'Exception {} while updating state'.format(ex) raise OperationError(error)
def update_token_state(self, txn, request, is_committed=False): for utxo in txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA][INPUTS]: TokenStaticHelper.spend_input(state=self.token_state, utxo_cache=self.utxo_cache, address=utxo[ADDRESS], seq_no=utxo[SEQNO], is_committed=is_committed) seq_no = get_seq_no(txn) for output in txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA][OUTPUTS]: TokenStaticHelper.add_new_output(state=self.token_state, utxo_cache=self.utxo_cache, output=Output( output[ADDRESS], seq_no, output[AMOUNT]), is_committed=is_committed)
def update_state(self, txn, prev_result, request, is_committed=False): try: payload = get_payload_data(txn) for inp in payload[INPUTS]: TokenStaticHelper.spend_input(self.state, self.utxo_cache, inp["address"], inp["seqNo"], is_committed=is_committed) for output in payload[OUTPUTS]: seq_no = get_seq_no(txn) TokenStaticHelper.add_new_output(self.state, self.utxo_cache, Output( output["address"], seq_no, output["amount"]), is_committed=is_committed) except UTXOError as ex: error = 'Exception {} while updating state'.format(ex) raise OperationError(error)