forked from TrueCloudLab/frostfs-api-go
[#166] v2/netmap: add v2 structures for netmap service
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
fa18f5ede7
commit
a29b615522
8 changed files with 555 additions and 1 deletions
|
@ -33,6 +33,9 @@ const (
|
|||
addressNodeInfoField = 2
|
||||
attributesNodeInfoField = 3
|
||||
stateNodeInfoField = 4
|
||||
|
||||
versionInfoResponseBodyField = 1
|
||||
nodeInfoResponseBodyField = 2
|
||||
)
|
||||
|
||||
func (f *Filter) StableMarshal(buf []byte) ([]byte, error) {
|
||||
|
@ -381,3 +384,51 @@ func (ni *NodeInfo) StableSize() (size int) {
|
|||
|
||||
return size
|
||||
}
|
||||
|
||||
func (l *LocalNodeInfoRequestBody) StableMarshal(buf []byte) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (l *LocalNodeInfoRequestBody) StableSize() (size int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
n, err = proto.NestedStructureMarshal(versionInfoResponseBodyField, buf[offset:], l.version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
offset += n
|
||||
|
||||
_, err = proto.NestedStructureMarshal(nodeInfoResponseBodyField, buf[offset:], l.nodeInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (l *LocalNodeInfoResponseBody) StableSize() (size int) {
|
||||
if l == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += proto.NestedStructureSize(versionInfoResponseBodyField, l.version)
|
||||
size += proto.NestedStructureSize(nodeInfoResponseBodyField, l.nodeInfo)
|
||||
|
||||
return size
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue