forked from TrueCloudLab/frostfs-api-go
[#275] reputation/convert: Add nil check
In `SendIntermediateResultRequestBody` add nil check for `trust` field. If true, allocate new `PeerToPeerTrust`. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
0f7a14a69f
commit
bb217067f4
2 changed files with 13 additions and 5 deletions
|
@ -476,10 +476,19 @@ func (x *SendIntermediateResultRequestBody) FromGRPCMessage(m grpc.Message) erro
|
|||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
err := x.trust.FromGRPCMessage(v.GetTrust())
|
||||
trust := v.GetTrust()
|
||||
if trust == nil {
|
||||
x.trust = nil
|
||||
} else {
|
||||
if x.trust == nil {
|
||||
x.trust = new(PeerToPeerTrust)
|
||||
}
|
||||
|
||||
err := x.trust.FromGRPCMessage(trust)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
x.epoch = v.GetEpoch()
|
||||
x.iter = v.GetIteration()
|
||||
|
|
|
@ -111,9 +111,8 @@ func GenerateSendIntermediateResultRequestBody(empty bool) *reputation.SendInter
|
|||
if !empty {
|
||||
m.SetEpoch(123)
|
||||
m.SetIteration(564)
|
||||
}
|
||||
|
||||
m.SetTrust(GeneratePeerToPeerTrust(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue