examples: Rewrite get_storage() not to create empty entries

This commit is contained in:
Paweł Bylica 2019-11-26 23:27:56 +01:00
parent ca74d1969f
commit 168c77457f
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
1 changed files with 7 additions and 3 deletions

View File

@ -59,9 +59,13 @@ public:
evmc::bytes32 get_storage(const evmc::address& addr, const evmc::bytes32& key) noexcept final
{
auto it = accounts.find(addr);
if (it != accounts.end())
return it->second.storage[key];
const auto account_iter = accounts.find(addr);
if (account_iter == accounts.end())
return {};
const auto storage_iter = account_iter->second.storage.find(key);
if (storage_iter != account_iter->second.storage.end())
return storage_iter->second;
return {};
}