forked from TrueCloudLab/frostfs-api-go
[#376] reputation: Remove pointers from slices
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
30c530e83d
commit
0cab407378
4 changed files with 13 additions and 19 deletions
|
@ -138,7 +138,7 @@ func (x *PeerToPeerTrust) FromGRPCMessage(m grpc.Message) error {
|
||||||
|
|
||||||
// TrustsToGRPC converts slice of Trust structures
|
// TrustsToGRPC converts slice of Trust structures
|
||||||
// to slice of gRPC-generated Trust messages.
|
// to slice of gRPC-generated Trust messages.
|
||||||
func TrustsToGRPC(xs []*Trust) (res []*reputation.Trust) {
|
func TrustsToGRPC(xs []Trust) (res []*reputation.Trust) {
|
||||||
if xs != nil {
|
if xs != nil {
|
||||||
res = make([]*reputation.Trust, 0, len(xs))
|
res = make([]*reputation.Trust, 0, len(xs))
|
||||||
|
|
||||||
|
@ -152,23 +152,17 @@ func TrustsToGRPC(xs []*Trust) (res []*reputation.Trust) {
|
||||||
|
|
||||||
// TrustsFromGRPC tries to restore slice of Trust structures from
|
// TrustsFromGRPC tries to restore slice of Trust structures from
|
||||||
// slice of gRPC-generated reputation.Trust messages.
|
// slice of gRPC-generated reputation.Trust messages.
|
||||||
func TrustsFromGRPC(xs []*reputation.Trust) (res []*Trust, err error) {
|
func TrustsFromGRPC(xs []*reputation.Trust) (res []Trust, err error) {
|
||||||
if xs != nil {
|
if xs != nil {
|
||||||
res = make([]*Trust, 0, len(xs))
|
res = make([]Trust, len(xs))
|
||||||
|
|
||||||
for i := range xs {
|
for i := range xs {
|
||||||
var x *Trust
|
|
||||||
|
|
||||||
if xs[i] != nil {
|
if xs[i] != nil {
|
||||||
x = new(Trust)
|
err = res[i].FromGRPCMessage(xs[i])
|
||||||
|
|
||||||
err = x.FromGRPCMessage(xs[i])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = append(res, x)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ func (x *AnnounceLocalTrustRequestBody) StableMarshal(buf []byte) ([]byte, error
|
||||||
offset += n
|
offset += n
|
||||||
|
|
||||||
for i := range x.trusts {
|
for i := range x.trusts {
|
||||||
n, err = protoutil.NestedStructureMarshal(announceLocalTrustBodyTrustsFNum, buf[offset:], x.trusts[i])
|
n, err = protoutil.NestedStructureMarshal(announceLocalTrustBodyTrustsFNum, buf[offset:], &x.trusts[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ func (x *AnnounceLocalTrustRequestBody) StableSize() (size int) {
|
||||||
size += protoutil.UInt64Size(announceLocalTrustBodyEpochFNum, x.epoch)
|
size += protoutil.UInt64Size(announceLocalTrustBodyEpochFNum, x.epoch)
|
||||||
|
|
||||||
for i := range x.trusts {
|
for i := range x.trusts {
|
||||||
size += protoutil.NestedStructureSize(announceLocalTrustBodyTrustsFNum, x.trusts[i])
|
size += protoutil.NestedStructureSize(announceLocalTrustBodyTrustsFNum, &x.trusts[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -61,13 +61,13 @@ func GenerateGlobalTrust(empty bool) *reputation.GlobalTrust {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTrusts(empty bool) []*reputation.Trust {
|
func GenerateTrusts(empty bool) []reputation.Trust {
|
||||||
var res []*reputation.Trust
|
var res []reputation.Trust
|
||||||
|
|
||||||
if !empty {
|
if !empty {
|
||||||
res = append(res,
|
res = append(res,
|
||||||
GenerateTrust(false),
|
*GenerateTrust(false),
|
||||||
GenerateTrust(false),
|
*GenerateTrust(false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ func (x *GlobalTrust) SetSignature(v *refs.Signature) {
|
||||||
type AnnounceLocalTrustRequestBody struct {
|
type AnnounceLocalTrustRequestBody struct {
|
||||||
epoch uint64
|
epoch uint64
|
||||||
|
|
||||||
trusts []*Trust
|
trusts []Trust
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEpoch returns epoch in which the trust was assessed.
|
// GetEpoch returns epoch in which the trust was assessed.
|
||||||
|
@ -229,7 +229,7 @@ func (x *AnnounceLocalTrustRequestBody) SetEpoch(v uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTrusts returns list of normalized trust values.
|
// GetTrusts returns list of normalized trust values.
|
||||||
func (x *AnnounceLocalTrustRequestBody) GetTrusts() []*Trust {
|
func (x *AnnounceLocalTrustRequestBody) GetTrusts() []Trust {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.trusts
|
return x.trusts
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ func (x *AnnounceLocalTrustRequestBody) GetTrusts() []*Trust {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTrusts sets list of normalized trust values.
|
// SetTrusts sets list of normalized trust values.
|
||||||
func (x *AnnounceLocalTrustRequestBody) SetTrusts(v []*Trust) {
|
func (x *AnnounceLocalTrustRequestBody) SetTrusts(v []Trust) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
x.trusts = v
|
x.trusts = v
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue