add namespaces to the grants cache

This commit is contained in:
Richard Holland
2026-06-05 15:43:38 +10:00
parent 1b6da60399
commit e9a2e71124
2 changed files with 4 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
#include <memory>
#include <optional>
#include <queue>
#include <tuple>
#include <vector>
#include <wasmedge/wasmedge.h>
@@ -174,7 +175,7 @@ struct HookResult
false; // hook_again allows strong pre-apply to nominate
// additional weak post-apply execution
std::shared_ptr<STObject const> provisionalMeta;
std::set<AccountID>
std::set<std::tuple<AccountID, uint256 /* namespace */>>
foreignStateGrantCache; // add found grants here to avoid rechecking
};

View File

@@ -1940,7 +1940,7 @@ HookAPI::state_foreign_set(
// check if we've used a grant to modify this state entry before, if not
// look up possible grants
if (!hasFix ||
hookCtx.result.foreignStateGrantCache.find(account) ==
hookCtx.result.foreignStateGrantCache.find({account, ns}) ==
hookCtx.result.foreignStateGrantCache.end())
{
auto const sle =
@@ -2016,7 +2016,7 @@ HookAPI::state_foreign_set(
}
// add the grant to the cache
hookCtx.result.foreignStateGrantCache.emplace(account);
hookCtx.result.foreignStateGrantCache.emplace(account, ns);
}
if (auto ret = set_state_cache(account, ns, key, data, true);