diff --git a/pkg/services/object/get/exec.go b/pkg/services/object/get/exec.go index ea2677f35..79469fa8f 100644 --- a/pkg/services/object/get/exec.go +++ b/pkg/services/object/get/exec.go @@ -120,7 +120,7 @@ func (exec *execCtx) initEpoch() bool { return true } - e, err := exec.svc.currentEpochReceiver.currentEpoch() + e, err := exec.svc.epochSource.Epoch() switch { default: diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index 93abb161f..d7e24256d 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -56,7 +56,7 @@ type testClient struct { type testEpochReceiver uint64 -func (e testEpochReceiver) currentEpoch() (uint64, error) { +func (e testEpochReceiver) Epoch() (uint64, error) { return uint64(e), nil } @@ -487,7 +487,7 @@ func TestGetRemoteSmall(t *testing.T) { }, } svc.clientCache = c - svc.currentEpochReceiver = testEpochReceiver(curEpoch) + svc.epochSource = testEpochReceiver(curEpoch) return svc } @@ -1182,7 +1182,7 @@ func TestGetFromPastEpoch(t *testing.T) { }, } - svc.currentEpochReceiver = testEpochReceiver(curEpoch) + svc.epochSource = testEpochReceiver(curEpoch) w := NewSimpleObjectWriter() diff --git a/pkg/services/object/get/service.go b/pkg/services/object/get/service.go index 70ceadf9f..97e92a717 100644 --- a/pkg/services/object/get/service.go +++ b/pkg/services/object/get/service.go @@ -42,13 +42,15 @@ type cfg struct { GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, error) } - currentEpochReceiver interface { - currentEpoch() (uint64, error) - } + epochSource epochSource keyStore *util.KeyStorage } +type epochSource interface { + Epoch() (uint64, error) +} + func defaultCfg() *cfg { return &cfg{ assembly: true, @@ -117,9 +119,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option { // map storage to receive current network state. func WithNetMapSource(nmSrc netmap.Source) Option { return func(c *cfg) { - c.currentEpochReceiver = &nmSrcWrapper{ - nmSrc: nmSrc, - } + c.epochSource = nmSrc } } diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index 927cd80eb..9abf17e90 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -6,7 +6,6 @@ import ( "io" coreclient "github.com/TrueCloudLab/frostfs-node/pkg/core/client" - "github.com/TrueCloudLab/frostfs-node/pkg/core/netmap" "github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" internal "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client" internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client" @@ -44,10 +43,6 @@ type hasherWrapper struct { hash io.Writer } -type nmSrcWrapper struct { - nmSrc netmap.Source -} - func NewSimpleObjectWriter() *SimpleObjectWriter { return &SimpleObjectWriter{ obj: object.New(), @@ -250,7 +245,3 @@ func (h *hasherWrapper) WriteChunk(p []byte) error { _, err := h.hash.Write(p) return err } - -func (n *nmSrcWrapper) currentEpoch() (uint64, error) { - return n.nmSrc.Epoch() -} diff --git a/pkg/services/object/search/exec.go b/pkg/services/object/search/exec.go index 7ba3d1466..980d7e166 100644 --- a/pkg/services/object/search/exec.go +++ b/pkg/services/object/search/exec.go @@ -56,7 +56,7 @@ func (exec *execCtx) initEpoch() bool { return true } - e, err := exec.svc.currentEpochReceiver.currentEpoch() + e, err := exec.svc.epochSource.Epoch() switch { default: diff --git a/pkg/services/object/search/search_test.go b/pkg/services/object/search/search_test.go index 3749d0d98..33ba07655 100644 --- a/pkg/services/object/search/search_test.go +++ b/pkg/services/object/search/search_test.go @@ -51,7 +51,7 @@ type simpleIDWriter struct { type testEpochReceiver uint64 -func (e testEpochReceiver) currentEpoch() (uint64, error) { +func (e testEpochReceiver) Epoch() (uint64, error) { return uint64(e), nil } @@ -261,7 +261,7 @@ func TestGetRemoteSmall(t *testing.T) { }, } svc.clientConstructor = c - svc.currentEpochReceiver = testEpochReceiver(curEpoch) + svc.epochSource = testEpochReceiver(curEpoch) return svc } @@ -388,7 +388,7 @@ func TestGetFromPastEpoch(t *testing.T) { }, } - svc.currentEpochReceiver = testEpochReceiver(curEpoch) + svc.epochSource = testEpochReceiver(curEpoch) w := new(simpleIDWriter) diff --git a/pkg/services/object/search/service.go b/pkg/services/object/search/service.go index 1a1cb4c1c..d0cd79e0a 100644 --- a/pkg/services/object/search/service.go +++ b/pkg/services/object/search/service.go @@ -46,13 +46,15 @@ type cfg struct { generateTraverser(cid.ID, uint64) (*placement.Traverser, error) } - currentEpochReceiver interface { - currentEpoch() (uint64, error) - } + epochSource epochSource keyStore *util.KeyStorage } +type epochSource interface { + Epoch() (uint64, error) +} + func defaultCfg() *cfg { return &cfg{ log: &logger.Logger{Logger: zap.L()}, @@ -110,9 +112,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option { // map storage to receive current network state. func WithNetMapSource(nmSrc netmap.Source) Option { return func(c *cfg) { - c.currentEpochReceiver = &nmSrcWrapper{ - nmSrc: nmSrc, - } + c.epochSource = nmSrc } } diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index 192a8dee5..a4e9d5759 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -4,7 +4,6 @@ import ( "sync" "github.com/TrueCloudLab/frostfs-node/pkg/core/client" - "github.com/TrueCloudLab/frostfs-node/pkg/core/netmap" "github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client" "github.com/TrueCloudLab/frostfs-node/pkg/services/object/util" @@ -35,10 +34,6 @@ type storageEngineWrapper struct { type traverseGeneratorWrapper util.TraverserGenerator -type nmSrcWrapper struct { - nmSrc netmap.Source -} - func newUniqueAddressWriter(w IDListWriter) IDListWriter { return &uniqueIDWriter{ written: make(map[oid.ID]struct{}), @@ -143,7 +138,3 @@ func idsFromAddresses(addrs []oid.Address) []oid.ID { func (e *traverseGeneratorWrapper) generateTraverser(cnr cid.ID, epoch uint64) (*placement.Traverser, error) { return (*util.TraverserGenerator)(e).GenerateTraverser(cnr, nil, epoch) } - -func (n *nmSrcWrapper) currentEpoch() (uint64, error) { - return n.nmSrc.Epoch() -}