29 lines
815 B
Go
29 lines
815 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
||
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||
|
policyengine "git.frostfs.info/TrueCloudLab/policy-engine"
|
||
|
)
|
||
|
|
||
|
type apeChainSourceImpl struct {
|
||
|
localChainStorage map[cid.ID]policyengine.CachedChainStorage
|
||
|
}
|
||
|
|
||
|
func NewAPESource() container.AccessPolicyEngineChainSource {
|
||
|
return &apeChainSourceImpl{
|
||
|
localChainStorage: make(map[cid.ID]policyengine.CachedChainStorage),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var _ container.AccessPolicyEngineChainSource = (*apeChainSourceImpl)(nil)
|
||
|
|
||
|
func (c *apeChainSourceImpl) GetChainSource(cid cid.ID) (policyengine.CachedChainStorage, error) {
|
||
|
s, ok := c.localChainStorage[cid]
|
||
|
if ok {
|
||
|
return s, nil
|
||
|
}
|
||
|
c.localChainStorage[cid] = policyengine.NewInMemory()
|
||
|
return c.localChainStorage[cid], nil
|
||
|
}
|