frostfs-node/cmd/neofs-node/reputation/common/util.go
Pavel Karpy d1db54acf8 [#488] reputation: Change Writer interface
Includes:
- Delete first `ctx` argument in `Write` method.
- Move intermediate Initial trust struct and method
to `calculator` file.
- Change Alpha to 0.1.

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

48 lines
906 B
Go

package common
import (
"context"
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
)
// EpochContext is a std context extended with epoch data.
type EpochContext struct {
context.Context
E uint64
}
func (ctx *EpochContext) Epoch() uint64 {
return ctx.E
}
type NopReputationWriter struct{}
func (NopReputationWriter) Write(reputation.Trust) error {
return nil
}
func (NopReputationWriter) Close() error {
return nil
}
// OnlyKeyRemoteServerInfo if implementation of reputation.ServerInfo
// interface but with only public key data.
type OnlyKeyRemoteServerInfo struct {
Key []byte
}
func (i *OnlyKeyRemoteServerInfo) PublicKey() []byte {
return i.Key
}
func (*OnlyKeyRemoteServerInfo) Address() string {
return ""
}
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func PanicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
}