forked from TrueCloudLab/frostfs-node
services/control: Autogenerate stable marshalers
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
d2d1694113
commit
0408acc40e
17 changed files with 10 additions and 1311 deletions
3
Makefile
3
Makefile
|
@ -66,11 +66,14 @@ protoc:
|
||||||
@GOPRIVATE=github.com/nspcc-dev go mod vendor
|
@GOPRIVATE=github.com/nspcc-dev go mod vendor
|
||||||
# Install specific version for protobuf lib
|
# Install specific version for protobuf lib
|
||||||
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go install -v
|
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go install -v
|
||||||
|
@GOBIN=$(abspath $(BIN)) go install -mod=mod -v github.com/nspcc-dev/neofs-api-go/v2/util/protogen
|
||||||
# Protoc generate
|
# Protoc generate
|
||||||
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
||||||
echo "⇒ Processing $$f "; \
|
echo "⇒ Processing $$f "; \
|
||||||
protoc \
|
protoc \
|
||||||
--proto_path=.:./vendor:/usr/local/include \
|
--proto_path=.:./vendor:/usr/local/include \
|
||||||
|
--plugin=protoc-gen-go-neofs=$(BIN)/protogen \
|
||||||
|
--go-neofs_out=. --go-neofs_opt=paths=source_relative \
|
||||||
--go_out=. --go_opt=paths=source_relative \
|
--go_out=. --go_opt=paths=source_relative \
|
||||||
--go-grpc_opt=require_unimplemented_servers=false \
|
--go-grpc_opt=require_unimplemented_servers=false \
|
||||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \
|
--go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \
|
||||||
|
|
Binary file not shown.
4
go.mod
4
go.mod
|
@ -17,7 +17,7 @@ require (
|
||||||
github.com/nspcc-dev/hrw v1.0.9
|
github.com/nspcc-dev/hrw v1.0.9
|
||||||
github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220609082921-2c9fb2044242
|
github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220609082921-2c9fb2044242
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5 // indirect
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5 // indirect
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.12.2
|
github.com/nspcc-dev/neofs-api-go/v2 v2.12.3-0.20220620114558-454b5c0ed7e9
|
||||||
github.com/nspcc-dev/neofs-contract v0.15.1
|
github.com/nspcc-dev/neofs-contract v0.15.1
|
||||||
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.4.0.20220616082321-e986f4780721
|
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.4.0.20220616082321-e986f4780721
|
||||||
github.com/nspcc-dev/tzhash v1.5.2
|
github.com/nspcc-dev/tzhash v1.5.2
|
||||||
|
@ -34,7 +34,7 @@ require (
|
||||||
go.uber.org/zap v1.18.1
|
go.uber.org/zap v1.18.1
|
||||||
golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4
|
golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.28.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -399,8 +399,9 @@ github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5 h1:bW
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.12.2 h1:ifV/c0bW1TPiEKZlNqhfZl8lzX0f6FokjYUaze/hlBk=
|
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.12.2/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU=
|
github.com/nspcc-dev/neofs-api-go/v2 v2.12.2/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU=
|
||||||
|
github.com/nspcc-dev/neofs-api-go/v2 v2.12.3-0.20220620114558-454b5c0ed7e9 h1:nMZRx2YCg+COYNweherLYl11A39iAmdtu24L3inI3yE=
|
||||||
|
github.com/nspcc-dev/neofs-api-go/v2 v2.12.3-0.20220620114558-454b5c0ed7e9/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU=
|
||||||
github.com/nspcc-dev/neofs-contract v0.15.1 h1:1r27t4SGKF7W1PRPOIfircEXHvALThNYNagT+SIabcA=
|
github.com/nspcc-dev/neofs-contract v0.15.1 h1:1r27t4SGKF7W1PRPOIfircEXHvALThNYNagT+SIabcA=
|
||||||
github.com/nspcc-dev/neofs-contract v0.15.1/go.mod h1:kxO5ZTqdzFnRM5RMvM+Fhd+3GGrJo6AmG2ZyA9OCqqQ=
|
github.com/nspcc-dev/neofs-contract v0.15.1/go.mod h1:kxO5ZTqdzFnRM5RMvM+Fhd+3GGrJo6AmG2ZyA9OCqqQ=
|
||||||
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||||
|
@ -956,8 +957,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/abiosoft/ishell.v2 v2.0.0/go.mod h1:sFp+cGtH6o4s1FtpVPTMcHq2yue+c4DGOVohJCPUzwY=
|
gopkg.in/abiosoft/ishell.v2 v2.0.0/go.mod h1:sFp+cGtH6o4s1FtpVPTMcHq2yue+c4DGOVohJCPUzwY=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|
|
@ -1,30 +1,5 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of health check request body
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns any error encountered which did not allow writing the data completely.
|
|
||||||
// Otherwise, returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *HealthCheckRequest_Body) StableMarshal(buf []byte) ([]byte, error) {
|
|
||||||
return buf, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableSize returns binary size of health check request body
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *HealthCheckRequest_Body) StableSize() int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBody sets health check request body.
|
// SetBody sets health check request body.
|
||||||
func (x *HealthCheckRequest) SetBody(v *HealthCheckRequest_Body) {
|
func (x *HealthCheckRequest) SetBody(v *HealthCheckRequest_Body) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
@ -32,33 +7,6 @@ func (x *HealthCheckRequest) SetBody(v *HealthCheckRequest_Body) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSignature sets signature of the health check request body.
|
|
||||||
func (x *HealthCheckRequest) SetSignature(body *Signature) {
|
|
||||||
if x != nil {
|
|
||||||
x.Signature = body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReadSignedData reads signed data of health check request to buf.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.SignedDataSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns any error encountered which did not allow writing the data completely.
|
|
||||||
// Otherwise, returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same signed data.
|
|
||||||
func (x *HealthCheckRequest) ReadSignedData(buf []byte) ([]byte, error) {
|
|
||||||
return x.GetBody().StableMarshal(buf)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SignedDataSize returns binary size of the signed data
|
|
||||||
// of health check request.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same signed data size.
|
|
||||||
func (x *HealthCheckRequest) SignedDataSize() int {
|
|
||||||
return x.GetBody().StableSize()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetHealthStatus sets health status of the IR application.
|
// SetHealthStatus sets health status of the IR application.
|
||||||
func (x *HealthCheckResponse_Body) SetHealthStatus(v HealthStatus) {
|
func (x *HealthCheckResponse_Body) SetHealthStatus(v HealthStatus) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
@ -66,79 +14,9 @@ func (x *HealthCheckResponse_Body) SetHealthStatus(v HealthStatus) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
healthRespBodyHealthStatusFNum
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of health check response body
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *HealthCheckResponse_Body) StableMarshal(buf []byte) []byte {
|
|
||||||
if x == nil {
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sz := x.StableSize(); len(buf) < sz {
|
|
||||||
buf = make([]byte, sz)
|
|
||||||
}
|
|
||||||
|
|
||||||
proto.EnumMarshal(healthRespBodyHealthStatusFNum, buf, int32(x.HealthStatus))
|
|
||||||
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableSize returns binary size of health check response body
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *HealthCheckResponse_Body) StableSize() int {
|
|
||||||
if x == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
size := 0
|
|
||||||
|
|
||||||
size += proto.EnumSize(healthRespBodyHealthStatusFNum, int32(x.HealthStatus))
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBody sets health check response body.
|
// SetBody sets health check response body.
|
||||||
func (x *HealthCheckResponse) SetBody(v *HealthCheckResponse_Body) {
|
func (x *HealthCheckResponse) SetBody(v *HealthCheckResponse_Body) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
x.Body = v
|
x.Body = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSignature sets signature of the health check response body.
|
|
||||||
func (x *HealthCheckResponse) SetSignature(v *Signature) {
|
|
||||||
if x != nil {
|
|
||||||
x.Signature = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReadSignedData reads signed data of health check response to buf.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.SignedDataSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns any error encountered which did not allow writing the data completely.
|
|
||||||
// Otherwise, returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same signed data.
|
|
||||||
func (x *HealthCheckResponse) ReadSignedData(buf []byte) ([]byte, error) {
|
|
||||||
return x.GetBody().StableMarshal(buf), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SignedDataSize returns binary size of the signed data
|
|
||||||
// of health check response.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same signed data size.
|
|
||||||
func (x *HealthCheckResponse) SignedDataSize() int {
|
|
||||||
return x.GetBody().StableSize()
|
|
||||||
}
|
|
||||||
|
|
BIN
pkg/services/control/ir/service.pb.go
generated
BIN
pkg/services/control/ir/service.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/ir/service_grpc.pb.go
generated
BIN
pkg/services/control/ir/service_grpc.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/ir/service_neofs.pb.go
generated
Normal file
BIN
pkg/services/control/ir/service_neofs.pb.go
generated
Normal file
Binary file not shown.
BIN
pkg/services/control/ir/types.pb.go
generated
BIN
pkg/services/control/ir/types.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/ir/types_neofs.pb.go
generated
Normal file
BIN
pkg/services/control/ir/types_neofs.pb.go
generated
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
BIN
pkg/services/control/service.pb.go
generated
BIN
pkg/services/control/service.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/service_grpc.pb.go
generated
BIN
pkg/services/control/service_grpc.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/service_neofs.pb.go
generated
Normal file
BIN
pkg/services/control/service_neofs.pb.go
generated
Normal file
Binary file not shown.
|
@ -1,7 +1,6 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,62 +39,6 @@ func (x *NodeInfo_Attribute) SetParents(v []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
nodeAttrKeyFNum
|
|
||||||
nodeAttrValueFNum
|
|
||||||
nodeAttrParentsFNum
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of node attribute
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *NodeInfo_Attribute) StableMarshal(buf []byte) []byte {
|
|
||||||
if x == nil {
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sz := x.StableSize(); len(buf) < sz {
|
|
||||||
buf = make([]byte, sz)
|
|
||||||
}
|
|
||||||
|
|
||||||
offset := proto.StringMarshal(nodeAttrKeyFNum, buf, x.Key)
|
|
||||||
offset += proto.StringMarshal(nodeAttrValueFNum, buf[offset:], x.Value)
|
|
||||||
|
|
||||||
for i := range x.Parents {
|
|
||||||
offset += proto.StringMarshal(nodeAttrParentsFNum, buf[offset:], x.Parents[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableSize returns binary size of node attribute
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *NodeInfo_Attribute) StableSize() int {
|
|
||||||
if x == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
size := 0
|
|
||||||
|
|
||||||
size += proto.StringSize(nodeAttrKeyFNum, x.Key)
|
|
||||||
size += proto.StringSize(nodeAttrValueFNum, x.Value)
|
|
||||||
|
|
||||||
parents := x.GetParents()
|
|
||||||
for i := range parents {
|
|
||||||
size += proto.StringSize(nodeAttrParentsFNum, parents[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPublicKey sets public key of the NeoFS node in a binary format.
|
// SetPublicKey sets public key of the NeoFS node in a binary format.
|
||||||
func (x *NodeInfo) SetPublicKey(v []byte) {
|
func (x *NodeInfo) SetPublicKey(v []byte) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
@ -124,66 +67,6 @@ func (x *NodeInfo) SetState(v NetmapStatus) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
nodePubKeyFNum
|
|
||||||
nodeAddrFNum
|
|
||||||
nodeAttrsFNum
|
|
||||||
nodeStateFNum
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of node information
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *NodeInfo) StableMarshal(buf []byte) []byte {
|
|
||||||
if x == nil {
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sz := x.StableSize(); len(buf) < sz {
|
|
||||||
buf = make([]byte, sz)
|
|
||||||
}
|
|
||||||
|
|
||||||
offset := proto.BytesMarshal(nodePubKeyFNum, buf, x.PublicKey)
|
|
||||||
offset += proto.RepeatedStringMarshal(nodeAddrFNum, buf[offset:], x.Addresses)
|
|
||||||
|
|
||||||
for i := range x.Attributes {
|
|
||||||
offset += proto.NestedStructureMarshal(nodeAttrsFNum, buf[offset:], x.Attributes[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
proto.EnumMarshal(nodeStateFNum, buf[offset:], int32(x.State))
|
|
||||||
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableSize returns binary size of node information
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *NodeInfo) StableSize() int {
|
|
||||||
if x == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
size := 0
|
|
||||||
|
|
||||||
size += proto.BytesSize(nodePubKeyFNum, x.PublicKey)
|
|
||||||
size += proto.RepeatedStringSize(nodeAddrFNum, x.Addresses)
|
|
||||||
|
|
||||||
for i := range x.Attributes {
|
|
||||||
size += proto.NestedStructureSize(nodeAttrsFNum, x.Attributes[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
size += proto.EnumSize(nodeStateFNum, int32(x.State))
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetEpoch sets revision number of the network map.
|
// SetEpoch sets revision number of the network map.
|
||||||
func (x *Netmap) SetEpoch(v uint64) {
|
func (x *Netmap) SetEpoch(v uint64) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
@ -198,56 +81,6 @@ func (x *Netmap) SetNodes(v []*NodeInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
netmapEpochFNum
|
|
||||||
netmapNodesFNum
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of netmap in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *Netmap) StableMarshal(buf []byte) []byte {
|
|
||||||
if x == nil {
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sz := x.StableSize(); len(buf) < sz {
|
|
||||||
buf = make([]byte, sz)
|
|
||||||
}
|
|
||||||
|
|
||||||
offset := proto.UInt64Marshal(netmapEpochFNum, buf, x.Epoch)
|
|
||||||
|
|
||||||
for i := range x.Nodes {
|
|
||||||
offset += proto.NestedStructureMarshal(netmapNodesFNum, buf[offset:], x.Nodes[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableSize returns binary size of netmap in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *Netmap) StableSize() int {
|
|
||||||
if x == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
size := 0
|
|
||||||
|
|
||||||
size += proto.UInt64Size(netmapEpochFNum, x.Epoch)
|
|
||||||
|
|
||||||
for i := range x.Nodes {
|
|
||||||
size += proto.NestedStructureSize(netmapNodesFNum, x.Nodes[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Netmap) MarshalJSON() ([]byte, error) {
|
func (x *Netmap) MarshalJSON() ([]byte, error) {
|
||||||
return protojson.MarshalOptions{
|
return protojson.MarshalOptions{
|
||||||
EmitUnpopulated: true,
|
EmitUnpopulated: true,
|
||||||
|
@ -283,61 +116,3 @@ func (x *ShardInfo) SetMode(v ShardMode) {
|
||||||
func (x *ShardInfo) SetErrorCount(count uint32) {
|
func (x *ShardInfo) SetErrorCount(count uint32) {
|
||||||
x.ErrorCount = count
|
x.ErrorCount = count
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
shardInfoIDFNum
|
|
||||||
shardInfoMetabaseFNum
|
|
||||||
shardInfoBlobstorFNum
|
|
||||||
shardInfoWriteCacheFNum
|
|
||||||
shardInfoModeFNum
|
|
||||||
shardInfoErrorCountFNum
|
|
||||||
)
|
|
||||||
|
|
||||||
// StableSize returns binary size of shard information
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary size.
|
|
||||||
func (x *ShardInfo) StableSize() int {
|
|
||||||
if x == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
size := 0
|
|
||||||
|
|
||||||
size += proto.BytesSize(shardInfoIDFNum, x.Shard_ID)
|
|
||||||
size += proto.StringSize(shardInfoMetabaseFNum, x.MetabasePath)
|
|
||||||
size += proto.StringSize(shardInfoBlobstorFNum, x.BlobstorPath)
|
|
||||||
size += proto.StringSize(shardInfoWriteCacheFNum, x.WritecachePath)
|
|
||||||
size += proto.EnumSize(shardInfoModeFNum, int32(x.Mode))
|
|
||||||
size += proto.UInt32Size(shardInfoErrorCountFNum, x.ErrorCount)
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
|
|
||||||
// StableMarshal reads binary representation of shard information
|
|
||||||
// in protobuf binary format.
|
|
||||||
//
|
|
||||||
// If buffer length is less than x.StableSize(), new buffer is allocated.
|
|
||||||
//
|
|
||||||
// Returns the buffer in which the data is written.
|
|
||||||
//
|
|
||||||
// Structures with the same field values have the same binary format.
|
|
||||||
func (x *ShardInfo) StableMarshal(buf []byte) []byte {
|
|
||||||
if x == nil {
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sz := x.StableSize(); len(buf) < sz {
|
|
||||||
buf = make([]byte, sz)
|
|
||||||
}
|
|
||||||
|
|
||||||
offset := proto.BytesMarshal(shardInfoIDFNum, buf, x.Shard_ID)
|
|
||||||
offset += proto.StringMarshal(shardInfoMetabaseFNum, buf[offset:], x.MetabasePath)
|
|
||||||
offset += proto.StringMarshal(shardInfoBlobstorFNum, buf[offset:], x.BlobstorPath)
|
|
||||||
offset += proto.StringMarshal(shardInfoWriteCacheFNum, buf[offset:], x.WritecachePath)
|
|
||||||
offset += proto.EnumMarshal(shardInfoModeFNum, buf[offset:], int32(x.Mode))
|
|
||||||
proto.EnumMarshal(shardInfoErrorCountFNum, buf[offset:], int32(x.ErrorCount))
|
|
||||||
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
BIN
pkg/services/control/types.pb.go
generated
BIN
pkg/services/control/types.pb.go
generated
Binary file not shown.
BIN
pkg/services/control/types_neofs.pb.go
generated
Normal file
BIN
pkg/services/control/types_neofs.pb.go
generated
Normal file
Binary file not shown.
Loading…
Reference in a new issue