forked from TrueCloudLab/frostfs-node
[#452] Use API structures for reputation PeerID and GlobalTrust
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7cf48d4d91
commit
27cf6f5112
6 changed files with 116 additions and 36 deletions
|
@ -3,18 +3,38 @@ package reputation
|
|||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/reputation"
|
||||
"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) {
|
||||
func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputation.GlobalTrust) {
|
||||
if !rp.alphabetState.IsAlphabet() {
|
||||
rp.log.Info("non alphabet mode, ignore reputation put notification")
|
||||
return
|
||||
}
|
||||
|
||||
// todo: do sanity checks of value and epoch
|
||||
// check if epoch is valid
|
||||
currentEpoch := rp.epochState.EpochCounter()
|
||||
if epoch >= currentEpoch {
|
||||
rp.log.Info("ignore reputation value",
|
||||
zap.String("reason", "invalid epoch number"),
|
||||
zap.Uint64("trust_epoch", epoch),
|
||||
zap.Uint64("local_epoch", currentEpoch))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// check signature
|
||||
if err := value.VerifySignature(); err != nil {
|
||||
rp.log.Info("ignore reputation value",
|
||||
zap.String("reason", "invalid signature"),
|
||||
zap.String("error", err.Error()))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// todo: do sanity checks of value
|
||||
|
||||
args := wrapper.PutArgs{}
|
||||
args.SetEpoch(epoch)
|
||||
|
@ -24,7 +44,7 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value []byte
|
|||
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("peer_id", hex.EncodeToString(id.ToV2().GetValue())),
|
||||
zap.String("error", err.Error()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue