action-env/cmd/frostfs-node/reputation/common/util.go
Dmitrii Stepanov cc8ff015b4 [#148] linter: Add containedctx linter
Context has to be passed as an argument: https://pkg.go.dev/context

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-03-21 09:52:39 +03:00

56 lines
1.1 KiB
Go

package common
import (
"context"
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation"
)
// EpochContext is a std context extended with epoch data.
// nolint: containedctx
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 is an 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) IterateAddresses(func(string) bool) {
}
func (*OnlyKeyRemoteServerInfo) NumberOfAddresses() int {
return 0
}
func (*OnlyKeyRemoteServerInfo) ExternalAddresses() []string {
return nil
}
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func PanicOnPrmValue(n string, v any) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
}