From 5d58b44bc8895350d5aa70da6b71f0ade8847960 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Fri, 15 Mar 2024 10:14:17 +0300 Subject: [PATCH] [#1044] node: Drop unused methods from APE implementation Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/config.go | 2 +- cmd/frostfs-node/policy_engine.go | 40 ++++--------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 424970b8f..a1f7bba40 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -1076,7 +1076,7 @@ func initAccessPolicyEngine(_ context.Context, c *cfg) { ) } - var morphRuleStorage policy_engine.MorphRuleChainStorage + var morphRuleStorage policy_engine.MorphRuleChainStorageReader morphRuleStorage = policy_client.NewContractStorage( client.NewSwitchRPCGuardedActor(c.cfgMorph.client), c.cfgObject.cfgAccessPolicyEngine.policyContractHash) diff --git a/cmd/frostfs-node/policy_engine.go b/cmd/frostfs-node/policy_engine.go index 100520f50..13e30a17e 100644 --- a/cmd/frostfs-node/policy_engine.go +++ b/cmd/frostfs-node/policy_engine.go @@ -19,14 +19,10 @@ type accessPolicyEngine struct { chainRouter engine.ChainRouter - morphChainStorage engine.MorphRuleChainStorage - localOverrideDatabase chainbase.LocalOverrideDatabase } -var _ engine.LocalOverrideEngine = (*accessPolicyEngine)(nil) - -var _ engine.MorphRuleChainStorage = (*morphAPEChainCache)(nil) +var _ engine.MorphRuleChainStorageReader = (*morphAPEChainCache)(nil) type morphAPEChainCacheKey struct { name chain.Name @@ -34,22 +30,17 @@ type morphAPEChainCacheKey struct { } type morphAPEChainCache struct { - source engine.MorphRuleChainStorage + source engine.MorphRuleChainStorageReader cache *expirable.LRU[morphAPEChainCacheKey, []*chain.Chain] } -func newMorphCache(source engine.MorphRuleChainStorage, size int, ttl time.Duration) engine.MorphRuleChainStorage { +func newMorphCache(source engine.MorphRuleChainStorageReader, size int, ttl time.Duration) engine.MorphRuleChainStorageReader { return &morphAPEChainCache{ source: source, cache: expirable.NewLRU(size, func(morphAPEChainCacheKey, []*chain.Chain) {}, ttl), } } -func (m *morphAPEChainCache) AddMorphRuleChain(name chain.Name, target engine.Target, c *chain.Chain) (util.Uint256, uint32, error) { - m.cache.Remove(morphAPEChainCacheKey{name: name, target: target}) - return m.source.AddMorphRuleChain(name, target, c) -} - func (m *morphAPEChainCache) GetAdmin() (util.Uint160, error) { return m.source.GetAdmin() } @@ -70,26 +61,12 @@ func (m *morphAPEChainCache) ListMorphRuleChains(name chain.Name, target engine. return result, nil } -func (m *morphAPEChainCache) RemoveMorphRuleChain(name chain.Name, target engine.Target, chainID chain.ID) (util.Uint256, uint32, error) { - m.cache.Remove(morphAPEChainCacheKey{name: name, target: target}) - return m.source.RemoveMorphRuleChain(name, target, chainID) -} - -func (m *morphAPEChainCache) SetAdmin(addr util.Uint160) (util.Uint256, uint32, error) { - return m.source.SetAdmin(addr) -} - func (m *morphAPEChainCache) ListTargetsIterator(targetType engine.TargetType) (uuid.UUID, result.Iterator, error) { return m.source.ListTargetsIterator(targetType) } -func (m *morphAPEChainCache) RemoveMorphRuleChainsByTarget(name chain.Name, target engine.Target) (util.Uint256, uint32, error) { - m.cache.Remove(morphAPEChainCacheKey{name: name, target: target}) - return m.source.RemoveMorphRuleChainsByTarget(name, target) -} - func newAccessPolicyEngine( - morphChainStorage engine.MorphRuleChainStorage, + morphChainStorage engine.MorphRuleChainStorageReader, localOverrideDatabase chainbase.LocalOverrideDatabase, ) *accessPolicyEngine { return &accessPolicyEngine{ @@ -98,8 +75,6 @@ func newAccessPolicyEngine( localOverrideDatabase, ), - morphChainStorage: morphChainStorage, - localOverrideDatabase: localOverrideDatabase, } } @@ -111,13 +86,6 @@ func (a *accessPolicyEngine) IsAllowed(name chain.Name, target engine.RequestTar return a.chainRouter.IsAllowed(name, target, r) } -func (a *accessPolicyEngine) MorphRuleChainStorage() engine.MorphRuleChainStorage { - a.mtx.Lock() - defer a.mtx.Unlock() - - return a.morphChainStorage -} - func (a *accessPolicyEngine) LocalStorage() engine.LocalOverrideStorage { a.mtx.Lock() defer a.mtx.Unlock() -- 2.45.2