[#452] innerring: Add reputation processor

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-03-31 18:38:01 +03:00 committed by Alex Vanin
parent 335b31206f
commit 09e4479d44
3 changed files with 174 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package reputation
import (
"encoding/hex"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
"go.uber.org/zap"
)
func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value []byte) {
if !rp.alphabetState.IsAlphabet() {
rp.log.Info("non alphabet mode, ignore reputation put notification")
return
}
// todo: do sanity checks of value and epoch
args := wrapper.PutArgs{}
args.SetEpoch(epoch)
args.SetPeerID(id)
args.SetValue(value)
err := rp.reputationWrp.PutViaNotary(args)
if err != nil {
rp.log.Warn("can't send approval tx for reputation value",
zap.String("peer_id", hex.EncodeToString(id.Bytes())),
zap.String("error", err.Error()))
}
}