2020-08-18 13:48:58 +00:00
|
|
|
package netmap
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
netmap "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
|
|
|
protoutil "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
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
|
2021-12-01 13:42:31 +00:00
|
|
|
subnetIDPolicyField = 5
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (f *Filter) StableMarshal(buf []byte) []byte {
|
2020-09-04 10:05:56 +00:00
|
|
|
if f == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, f.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.StringMarshal(nameFilterField, buf[offset:], f.name)
|
|
|
|
offset += protoutil.StringMarshal(keyFilterField, buf[offset:], f.key)
|
|
|
|
offset += protoutil.EnumMarshal(opFilterField, buf[offset:], int32(f.op))
|
|
|
|
offset += protoutil.StringMarshal(valueFilterField, buf[offset:], f.value)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
for i := range f.filters {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(filtersFilterField, buf[offset:], &f.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2022-03-01 13:41:42 +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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (s *Selector) StableMarshal(buf []byte) []byte {
|
2020-09-04 10:05:56 +00:00
|
|
|
if s == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, s.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.StringMarshal(nameSelectorField, buf[offset:], s.name)
|
|
|
|
offset += protoutil.UInt32Marshal(countSelectorField, buf[offset:], s.count)
|
|
|
|
offset += protoutil.EnumMarshal(clauseSelectorField, buf[offset:], int32(s.clause))
|
|
|
|
offset += protoutil.StringMarshal(attributeSelectorField, buf[offset:], s.attribute)
|
|
|
|
protoutil.StringMarshal(filterSelectorField, buf[offset:], s.filter)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (r *Replica) StableMarshal(buf []byte) []byte {
|
2020-09-04 10:05:56 +00:00
|
|
|
if r == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, r.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt32Marshal(countReplicaField, buf[offset:], r.count)
|
|
|
|
protoutil.StringMarshal(selectorReplicaField, buf[offset:], r.selector)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (p *PlacementPolicy) StableMarshal(buf []byte) []byte {
|
2020-09-04 10:05:56 +00:00
|
|
|
if p == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, p.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
for i := range p.replicas {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(replicasPolicyField, buf[offset:], &p.replicas[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt32Marshal(backupPolicyField, buf[offset:], p.backupFactor)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
for i := range p.selectors {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(selectorsPolicyField, buf[offset:], &p.selectors[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range p.filters {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(filtersPolicyField, buf[offset:], &p.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
protoutil.NestedStructureMarshal(subnetIDPolicyField, buf[offset:], p.subnetID)
|
2021-12-01 13:42:31 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
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 {
|
2022-03-01 13:41:42 +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 {
|
2022-03-01 13:41:42 +00:00
|
|
|
size += protoutil.NestedStructureSize(selectorsPolicyField, &p.selectors[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range p.filters {
|
2022-03-01 13:41:42 +00:00
|
|
|
size += protoutil.NestedStructureSize(filtersPolicyField, &p.filters[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 13:42:31 +00:00
|
|
|
size += protoutil.NestedStructureSize(subnetIDPolicyField, p.subnetID)
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (a *Attribute) StableMarshal(buf []byte) []byte {
|
2020-09-01 07:46:20 +00:00
|
|
|
if a == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, a.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.StringMarshal(keyAttributeField, buf[offset:], a.key)
|
|
|
|
offset += protoutil.StringMarshal(valueAttributeField, buf[offset:], a.value)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
for i := range a.parents {
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.StringMarshal(parentsAttributeField, buf[offset:], a.parents[i])
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (ni *NodeInfo) StableMarshal(buf []byte) []byte {
|
2020-09-01 07:46:20 +00:00
|
|
|
if ni == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, ni.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.BytesMarshal(keyNodeInfoField, buf[offset:], ni.publicKey)
|
|
|
|
offset += protoutil.RepeatedStringMarshal(addressNodeInfoField, buf[offset:], ni.addresses)
|
2020-09-01 07:46:20 +00:00
|
|
|
|
|
|
|
for i := range ni.attributes {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(attributesNodeInfoField, buf[offset:], &ni.attributes[i])
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
protoutil.EnumMarshal(stateNodeInfoField, buf[offset:], int32(ni.state))
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2021-06-18 16:08:55 +00:00
|
|
|
size += protoutil.RepeatedStringSize(addressNodeInfoField, ni.addresses)
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
for i := range ni.attributes {
|
2022-03-02 07:40:22 +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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) StableMarshal(buf []byte) []byte {
|
|
|
|
return nil
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoRequestBody) StableSize() (size int) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) Unmarshal([]byte) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (l *LocalNodeInfoResponseBody) StableMarshal(buf []byte) []byte {
|
2020-10-08 11:22:28 +00:00
|
|
|
if l == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, l.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(versionInfoResponseBodyField, buf[offset:], l.version)
|
|
|
|
protoutil.NestedStructureMarshal(nodeInfoResponseBodyField, buf[offset:], l.nodeInfo)
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-09-28 08:10:20 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
netPrmKeyFNum
|
|
|
|
netPrmValFNum
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *NetworkParameter) StableMarshal(buf []byte) []byte {
|
2021-09-28 08:10:20 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
var offset int
|
2021-09-28 08:10:20 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.BytesMarshal(netPrmKeyFNum, buf[offset:], x.k)
|
|
|
|
protoutil.BytesMarshal(netPrmValFNum, buf[offset:], x.v)
|
2021-09-28 08:10:20 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetworkParameter) StableSize() (size int) {
|
|
|
|
if x == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += protoutil.BytesSize(netPrmKeyFNum, x.k)
|
|
|
|
size += protoutil.BytesSize(netPrmValFNum, x.v)
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
netCfgPrmsFNum
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (x *NetworkConfig) StableMarshal(buf []byte) []byte {
|
2021-09-28 08:10:20 +00:00
|
|
|
if x == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2021-09-28 08:10:20 +00:00
|
|
|
|
|
|
|
for i := range x.ps {
|
2022-04-05 08:24:34 +00:00
|
|
|
offset += protoutil.NestedStructureMarshal(netCfgPrmsFNum, buf[offset:], &x.ps[i])
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetworkConfig) StableSize() (size int) {
|
|
|
|
if x == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range x.ps {
|
2022-03-01 13:41:42 +00:00
|
|
|
size += protoutil.NestedStructureSize(netCfgPrmsFNum, &x.ps[i])
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2021-02-17 17:28:46 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
netInfoCurEpochFNum
|
|
|
|
netInfoMagicNumFNum
|
2021-09-28 08:10:20 +00:00
|
|
|
netInfoMSPerBlockFNum
|
|
|
|
netInfoCfgFNum
|
2021-02-17 17:28:46 +00:00
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (i *NetworkInfo) StableMarshal(buf []byte) []byte {
|
2021-02-17 17:28:46 +00:00
|
|
|
if i == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, i.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
var offset int
|
2021-02-17 17:28:46 +00:00
|
|
|
|
2022-03-12 12:20:19 +00:00
|
|
|
offset += protoutil.UInt64Marshal(netInfoCurEpochFNum, buf[offset:], i.curEpoch)
|
|
|
|
offset += protoutil.UInt64Marshal(netInfoMagicNumFNum, buf[offset:], i.magicNum)
|
|
|
|
offset += protoutil.Int64Marshal(netInfoMSPerBlockFNum, buf[offset:], i.msPerBlock)
|
2022-04-05 08:24:34 +00:00
|
|
|
protoutil.NestedStructureMarshal(netInfoCfgFNum, buf[offset:], i.netCfg)
|
2021-09-28 08:10:20 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *NetworkInfo) StableSize() (size int) {
|
|
|
|
if i == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
size += protoutil.UInt64Size(netInfoCurEpochFNum, i.curEpoch)
|
|
|
|
size += protoutil.UInt64Size(netInfoMagicNumFNum, i.magicNum)
|
2021-09-28 08:10:20 +00:00
|
|
|
size += protoutil.Int64Size(netInfoMSPerBlockFNum, i.msPerBlock)
|
|
|
|
size += protoutil.NestedStructureSize(netInfoCfgFNum, i.netCfg)
|
2021-02-17 17:28:46 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (l *NetworkInfoRequestBody) StableMarshal(buf []byte) []byte {
|
|
|
|
return nil
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
func (i *NetworkInfoResponseBody) StableMarshal(buf []byte) []byte {
|
2021-02-17 17:28:46 +00:00
|
|
|
if i == nil {
|
2022-04-05 08:24:34 +00:00
|
|
|
return []byte{}
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, i.StableSize())
|
|
|
|
}
|
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
protoutil.NestedStructureMarshal(netInfoRespBodyNetInfoFNum, buf, i.netInfo)
|
2021-02-17 17:28:46 +00:00
|
|
|
|
2022-04-05 08:24:34 +00:00
|
|
|
return buf
|
2021-02-17 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
}
|
2022-09-17 09:59:54 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
fNumNetMapEpoch
|
|
|
|
fNumNetMapNodes
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *NetMap) StableMarshal(buf []byte) []byte {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
offset := protoutil.UInt64Marshal(fNumNetMapEpoch, buf, x.epoch)
|
|
|
|
|
|
|
|
for i := range x.nodes {
|
|
|
|
offset += protoutil.NestedStructureMarshal(fNumNetMapNodes, buf[offset:], &x.nodes[i])
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetMap) StableSize() (size int) {
|
|
|
|
if x != nil {
|
|
|
|
size = protoutil.UInt64Size(fNumNetMapEpoch, x.epoch)
|
|
|
|
|
|
|
|
for i := range x.nodes {
|
|
|
|
size += protoutil.NestedStructureSize(fNumNetMapNodes, &x.nodes[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequestBody) StableMarshal([]byte) []byte {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequestBody) StableSize() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
fNumSnapshotResponseBodyNetMap
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x *SnapshotResponseBody) StableMarshal(buf []byte) []byte {
|
|
|
|
if x == nil {
|
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
protoutil.NestedStructureMarshal(fNumSnapshotResponseBodyNetMap, buf, x.netMap)
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponseBody) StableSize() (size int) {
|
|
|
|
if x != nil {
|
|
|
|
size = protoutil.NestedStructureSize(fNumSnapshotResponseBodyNetMap, x.netMap)
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|