[#488] cmd/reputation: Add DaughterStorage

Add `DaughterStorage` init in main pkg
and start write all received daughters'
trusts to it.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-04-21 07:56:38 +03:00 committed by Alex Vanin
parent 56b3e35779
commit f6783f4f81
8 changed files with 53 additions and 37 deletions

View file

@ -2,7 +2,6 @@ package local
import (
"bytes"
"encoding/hex"
netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
@ -11,7 +10,6 @@ import (
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors"
"go.uber.org/zap"
)
type TrustStorage struct {
@ -37,13 +35,6 @@ func (s *TrustStorage) InitIterator(ctx reputationcommon.Context) (trustcontroll
}, nil
}
func (s *TrustStorage) InitWriter(ctx reputationcommon.Context) (reputationcommon.Writer, error) {
return &TrustLogger{
ctx: ctx,
log: s.Log,
}, nil
}
type TrustIterator struct {
ctx reputationcommon.Context
@ -98,23 +89,3 @@ func (it *TrustIterator) Iterate(h reputation.TrustHandler) error {
return nil
}
type TrustLogger struct {
ctx reputationcommon.Context
log *logger.Logger
}
func (l *TrustLogger) Write(t reputation.Trust) error {
l.log.Info("received local trust",
zap.Uint64("epoch", l.ctx.Epoch()),
zap.String("peer", hex.EncodeToString(t.Peer().Bytes())),
zap.Stringer("value", t.Value()),
)
return nil
}
func (*TrustLogger) Close() error {
return nil
}