forked from TrueCloudLab/frostfs-node
[#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:
parent
56b3e35779
commit
f6783f4f81
8 changed files with 53 additions and 37 deletions
|
@ -107,7 +107,7 @@ type RemoteTrustWriter struct {
|
|||
buf []*reputationapi.Trust
|
||||
}
|
||||
|
||||
func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||
func (rtp *RemoteTrustWriter) Write(_ reputationcommon.Context, t reputation.Trust) error {
|
||||
apiTrust := reputationapi.NewTrust()
|
||||
|
||||
apiPeer := reputationapi.NewPeerID()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package local
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
||||
)
|
||||
|
@ -18,7 +19,7 @@ func (ctx *EpochContext) Epoch() uint64 {
|
|||
|
||||
type NopReputationWriter struct{}
|
||||
|
||||
func (NopReputationWriter) Write(reputation.Trust) error {
|
||||
func (NopReputationWriter) Write(common.Context, reputation.Trust) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue