2021-03-24 07:10:51 +00:00
|
|
|
package reputation
|
|
|
|
|
|
|
|
import (
|
|
|
|
reputation "github.com/nspcc-dev/neofs-api-go/v2/reputation/grpc"
|
2021-11-16 17:30:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
|
|
|
protoutil "github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
2021-03-24 07:10:51 +00:00
|
|
|
)
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
2021-05-07 09:34:24 +00:00
|
|
|
peerIDPubKeyFNum
|
2021-04-01 14:53:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (x *PeerID) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
_, err := protoutil.BytesMarshal(peerIDPubKeyFNum, buf, x.publicKey)
|
2021-04-01 14:53:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *PeerID) StableSize() (size int) {
|
2021-05-07 09:34:24 +00:00
|
|
|
size += protoutil.BytesSize(peerIDPubKeyFNum, x.publicKey)
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *PeerID) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.PeerID))
|
|
|
|
}
|
|
|
|
|
2021-03-24 07:10:51 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
trustPeerFNum
|
|
|
|
trustValueFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *Trust) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(trustPeerFNum, buf[offset:], x.peer)
|
2021-03-24 07:10:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
_, err = protoutil.Float64Marshal(trustValueFNum, buf[offset:], x.val)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Trust) StableSize() (size int) {
|
2021-04-01 14:53:14 +00:00
|
|
|
size += protoutil.NestedStructureSize(trustPeerFNum, x.peer)
|
2021-03-24 07:10:51 +00:00
|
|
|
size += protoutil.Float64Size(trustValueFNum, x.val)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *Trust) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.Trust))
|
|
|
|
}
|
|
|
|
|
2021-04-09 08:28:06 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
p2pTrustTrustingFNum
|
|
|
|
p2pTrustValueFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *PeerToPeerTrust) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
offset, err := protoutil.NestedStructureMarshal(p2pTrustTrustingFNum, buf, x.trusting)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = protoutil.NestedStructureMarshal(p2pTrustValueFNum, buf[offset:], x.trust)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *PeerToPeerTrust) StableSize() (size int) {
|
|
|
|
size += protoutil.NestedStructureSize(p2pTrustTrustingFNum, x.trusting)
|
|
|
|
size += protoutil.NestedStructureSize(p2pTrustValueFNum, x.trust)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *PeerToPeerTrust) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.PeerToPeerTrust))
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:53:14 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
globalTrustBodyManagerFNum
|
|
|
|
globalTrustBodyValueFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *GlobalTrustBody) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
offset, err := protoutil.NestedStructureMarshal(globalTrustBodyManagerFNum, buf, x.manager)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = protoutil.NestedStructureMarshal(globalTrustBodyValueFNum, buf[offset:], x.trust)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *GlobalTrustBody) StableSize() (size int) {
|
|
|
|
size += protoutil.NestedStructureSize(globalTrustBodyManagerFNum, x.manager)
|
|
|
|
size += protoutil.NestedStructureSize(globalTrustBodyValueFNum, x.trust)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *GlobalTrustBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.GlobalTrust_Body))
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
globalTrustVersionFNum
|
|
|
|
globalTrustBodyFNum
|
|
|
|
globalTrustSigFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *GlobalTrust) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
offset, err := protoutil.NestedStructureMarshal(globalTrustVersionFNum, buf, x.version)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
n, err := protoutil.NestedStructureMarshal(globalTrustBodyFNum, buf[offset:], x.body)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
_, err = protoutil.NestedStructureMarshal(globalTrustSigFNum, buf[offset:], x.sig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *GlobalTrust) StableSize() (size int) {
|
|
|
|
size += protoutil.NestedStructureSize(globalTrustVersionFNum, x.version)
|
|
|
|
size += protoutil.NestedStructureSize(globalTrustBodyFNum, x.body)
|
|
|
|
size += protoutil.NestedStructureSize(globalTrustSigFNum, x.sig)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *GlobalTrust) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.GlobalTrust))
|
|
|
|
}
|
|
|
|
|
2021-03-24 07:10:51 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
2021-05-07 09:34:24 +00:00
|
|
|
announceLocalTrustBodyEpochFNum
|
|
|
|
announceLocalTrustBodyTrustsFNum
|
2021-03-24 07:10:51 +00:00
|
|
|
)
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) StableMarshal(buf []byte) ([]byte, error) {
|
2021-03-24 07:10:51 +00:00
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
n, err = protoutil.UInt64Marshal(announceLocalTrustBodyEpochFNum, buf[offset:], x.epoch)
|
2021-03-24 07:10:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
for i := range x.trusts {
|
2021-05-07 09:34:24 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(announceLocalTrustBodyTrustsFNum, buf[offset:], x.trusts[i])
|
2021-03-24 07:10:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) StableSize() (size int) {
|
|
|
|
size += protoutil.UInt64Size(announceLocalTrustBodyEpochFNum, x.epoch)
|
2021-03-24 07:10:51 +00:00
|
|
|
|
|
|
|
for i := range x.trusts {
|
2021-05-07 09:34:24 +00:00
|
|
|
size += protoutil.NestedStructureSize(announceLocalTrustBodyTrustsFNum, x.trusts[i])
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustRequestBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.AnnounceLocalTrustRequest_Body))
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustResponseBody) StableMarshal(buf []byte) ([]byte, error) {
|
2021-03-24 07:10:51 +00:00
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustResponseBody) StableSize() int {
|
2021-03-24 07:10:51 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceLocalTrustResponseBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.AnnounceLocalTrustResponse_Body))
|
2021-03-24 07:10:51 +00:00
|
|
|
}
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
2021-05-07 09:34:24 +00:00
|
|
|
announceInterResBodyEpochFNum
|
|
|
|
announceInterResBodyIterFNum
|
|
|
|
announceInterResBodyTrustFNum
|
2021-04-01 14:53:14 +00:00
|
|
|
)
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) StableMarshal(buf []byte) ([]byte, error) {
|
2021-04-01 14:53:14 +00:00
|
|
|
if x == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2021-04-22 07:40:12 +00:00
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
n, err = protoutil.UInt64Marshal(announceInterResBodyEpochFNum, buf, x.epoch)
|
2021-04-01 14:53:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-04-22 07:40:12 +00:00
|
|
|
offset += n
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
n, err = protoutil.UInt32Marshal(announceInterResBodyIterFNum, buf[offset:], x.iter)
|
2021-04-22 07:40:12 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
_, err = protoutil.NestedStructureMarshal(announceInterResBodyTrustFNum, buf[offset:], x.trust)
|
2021-04-01 14:53:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) StableSize() (size int) {
|
|
|
|
size += protoutil.UInt64Size(announceInterResBodyEpochFNum, x.epoch)
|
|
|
|
size += protoutil.UInt32Size(announceInterResBodyIterFNum, x.iter)
|
|
|
|
size += protoutil.NestedStructureSize(announceInterResBodyTrustFNum, x.trust)
|
2021-04-01 14:53:14 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultRequestBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.AnnounceIntermediateResultRequest_Body))
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultResponseBody) StableMarshal(buf []byte) ([]byte, error) {
|
2021-04-01 14:53:14 +00:00
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultResponseBody) StableSize() int {
|
2021-04-01 14:53:14 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func (x *AnnounceIntermediateResultResponseBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(x, data, new(reputation.AnnounceIntermediateResultResponse_Body))
|
2021-04-01 14:53:14 +00:00
|
|
|
}
|