@@ -1055,7 +1055,23 @@ bool APIHandler::updateSmartCachesTransaction(csdb::Transaction trxn, cs::Sequen
10551055 }
10561056
10571057 HashState res;
1058- { // signal to end waiting for a transaction
1058+ res.hash = cs::Zero::hash;
1059+ std::string newStateStr;
1060+ if (trxn.user_field_ids ().count (cs::trx_uf::new_state::RetVal) > 0 ) {
1061+ res.retVal = trxn.user_field (cs::trx_uf::new_state::RetVal).template value <std::string>();
1062+ }
1063+
1064+ general::Variant var;
1065+ if (!res.retVal .empty ()) {
1066+ std::string tmp = res.retVal ;
1067+ var = deserialize<general::Variant>(std::move (tmp));
1068+ }
1069+
1070+ if (trxn.user_field_ids ().count (cs::trx_uf::new_state::Value) > 0 ) {
1071+ // new_state value, not hash!
1072+ newStateStr = trxn.user_field (cs::trx_uf::new_state::Value).template value <std::string>();
1073+ }
1074+ else { // signal to end waiting for a transaction
10591075 auto hashStateInst (lockedReference (this ->hashStateSL ));
10601076 (*hashStateInst)[target_pk].updateHash ([&](const HashState& oldHash) {
10611077 auto newHashStr = trxn.user_field (cs::trx_uf::new_state::Hash).template value <std::string>();
@@ -1068,16 +1084,18 @@ bool APIHandler::updateSmartCachesTransaction(csdb::Transaction trxn, cs::Sequen
10681084 });
10691085 }
10701086
1071- if (res.hash != cs::Zero::hash) { // update tokens
1087+ if (!newStateStr. empty () || res.hash != cs::Zero::hash) { // update tokens
10721088 auto caller_pk = s_blockchain.getAddressByType (execTrans.source (), BlockChain::AddressType::PublicKey);
10731089
10741090 if (is_smart_deploy (smart))
10751091 tm.checkNewDeploy (target_pk, caller_pk, smart);
10761092
1077- // state also will be updated in update_smart_state_slot()
1078- std::string newState = cs::SmartContracts::get_contract_state (s_blockchain, target_pk);
1079- if (!newState.empty ())
1080- tm.checkNewState (target_pk, caller_pk, smart, newState);
1093+ if (newStateStr.empty ()) {
1094+ newStateStr = cs::SmartContracts::get_contract_state (s_blockchain, target_pk);
1095+ }
1096+ if (!newStateStr.empty ()) {
1097+ tm.checkNewState (target_pk, caller_pk, smart, newStateStr);
1098+ }
10811099 }
10821100 }
10831101 }
0 commit comments