forked from TrueCloudLab/frostfs-api-go
[#274] reputation: Adapt converters and encoding methods on messages
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
1076478b29
commit
541a56aae1
4 changed files with 38 additions and 1 deletions
|
@ -458,6 +458,7 @@ func (x *SendIntermediateResultRequestBody) ToGRPCMessage() grpc.Message {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
m = new(reputation.SendIntermediateResultRequest_Body)
|
m = new(reputation.SendIntermediateResultRequest_Body)
|
||||||
|
|
||||||
|
m.SetEpoch(x.epoch)
|
||||||
m.SetIteration(x.iter)
|
m.SetIteration(x.iter)
|
||||||
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.PeerToPeerTrust))
|
m.SetTrust(x.trust.ToGRPCMessage().(*reputation.PeerToPeerTrust))
|
||||||
}
|
}
|
||||||
|
@ -480,6 +481,7 @@ func (x *SendIntermediateResultRequestBody) FromGRPCMessage(m grpc.Message) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x.epoch = v.GetEpoch()
|
||||||
x.iter = v.GetIteration()
|
x.iter = v.GetIteration()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -277,6 +277,7 @@ func (x *SendLocalTrustResponseBody) Unmarshal(data []byte) error {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ = iota
|
_ = iota
|
||||||
|
sendInterResBodyEpochFNum
|
||||||
sendInterResBodyIterFNum
|
sendInterResBodyIterFNum
|
||||||
sendInterResBodyTrustFNum
|
sendInterResBodyTrustFNum
|
||||||
)
|
)
|
||||||
|
@ -290,11 +291,25 @@ func (x *SendIntermediateResultRequestBody) StableMarshal(buf []byte) ([]byte, e
|
||||||
buf = make([]byte, x.StableSize())
|
buf = make([]byte, x.StableSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
offset, err := protoutil.UInt32Marshal(sendInterResBodyIterFNum, buf, x.iter)
|
var (
|
||||||
|
offset, n int
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
n, err = protoutil.UInt64Marshal(sendInterResBodyEpochFNum, buf, x.epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset += n
|
||||||
|
|
||||||
|
n, err = protoutil.UInt32Marshal(sendInterResBodyIterFNum, buf[offset:], x.iter)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += n
|
||||||
|
|
||||||
_, err = protoutil.NestedStructureMarshal(sendInterResBodyTrustFNum, buf[offset:], x.trust)
|
_, err = protoutil.NestedStructureMarshal(sendInterResBodyTrustFNum, buf[offset:], x.trust)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -304,6 +319,7 @@ func (x *SendIntermediateResultRequestBody) StableMarshal(buf []byte) ([]byte, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SendIntermediateResultRequestBody) StableSize() (size int) {
|
func (x *SendIntermediateResultRequestBody) StableSize() (size int) {
|
||||||
|
size += protoutil.UInt64Size(sendInterResBodyEpochFNum, x.epoch)
|
||||||
size += protoutil.UInt32Size(sendInterResBodyIterFNum, x.iter)
|
size += protoutil.UInt32Size(sendInterResBodyIterFNum, x.iter)
|
||||||
size += protoutil.NestedStructureSize(sendInterResBodyTrustFNum, x.trust)
|
size += protoutil.NestedStructureSize(sendInterResBodyTrustFNum, x.trust)
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ func GenerateSendIntermediateResultRequestBody(empty bool) *reputation.SendInter
|
||||||
m := new(reputation.SendIntermediateResultRequestBody)
|
m := new(reputation.SendIntermediateResultRequestBody)
|
||||||
|
|
||||||
if !empty {
|
if !empty {
|
||||||
|
m.SetEpoch(123)
|
||||||
m.SetIteration(564)
|
m.SetIteration(564)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,11 +297,29 @@ func (x *SendLocalTrustResponse) SetBody(v *SendLocalTrustResponseBody) {
|
||||||
|
|
||||||
// SendIntermediateResultRequestBody is a structure of SendIntermediateResult request body.
|
// SendIntermediateResultRequestBody is a structure of SendIntermediateResult request body.
|
||||||
type SendIntermediateResultRequestBody struct {
|
type SendIntermediateResultRequestBody struct {
|
||||||
|
epoch uint64
|
||||||
|
|
||||||
iter uint32
|
iter uint32
|
||||||
|
|
||||||
trust *PeerToPeerTrust
|
trust *PeerToPeerTrust
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetEpoch returns epoch number in which the intermediate trust was assessed.
|
||||||
|
func (x *SendIntermediateResultRequestBody) GetEpoch() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.epoch
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEpoch sets epoch number in which the intermediate trust was assessed.
|
||||||
|
func (x *SendIntermediateResultRequestBody) SetEpoch(v uint64) {
|
||||||
|
if x != nil {
|
||||||
|
x.epoch = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetIteration returns sequence number of the iteration.
|
// GetIteration returns sequence number of the iteration.
|
||||||
func (x *SendIntermediateResultRequestBody) GetIteration() uint32 {
|
func (x *SendIntermediateResultRequestBody) GetIteration() uint32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
|
Loading…
Reference in a new issue