diff --git a/v2/reputation/convert.go b/v2/reputation/convert.go index 52df2fa1..8aa9aa01 100644 --- a/v2/reputation/convert.go +++ b/v2/reputation/convert.go @@ -458,6 +458,7 @@ func (x *SendIntermediateResultRequestBody) ToGRPCMessage() grpc.Message { if x != nil { m = new(reputation.SendIntermediateResultRequest_Body) + m.SetEpoch(x.epoch) m.SetIteration(x.iter) m.SetTrust(x.trust.ToGRPCMessage().(*reputation.PeerToPeerTrust)) } @@ -480,6 +481,7 @@ func (x *SendIntermediateResultRequestBody) FromGRPCMessage(m grpc.Message) erro return err } + x.epoch = v.GetEpoch() x.iter = v.GetIteration() return nil diff --git a/v2/reputation/marshal.go b/v2/reputation/marshal.go index 20fa6776..2f084088 100644 --- a/v2/reputation/marshal.go +++ b/v2/reputation/marshal.go @@ -277,6 +277,7 @@ func (x *SendLocalTrustResponseBody) Unmarshal(data []byte) error { const ( _ = iota + sendInterResBodyEpochFNum sendInterResBodyIterFNum sendInterResBodyTrustFNum ) @@ -290,11 +291,25 @@ func (x *SendIntermediateResultRequestBody) StableMarshal(buf []byte) ([]byte, e 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 { 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) if err != nil { return nil, err @@ -304,6 +319,7 @@ func (x *SendIntermediateResultRequestBody) StableMarshal(buf []byte) ([]byte, e } func (x *SendIntermediateResultRequestBody) StableSize() (size int) { + size += protoutil.UInt64Size(sendInterResBodyEpochFNum, x.epoch) size += protoutil.UInt32Size(sendInterResBodyIterFNum, x.iter) size += protoutil.NestedStructureSize(sendInterResBodyTrustFNum, x.trust) diff --git a/v2/reputation/test/generate.go b/v2/reputation/test/generate.go index 65e50e86..fbd4bd16 100644 --- a/v2/reputation/test/generate.go +++ b/v2/reputation/test/generate.go @@ -109,6 +109,7 @@ func GenerateSendIntermediateResultRequestBody(empty bool) *reputation.SendInter m := new(reputation.SendIntermediateResultRequestBody) if !empty { + m.SetEpoch(123) m.SetIteration(564) } diff --git a/v2/reputation/types.go b/v2/reputation/types.go index b7ef5453..b1bd7075 100644 --- a/v2/reputation/types.go +++ b/v2/reputation/types.go @@ -297,11 +297,29 @@ func (x *SendLocalTrustResponse) SetBody(v *SendLocalTrustResponseBody) { // SendIntermediateResultRequestBody is a structure of SendIntermediateResult request body. type SendIntermediateResultRequestBody struct { + epoch uint64 + iter uint32 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. func (x *SendIntermediateResultRequestBody) GetIteration() uint32 { if x != nil {