frostfs-node/cmd/neofs-node/reputation/intermediate/daughters.go
Pavel Karpy f7aa79f0b6 [#488] cmd/reputation/storage: Add consumers storage
Add consumer storage wrapper that implements
`WriterProvider` interface. Change field naming
in daughters storage package.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-05-04 17:53:02 +03:00

35 lines
954 B
Go

package intermediate
import (
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust/storage/daughters"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
)
type DaughterStorageWriterProvider struct {
Log *logger.Logger
Storage *daughters.Storage
}
type DaughterTrustWriter struct {
log *logger.Logger
storage *daughters.Storage
}
func (w *DaughterTrustWriter) Write(ctx common.Context, t reputation.Trust) error {
w.storage.Put(ctx.Epoch(), t)
return nil
}
func (w *DaughterTrustWriter) Close() error {
return nil
}
func (s *DaughterStorageWriterProvider) InitWriter(_ reputationcommon.Context) (reputationcommon.Writer, error) {
return &DaughterTrustWriter{
log: s.Log,
storage: s.Storage,
}, nil
}