[#1278] neofs-node: Use global cached netmap source in services

Signed-off-by: Alex Vanin <alexey@nspcc.ru>

(cherry picked from commit be6ae3c066)
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-03-29 16:52:12 +03:00
parent a193db3a3d
commit 5180e467f8
6 changed files with 13 additions and 14 deletions

View file

@ -116,6 +116,8 @@ type cfg struct {
clientCache *cache.ClientCache
persistate *state.PersistentStorage
netMapSource netmapCore.Source
}
type cfgGRPC struct {
@ -175,8 +177,6 @@ type cfgNodeInfo struct {
}
type cfgObject struct {
netMapSource netmapCore.Source
cnrSource container.Source
eaclSource eacl.Source

View file

@ -105,7 +105,7 @@ func initContainerService(c *cfg) {
loadPlacementBuilder := &loadPlacementBuilder{
log: c.log,
nmSrc: c.cfgNetmap.wrapper,
nmSrc: c.netMapSource,
cnrSrc: cnrSrc,
}

View file

@ -31,7 +31,7 @@ func initControlService(c *cfg) {
controlSvc.WithKey(&c.key.PrivateKey),
controlSvc.WithAuthorizedKeys(rawPubs),
controlSvc.WithHealthChecker(c),
controlSvc.WithNetMapSource(c.cfgNetmap.wrapper),
controlSvc.WithNetMapSource(c.netMapSource),
controlSvc.WithNodeState(c),
controlSvc.WithDeletedObjectHandler(func(addrList []*object.Address) error {
prm := new(engine.DeletePrm).WithAddresses(addrList...)

View file

@ -99,7 +99,7 @@ func initMorphComponents(c *cfg) {
netmapSource = newCachedNetmapStorage(c.cfgNetmap.state, wrap)
}
c.cfgObject.netMapSource = netmapSource
c.netMapSource = netmapSource
c.cfgNetmap.wrapper = wrap
}

View file

@ -185,7 +185,7 @@ func initObjectService(c *cfg) {
clientConstructor := &reputationClientConstructor{
log: c.log,
nmSrc: c.cfgObject.netMapSource,
nmSrc: c.netMapSource,
netState: c.cfgNetmap.state,
trustStorage: c.cfgReputation.localTrustStorage,
basicConstructor: c.clientCache,
@ -228,7 +228,7 @@ func initObjectService(c *cfg) {
policer.WithLocalStorage(ls),
policer.WithContainerSource(c.cfgObject.cnrSource),
policer.WithPlacementBuilder(
placement.NewNetworkMapSourceBuilder(c.cfgObject.netMapSource),
placement.NewNetworkMapSourceBuilder(c.netMapSource),
),
policer.WithRemoteHeader(
headsvc.NewRemoteHeader(keyStorage, clientConstructor),
@ -251,7 +251,7 @@ func initObjectService(c *cfg) {
policer.WithNodeLoader(c),
)
traverseGen := util.NewTraverserGenerator(c.cfgObject.netMapSource, c.cfgObject.cnrSource, c)
traverseGen := util.NewTraverserGenerator(c.netMapSource, c.cfgObject.cnrSource, c)
c.workers = append(c.workers, pol)
@ -261,7 +261,7 @@ func initObjectService(c *cfg) {
putsvc.WithMaxSizeSource(c),
putsvc.WithLocalStorage(ls),
putsvc.WithContainerSource(c.cfgObject.cnrSource),
putsvc.WithNetworkMapSource(c.cfgObject.netMapSource),
putsvc.WithNetworkMapSource(c.netMapSource),
putsvc.WithNetmapKeys(c),
putsvc.WithFormatValidatorOpts(
objectCore.WithDeleteHandler(objInhumer),
@ -285,7 +285,7 @@ func initObjectService(c *cfg) {
placement.WithoutSuccessTracking(),
),
),
searchsvc.WithNetMapSource(c.cfgNetmap.wrapper),
searchsvc.WithNetMapSource(c.netMapSource),
searchsvc.WithKeyStorage(keyStorage),
)
@ -303,7 +303,7 @@ func initObjectService(c *cfg) {
placement.SuccessAfter(1),
),
),
getsvc.WithNetMapSource(c.cfgNetmap.wrapper),
getsvc.WithNetMapSource(c.netMapSource),
getsvc.WithKeyStorage(keyStorage),
)
@ -349,7 +349,7 @@ func initObjectService(c *cfg) {
acl.NewSenderClassifier(
c.log,
irFetcher,
c.cfgNetmap.wrapper,
c.netMapSource,
),
),
acl.WithContainerSource(

View file

@ -37,8 +37,7 @@ func initReputationService(c *cfg) {
localKey := c.key.PublicKey().Bytes()
// consider sharing this between application components
nmSrc := newCachedNetmapStorage(c.cfgNetmap.state, c.cfgNetmap.wrapper)
nmSrc := c.netMapSource
// storing calculated trusts as a daughter
c.cfgReputation.localTrustStorage = truststorage.New(