2020-08-18 13:48:58 +00:00
|
|
|
package netmap
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
import (
|
2021-03-12 12:57:23 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/rpc/message"
|
2020-11-13 08:45:59 +00:00
|
|
|
protoutil "github.com/nspcc-dev/neofs-api-go/util/proto"
|
|
|
|
netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
|
2020-09-01 07:46:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-09-04 10:05:56 +00:00
|
|
|
nameFilterField = 1
|
|
|
|
keyFilterField = 2
|
|
|
|
opFilterField = 3
|
|
|
|
valueFilterField = 4
|
|
|
|
filtersFilterField = 5
|
|
|
|
|
|
|
|
nameSelectorField = 1
|
|
|
|
countSelectorField = 2
|
2020-09-08 10:19:22 +00:00
|
|
|
clauseSelectorField = 3
|
|
|
|
attributeSelectorField = 4
|
|
|
|
filterSelectorField = 5
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
countReplicaField = 1
|
|
|
|
selectorReplicaField = 2
|
|
|
|
|
|
|
|
replicasPolicyField = 1
|
|
|
|
backupPolicyField = 2
|
|
|
|
selectorsPolicyField = 3
|
|
|
|
filtersPolicyField = 4
|
|
|
|
|
|
|
|
keyAttributeField = 1
|
|
|
|
valueAttributeField = 2
|
|
|
|
parentsAttributeField = 3
|
2020-09-01 07:46:20 +00:00
|
|
|
|
|
|
|
keyNodeInfoField = 1
|
|
|
|
addressNodeInfoField = 2
|
|
|
|
attributesNodeInfoField = 3
|
2020-09-04 10:05:56 +00:00
|
|
|
stateNodeInfoField = 4
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
versionInfoResponseBodyField = 1
|
|
|
|
nodeInfoResponseBodyField = 2
|
2020-09-01 07:46:20 +00:00
|
|
|
)
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func (f *Filter) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if f == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, f.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(nameFilterField, buf[offset:], f.name)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(keyFilterField, buf[offset:], f.key)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.EnumMarshal(opFilterField, buf[offset:], int32(f.op))
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(valueFilterField, buf[offset:], f.value)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
for i := range f.filters {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(filtersFilterField, buf[offset:], f.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) StableSize() (size int) {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.StringSize(nameFilterField, f.name)
|
|
|
|
size += protoutil.StringSize(keyFilterField, f.key)
|
|
|
|
size += protoutil.EnumSize(opFilterField, int32(f.op))
|
|
|
|
size += protoutil.StringSize(valueFilterField, f.value)
|
2020-09-04 10:05:56 +00:00
|
|
|
for i := range f.filters {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(filtersFilterField, f.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (f *Filter) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(f, data, new(netmap.Filter))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func (s *Selector) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if s == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, s.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(nameSelectorField, buf[offset:], s.name)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.UInt32Marshal(countSelectorField, buf[offset:], s.count)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.EnumMarshal(clauseSelectorField, buf[offset:], int32(s.clause))
|
2020-09-08 10:19:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(attributeSelectorField, buf[offset:], s.attribute)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2021-01-11 16:32:37 +00:00
|
|
|
_, err = protoutil.StringMarshal(filterSelectorField, buf[offset:], s.filter)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) StableSize() (size int) {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.StringSize(nameSelectorField, s.name)
|
|
|
|
size += protoutil.UInt32Size(countSelectorField, s.count)
|
|
|
|
size += protoutil.EnumSize(countSelectorField, int32(s.clause))
|
|
|
|
size += protoutil.StringSize(attributeSelectorField, s.attribute)
|
|
|
|
size += protoutil.StringSize(filterSelectorField, s.filter)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (s *Selector) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(s, data, new(netmap.Selector))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func (r *Replica) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if r == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.UInt32Marshal(countReplicaField, buf[offset:], r.count)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2021-01-11 16:32:37 +00:00
|
|
|
_, err = protoutil.StringMarshal(selectorReplicaField, buf[offset:], r.selector)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) StableSize() (size int) {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.UInt32Size(countReplicaField, r.count)
|
|
|
|
size += protoutil.StringSize(selectorReplicaField, r.selector)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (r *Replica) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(r, data, new(netmap.Replica))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 13:48:58 +00:00
|
|
|
func (p *PlacementPolicy) StableMarshal(buf []byte) ([]byte, error) {
|
2020-09-04 10:05:56 +00:00
|
|
|
if p == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, p.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
for i := range p.replicas {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(replicasPolicyField, buf[offset:], p.replicas[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.UInt32Marshal(backupPolicyField, buf[offset:], p.backupFactor)
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
for i := range p.selectors {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(selectorsPolicyField, buf[offset:], p.selectors[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range p.filters {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(filtersPolicyField, buf[offset:], p.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
2020-08-18 13:48:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PlacementPolicy) StableSize() (size int) {
|
2020-09-04 10:05:56 +00:00
|
|
|
for i := range p.replicas {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(replicasPolicyField, p.replicas[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.UInt32Size(backupPolicyField, p.backupFactor)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
for i := range p.selectors {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(selectorsPolicyField, p.selectors[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range p.filters {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(filtersPolicyField, p.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
2020-08-18 13:48:58 +00:00
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (p *PlacementPolicy) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(p, data, new(netmap.PlacementPolicy))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
func (a *Attribute) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if a == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, a.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(keyAttributeField, buf[offset:], a.key)
|
2020-09-01 07:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(valueAttributeField, buf[offset:], a.value)
|
2020-09-01 07:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
offset += n
|
|
|
|
|
|
|
|
for i := range a.parents {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(parentsAttributeField, buf[offset:], a.parents[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) StableSize() (size int) {
|
|
|
|
if a == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.StringSize(keyAttributeField, a.key)
|
|
|
|
size += protoutil.StringSize(valueAttributeField, a.value)
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
for i := range a.parents {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.StringSize(parentsAttributeField, a.parents[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (a *Attribute) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(a, data, new(netmap.NodeInfo_Attribute))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
func (ni *NodeInfo) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if ni == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, ni.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.BytesMarshal(keyNodeInfoField, buf[offset:], ni.publicKey)
|
2020-09-01 07:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.StringMarshal(addressNodeInfoField, buf[offset:], ni.address)
|
2020-09-01 07:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
for i := range ni.attributes {
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(attributesNodeInfoField, buf[offset:], ni.attributes[i])
|
2020-09-01 07:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
}
|
|
|
|
|
2021-01-11 16:32:37 +00:00
|
|
|
_, err = protoutil.EnumMarshal(stateNodeInfoField, buf[offset:], int32(ni.state))
|
2020-09-04 10:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ni *NodeInfo) StableSize() (size int) {
|
|
|
|
if ni == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.BytesSize(keyNodeInfoField, ni.publicKey)
|
|
|
|
size += protoutil.StringSize(addressNodeInfoField, ni.address)
|
2020-09-01 07:46:20 +00:00
|
|
|
for i := range ni.attributes {
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(attributesNodeInfoField, ni.attributes[i])
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.EnumSize(stateNodeInfoField, int32(ni.state))
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
return size
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
func (ni *NodeInfo) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(ni, data, new(netmap.NodeInfo))
|
2020-11-13 08:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 11:22:28 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoRequestBody) StableSize() (size int) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) Unmarshal([]byte) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-08 11:22:28 +00:00
|
|
|
func (l *LocalNodeInfoResponseBody) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if l == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, l.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
n, err = protoutil.NestedStructureMarshal(versionInfoResponseBodyField, buf[offset:], l.version)
|
2020-10-08 11:22:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
_, err = protoutil.NestedStructureMarshal(nodeInfoResponseBodyField, buf[offset:], l.nodeInfo)
|
2020-10-08 11:22:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) StableSize() (size int) {
|
|
|
|
if l == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2020-11-13 08:45:59 +00:00
|
|
|
size += protoutil.NestedStructureSize(versionInfoResponseBodyField, l.version)
|
|
|
|
size += protoutil.NestedStructureSize(nodeInfoResponseBodyField, l.nodeInfo)
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
2021-02-17 17:28:46 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoResponseBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(l, data, new(netmap.LocalNodeInfoResponse_Body))
|
|
|
|
}
|
|
|
|
|
2021-02-17 17:28:46 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
netInfoCurEpochFNum
|
|
|
|
netInfoMagicNumFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (i *NetworkInfo) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if i == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, i.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
offset, n int
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
n, err = protoutil.UInt64Marshal(netInfoCurEpochFNum, buf[offset:], i.curEpoch)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += n
|
|
|
|
|
|
|
|
_, err = protoutil.UInt64Marshal(netInfoMagicNumFNum, buf[offset:], i.magicNum)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *NetworkInfo) StableSize() (size int) {
|
|
|
|
if i == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += protoutil.UInt64Size(netInfoCurEpochFNum, i.curEpoch)
|
|
|
|
size += protoutil.UInt64Size(netInfoMagicNumFNum, i.magicNum)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *NetworkInfo) Unmarshal(data []byte) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
return message.Unmarshal(i, data, new(netmap.NetworkInfo))
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoRequestBody) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoRequestBody) StableSize() (size int) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoRequestBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(l, data, new(netmap.NetworkInfoRequest_Body))
|
|
|
|
}
|
|
|
|
|
2021-02-17 17:28:46 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
netInfoRespBodyNetInfoFNum
|
|
|
|
)
|
|
|
|
|
|
|
|
func (i *NetworkInfoResponseBody) StableMarshal(buf []byte) ([]byte, error) {
|
|
|
|
if i == nil {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, i.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := protoutil.NestedStructureMarshal(netInfoRespBodyNetInfoFNum, buf, i.netInfo)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *NetworkInfoResponseBody) StableSize() (size int) {
|
|
|
|
if i == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += protoutil.NestedStructureSize(netInfoRespBodyNetInfoFNum, i.netInfo)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
func (i *NetworkInfoResponseBody) Unmarshal(data []byte) error {
|
|
|
|
return message.Unmarshal(i, data, new(netmap.NetworkInfoResponse_Body))
|
|
|
|
}
|