[#488] reputation: Change Writer interface

Includes:
- Delete first `ctx` argument in `Write` method.
- Move intermediate Initial trust struct and method
to `calculator` file.
- Change Alpha to 0.1.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-05-04 09:16:51 +03:00 committed by Alex Vanin
parent 0d34d7c508
commit d1db54acf8
14 changed files with 61 additions and 63 deletions

View file

@ -29,7 +29,7 @@ type Writer interface {
// Close operation.
//
// Write must not be called after Close.
Write(Context, reputation.Trust) error
Write(reputation.Trust) error
// Close exits with method-providing Writer.
//

View file

@ -65,7 +65,7 @@ func (r *Router) InitWriter(ctx common.Context) (common.Writer, error) {
}, nil
}
func (w *trustWriter) Write(ctx common.Context, t reputation.Trust) error {
func (w *trustWriter) Write(t reputation.Trust) error {
w.routeMtx.Lock()
defer w.routeMtx.Unlock()
@ -94,7 +94,7 @@ func (w *trustWriter) Write(ctx common.Context, t reputation.Trust) error {
continue
}
remoteWriter, err = provider.InitWriter(w.ctx)
remoteWriter, err = provider.InitWriter(w.ctx.Context)
if err != nil {
w.router.log.Debug("could not initialize writer",
zap.String("error", err.Error()),
@ -106,7 +106,7 @@ func (w *trustWriter) Write(ctx common.Context, t reputation.Trust) error {
w.mServers[endpoint] = remoteWriter
}
err := remoteWriter.Write(ctx, t)
err := remoteWriter.Write(t)
if err != nil {
w.router.log.Debug("could not write the value",
zap.String("error", err.Error()),

View file

@ -195,7 +195,7 @@ func (c *Calculator) iterateDaughter(p iterDaughterPrm) {
trust.SetValue(val)
err := intermediateWriter.Write(p.ctx, trust)
err := intermediateWriter.Write(trust)
if err != nil {
c.opts.log.Debug("write intermediate value failure",
zap.String("error", err.Error()),
@ -257,7 +257,7 @@ func (c *Calculator) sendInitialValues(ctx Context) {
initTrust.Mul(trust.Value())
trust.SetValue(initTrust)
err = intermediateWriter.Write(ctx, trust)
err = intermediateWriter.Write(trust)
if err != nil {
c.opts.log.Debug("write intermediate value failure",
zap.String("error", err.Error()),

View file

@ -126,7 +126,7 @@ func (c *reportContext) report() {
return err
}
return targetWriter.Write(c.ctx, t)
return targetWriter.Write(t)
},
)
if err != nil && !errors.Is(err, context.Canceled) {

View file

@ -47,7 +47,7 @@ type EpochTrustValueStorage struct {
func newTrustValueStorage() *EpochTrustValueStorage {
return &EpochTrustValueStorage{
mItems: make(map[string]*trustValue, 1),
mItems: make(map[string]*trustValue, 1),
}
}

View file

@ -9,7 +9,7 @@ import (
// All values must comply with the requirements imposed on them.
// Passing incorrect parameter values will result in constructor
// failure (error or panic depending on the implementation).
type Prm struct {}
type Prm struct{}
// Storage represents in-memory storage of
// local reputation values.