From 469e8a6e59a26a24614eefc8f50f641e452ad616 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Tue, 4 Apr 2023 17:47:00 +0300 Subject: [PATCH] [#212] reputationsvc: Resolve containedctx linter Signed-off-by: Dmitrii Stepanov --- .../reputation/eigentrust/controller/calls.go | 18 ++---------------- .../eigentrust/controller/controller.go | 4 ++-- .../reputation/eigentrust/controller/deps.go | 6 ------ 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/pkg/services/reputation/eigentrust/controller/calls.go b/pkg/services/reputation/eigentrust/controller/calls.go index 28228706c..faf953aed 100644 --- a/pkg/services/reputation/eigentrust/controller/calls.go +++ b/pkg/services/reputation/eigentrust/controller/calls.go @@ -1,8 +1,6 @@ package eigentrustctrl import ( - "context" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation/eigentrust" "go.uber.org/zap" ) @@ -12,10 +10,7 @@ type ContinuePrm struct { Epoch uint64 } -// nolint: containedctx type iterContext struct { - context.Context - eigentrust.EpochIteration iterationNumber uint32 @@ -26,12 +21,6 @@ func (x iterContext) Last() bool { return x.last } -type iterContextCancel struct { - iterContext - - cancel context.CancelFunc -} - // Continue moves the global reputation calculator to the next iteration. func (c *Controller) Continue(prm ContinuePrm) { c.mtx.Lock() @@ -39,10 +28,9 @@ func (c *Controller) Continue(prm ContinuePrm) { { iterCtx, ok := c.mCtx[prm.Epoch] if !ok { - iterCtx = new(iterContextCancel) + iterCtx = new(iterContext) c.mCtx[prm.Epoch] = iterCtx - iterCtx.Context, iterCtx.cancel = context.WithCancel(context.Background()) iterCtx.EpochIteration.SetEpoch(prm.Epoch) iterations, err := c.prm.IterationsProvider.EigenTrustIterations() @@ -53,14 +41,12 @@ func (c *Controller) Continue(prm ContinuePrm) { } else { iterCtx.iterationNumber = uint32(iterations) } - } else { - iterCtx.cancel() } iterCtx.last = iterCtx.I() == iterCtx.iterationNumber-1 err := c.prm.WorkerPool.Submit(func() { - c.prm.DaughtersTrustCalculator.Calculate(iterCtx.iterContext) + c.prm.DaughtersTrustCalculator.Calculate(iterCtx) // iteration++ iterCtx.Increment() diff --git a/pkg/services/reputation/eigentrust/controller/controller.go b/pkg/services/reputation/eigentrust/controller/controller.go index fe9150bcf..a6d0d4a82 100644 --- a/pkg/services/reputation/eigentrust/controller/controller.go +++ b/pkg/services/reputation/eigentrust/controller/controller.go @@ -47,7 +47,7 @@ type Controller struct { opts *options mtx sync.Mutex - mCtx map[uint64]*iterContextCancel + mCtx map[uint64]*iterContext } const invalidPrmValFmt = "invalid parameter %s (%T):%v" @@ -81,6 +81,6 @@ func New(prm Prm, opts ...Option) *Controller { return &Controller{ prm: prm, opts: o, - mCtx: make(map[uint64]*iterContextCancel), + mCtx: make(map[uint64]*iterContext), } } diff --git a/pkg/services/reputation/eigentrust/controller/deps.go b/pkg/services/reputation/eigentrust/controller/deps.go index 8c4752657..2aeafb61a 100644 --- a/pkg/services/reputation/eigentrust/controller/deps.go +++ b/pkg/services/reputation/eigentrust/controller/deps.go @@ -1,14 +1,8 @@ package eigentrustctrl -import ( - "context" -) - // IterationContext is a context of the i-th // stage of iterative EigenTrust algorithm. type IterationContext interface { - context.Context - // Must return epoch number to select the values // for global trust calculation. Epoch() uint64