[#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
35
cmd/neofs-node/reputation/intermediate/daughters.go
Normal file
35
cmd/neofs-node/reputation/intermediate/daughters.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
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 DaughterStorage 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 *DaughterStorage) InitWriter(_ reputationcommon.Context) (reputationcommon.Writer, error) {
|
||||
return &DaughterTrustWriter{
|
||||
log: s.Log,
|
||||
storage: s.Storage,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue