package main import ( "sync" "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 { mtx sync.Mutex 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) { c.mtx.Lock() defer c.mtx.Unlock() s, ok := c.localChainStorage[cid] if ok { return s, nil } c.localChainStorage[cid] = policyengine.NewInMemory() return c.localChainStorage[cid], nil }