2021-04-22 14:56:25 +00:00
|
|
|
package common
|
2021-04-18 08:51:49 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
|
|
|
)
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// EpochContext is a std context extended with epoch data.
|
2021-04-18 08:51:49 +00:00
|
|
|
type EpochContext struct {
|
|
|
|
context.Context
|
|
|
|
E uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *EpochContext) Epoch() uint64 {
|
|
|
|
return ctx.E
|
|
|
|
}
|
|
|
|
|
|
|
|
type NopReputationWriter struct{}
|
|
|
|
|
2021-05-04 06:16:51 +00:00
|
|
|
func (NopReputationWriter) Write(reputation.Trust) error {
|
2021-04-18 08:51:49 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (NopReputationWriter) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// OnlyKeyRemoteServerInfo if implementation of reputation.ServerInfo
|
|
|
|
// interface but with only public key data.
|
2021-04-18 08:51:49 +00:00
|
|
|
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"
|
|
|
|
|
2021-04-22 14:56:25 +00:00
|
|
|
func PanicOnPrmValue(n string, v interface{}) {
|
2021-04-18 08:51:49 +00:00
|
|
|
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
|
|
|
|
}
|