@@ -273,16 +273,12 @@ api::SealedTransaction APIHandler::convertTransaction(const csdb::Transaction& t
273273 csdb::Currency currency = transaction.currency ();
274274 csdb::Address address = transaction.source ();
275275 if (address.is_wallet_id ()) {
276- BlockChain::WalletData data_to_fetch_pulic_key;
277- s_blockchain.findWalletData (transaction.source ().wallet_id (), data_to_fetch_pulic_key);
278- address = csdb::Address::from_public_key (data_to_fetch_pulic_key.address_ );
276+ address = s_blockchain.getAddressByType (transaction.source (), BlockChain::AddressType::PublicKey);
279277 }
280278
281279 csdb::Address target = transaction.target ();
282280 if (target.is_wallet_id ()) {
283- BlockChain::WalletData data_to_fetch_pulic_key;
284- s_blockchain.findWalletData (transaction.target ().wallet_id (), data_to_fetch_pulic_key);
285- target = csdb::Address::from_public_key (data_to_fetch_pulic_key.address_ );
281+ target = s_blockchain.getAddressByType (transaction.target (), BlockChain::AddressType::PublicKey);
286282 }
287283
288284 result.id = convert_transaction_id (transaction.id ());
@@ -1055,7 +1051,23 @@ bool APIHandler::updateSmartCachesTransaction(csdb::Transaction trxn, cs::Sequen
10551051 }
10561052
10571053 HashState res;
1058- { // signal to end waiting for a transaction
1054+ res.hash = cs::Zero::hash;
1055+ std::string newStateStr;
1056+ if (trxn.user_field_ids ().count (cs::trx_uf::new_state::RetVal) > 0 ) {
1057+ res.retVal = trxn.user_field (cs::trx_uf::new_state::RetVal).template value <std::string>();
1058+ }
1059+
1060+ general::Variant var;
1061+ if (!res.retVal .empty ()) {
1062+ std::string tmp = res.retVal ;
1063+ var = deserialize<general::Variant>(std::move (tmp));
1064+ }
1065+
1066+ if (trxn.user_field_ids ().count (cs::trx_uf::new_state::Value) > 0 ) {
1067+ // new_state value, not hash!
1068+ newStateStr = trxn.user_field (cs::trx_uf::new_state::Value).template value <std::string>();
1069+ }
1070+ else { // signal to end waiting for a transaction
10591071 auto hashStateInst (lockedReference (this ->hashStateSL ));
10601072 (*hashStateInst)[target_pk].updateHash ([&](const HashState& oldHash) {
10611073 auto newHashStr = trxn.user_field (cs::trx_uf::new_state::Hash).template value <std::string>();
@@ -1068,16 +1080,18 @@ bool APIHandler::updateSmartCachesTransaction(csdb::Transaction trxn, cs::Sequen
10681080 });
10691081 }
10701082
1071- if (res.hash != cs::Zero::hash) { // update tokens
1083+ if (!newStateStr. empty () || res.hash != cs::Zero::hash) { // update tokens
10721084 auto caller_pk = s_blockchain.getAddressByType (execTrans.source (), BlockChain::AddressType::PublicKey);
10731085
10741086 if (is_smart_deploy (smart))
10751087 tm.checkNewDeploy (target_pk, caller_pk, smart);
10761088
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);
1089+ if (newStateStr.empty ()) {
1090+ newStateStr = cs::SmartContracts::get_contract_state (s_blockchain, target_pk);
1091+ }
1092+ if (!newStateStr.empty ()) {
1093+ tm.checkNewState (target_pk, caller_pk, smart, newStateStr);
1094+ }
10811095 }
10821096 }
10831097 }
@@ -1960,9 +1974,9 @@ void APIHandler::TokensListGet(api::TokensListResult& _return, int64_t offset, i
19601974}
19611975
19621976// ////////Wallets
1963- typedef std::list<std::pair<const cs::WalletsCache::WalletData::Address *, const cs::WalletsCache::WalletData*>> WCSortedList;
1977+ typedef std::list<std::pair<const cs::PublicKey *, const cs::WalletsCache::WalletData*>> WCSortedList;
19641978template <typename T>
1965- void walletStep (const cs::WalletsCache::WalletData::Address * addr, const cs::WalletsCache::WalletData* wd, const uint64_t num,
1979+ void walletStep (const cs::PublicKey * addr, const cs::WalletsCache::WalletData* wd, const uint64_t num,
19661980 std::function<const T&(const cs::WalletsCache::WalletData&)> getter, std::function<bool(const T&, const T&)> comparator, WCSortedList& lst) {
19671981 assert (num > 0 );
19681982
@@ -1987,7 +2001,7 @@ void iterateOverWallets(std::function<const T&(const cs::WalletsCache::WalletDat
19872001 using Comparer = std::function<bool (const T&, const T&)>;
19882002 Comparer comparator = desc ? Comparer (std::greater<T>()) : Comparer (std::less<T>());
19892003
1990- bc.iterateOverWallets ([&lst, num, getter, comparator](const cs::WalletsCache::WalletData::Address & addr, const cs::WalletsCache::WalletData& wd) {
2004+ bc.iterateOverWallets ([&lst, num, getter, comparator](const cs::PublicKey & addr, const cs::WalletsCache::WalletData& wd) {
19912005 if (!addr.empty () && wd.balance_ >= csdb::Amount (0 )) {
19922006 walletStep (&addr, &wd, num, getter, comparator, lst);
19932007 }
@@ -2051,7 +2065,7 @@ void APIHandler::TrustedGet(TrustedGetResult& _return, int32_t _page) {
20512065 uint32_t limit = PER_PAGE;
20522066 uint32_t total = 0 ;
20532067
2054- s_blockchain.iterateOverWriters ([&_return, &offset, &limit, &total](const cs::WalletsCache::WalletData::Address & addr, const cs::WalletsCache::TrustedData& wd) {
2068+ s_blockchain.iterateOverWriters ([&_return, &offset, &limit, &total](const cs::PublicKey & addr, const cs::WalletsCache::TrustedData& wd) {
20552069 if (addr.empty ()) {
20562070 return true ;
20572071 }
0 commit comments