[#1044] node: Drop unused methods from APE implementation
All checks were successful
DCO action / DCO (pull_request) Successful in 1m23s
Build / Build Components (1.21) (pull_request) Successful in 3m26s
Vulncheck / Vulncheck (pull_request) Successful in 3m31s
Build / Build Components (1.20) (pull_request) Successful in 4m25s
Tests and linters / Staticcheck (pull_request) Successful in 5m40s
Tests and linters / gopls check (pull_request) Successful in 5m46s
Tests and linters / Lint (pull_request) Successful in 6m17s
Tests and linters / Tests (1.20) (pull_request) Successful in 8m30s
Tests and linters / Tests with -race (pull_request) Successful in 8m34s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m0s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m23s
Build / Build Components (1.21) (pull_request) Successful in 3m26s
Vulncheck / Vulncheck (pull_request) Successful in 3m31s
Build / Build Components (1.20) (pull_request) Successful in 4m25s
Tests and linters / Staticcheck (pull_request) Successful in 5m40s
Tests and linters / gopls check (pull_request) Successful in 5m46s
Tests and linters / Lint (pull_request) Successful in 6m17s
Tests and linters / Tests (1.20) (pull_request) Successful in 8m30s
Tests and linters / Tests with -race (pull_request) Successful in 8m34s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m0s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
6bf77cabd4
commit
5d58b44bc8
2 changed files with 5 additions and 37 deletions
|
@ -1076,7 +1076,7 @@ func initAccessPolicyEngine(_ context.Context, c *cfg) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var morphRuleStorage policy_engine.MorphRuleChainStorage
|
var morphRuleStorage policy_engine.MorphRuleChainStorageReader
|
||||||
morphRuleStorage = policy_client.NewContractStorage(
|
morphRuleStorage = policy_client.NewContractStorage(
|
||||||
client.NewSwitchRPCGuardedActor(c.cfgMorph.client),
|
client.NewSwitchRPCGuardedActor(c.cfgMorph.client),
|
||||||
c.cfgObject.cfgAccessPolicyEngine.policyContractHash)
|
c.cfgObject.cfgAccessPolicyEngine.policyContractHash)
|
||||||
|
|
|
@ -19,14 +19,10 @@ type accessPolicyEngine struct {
|
||||||
|
|
||||||
chainRouter engine.ChainRouter
|
chainRouter engine.ChainRouter
|
||||||
|
|
||||||
morphChainStorage engine.MorphRuleChainStorage
|
|
||||||
|
|
||||||
localOverrideDatabase chainbase.LocalOverrideDatabase
|
localOverrideDatabase chainbase.LocalOverrideDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ engine.LocalOverrideEngine = (*accessPolicyEngine)(nil)
|
var _ engine.MorphRuleChainStorageReader = (*morphAPEChainCache)(nil)
|
||||||
|
|
||||||
var _ engine.MorphRuleChainStorage = (*morphAPEChainCache)(nil)
|
|
||||||
|
|
||||||
type morphAPEChainCacheKey struct {
|
type morphAPEChainCacheKey struct {
|
||||||
name chain.Name
|
name chain.Name
|
||||||
|
@ -34,22 +30,17 @@ type morphAPEChainCacheKey struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type morphAPEChainCache struct {
|
type morphAPEChainCache struct {
|
||||||
source engine.MorphRuleChainStorage
|
source engine.MorphRuleChainStorageReader
|
||||||
cache *expirable.LRU[morphAPEChainCacheKey, []*chain.Chain]
|
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{
|
return &morphAPEChainCache{
|
||||||
source: source,
|
source: source,
|
||||||
cache: expirable.NewLRU(size, func(morphAPEChainCacheKey, []*chain.Chain) {}, ttl),
|
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) {
|
func (m *morphAPEChainCache) GetAdmin() (util.Uint160, error) {
|
||||||
return m.source.GetAdmin()
|
return m.source.GetAdmin()
|
||||||
}
|
}
|
||||||
|
@ -70,26 +61,12 @@ func (m *morphAPEChainCache) ListMorphRuleChains(name chain.Name, target engine.
|
||||||
return result, nil
|
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) {
|
func (m *morphAPEChainCache) ListTargetsIterator(targetType engine.TargetType) (uuid.UUID, result.Iterator, error) {
|
||||||
return m.source.ListTargetsIterator(targetType)
|
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(
|
func newAccessPolicyEngine(
|
||||||
morphChainStorage engine.MorphRuleChainStorage,
|
morphChainStorage engine.MorphRuleChainStorageReader,
|
||||||
localOverrideDatabase chainbase.LocalOverrideDatabase,
|
localOverrideDatabase chainbase.LocalOverrideDatabase,
|
||||||
) *accessPolicyEngine {
|
) *accessPolicyEngine {
|
||||||
return &accessPolicyEngine{
|
return &accessPolicyEngine{
|
||||||
|
@ -98,8 +75,6 @@ func newAccessPolicyEngine(
|
||||||
localOverrideDatabase,
|
localOverrideDatabase,
|
||||||
),
|
),
|
||||||
|
|
||||||
morphChainStorage: morphChainStorage,
|
|
||||||
|
|
||||||
localOverrideDatabase: localOverrideDatabase,
|
localOverrideDatabase: localOverrideDatabase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,13 +86,6 @@ func (a *accessPolicyEngine) IsAllowed(name chain.Name, target engine.RequestTar
|
||||||
return a.chainRouter.IsAllowed(name, target, r)
|
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 {
|
func (a *accessPolicyEngine) LocalStorage() engine.LocalOverrideStorage {
|
||||||
a.mtx.Lock()
|
a.mtx.Lock()
|
||||||
defer a.mtx.Unlock()
|
defer a.mtx.Unlock()
|
||||||
|
|
Loading…
Reference in a new issue