Commit db2062f5 authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/proto: RequestIdentification += DevPath

This corresponds to NEO/py commit 97af23cc (Maximize resiliency by
taking into account the topology of storage nodes).
parent 7f67a252
......@@ -368,6 +368,7 @@ type RequestIdentification struct {
UUID NodeUUID
Address Address // where requesting node is also accepting connections
ClusterName string
DevPath []string // [] of devid
IdTime IdTime
}
......
......@@ -250,11 +250,12 @@ func TestMsgMarshal(t *testing.T) {
},
// uint32, Address, string, IdTime
{&RequestIdentification{CLIENT, 17, Address{"localhost", 7777}, "myname", 0.12345678},
{&RequestIdentification{CLIENT, 17, Address{"localhost", 7777}, "myname", []string{"room1", "rack234"}, 0.12345678},
u8(2) + u32(17) + u32(9) +
"localhost" + u16(7777) +
u32(6) + "myname" +
u32(2) + u32(5)+"room1" + u32(7)+"rack234" +
hex("3fbf9add1091c895"),
},
......
......@@ -65,7 +65,12 @@ func (*RequestIdentification) NEOMsgCode() uint16 {
}
func (p *RequestIdentification) NEOMsgEncodedLen() int {
return 9 + p.Address.neoEncodedLen() + len(p.ClusterName) + p.IdTime.neoEncodedLen()
var size int
for i := 0; i < len(p.DevPath); i++ {
a := &p.DevPath[i]
size += len((*a))
}
return 13 + p.Address.neoEncodedLen() + len(p.ClusterName) + len(p.DevPath)*4 + p.IdTime.neoEncodedLen() + size
}
func (p *RequestIdentification) NEOMsgEncode(data []byte) {
......@@ -82,6 +87,22 @@ func (p *RequestIdentification) NEOMsgEncode(data []byte) {
copy(data, p.ClusterName)
data = data[l:]
}
{
l := uint32(len(p.DevPath))
binary.BigEndian.PutUint32(data[0:], l)
data = data[4:]
for i := 0; uint32(i) < l; i++ {
a := &p.DevPath[i]
{
l := uint32(len((*a)))
binary.BigEndian.PutUint32(data[0:], l)
data = data[4:]
copy(data, (*a))
data = data[l:]
}
data = data[0:]
}
}
{
n := p.IdTime.neoEncode(data[0:])
data = data[0+n:]
......@@ -107,6 +128,25 @@ func (p *RequestIdentification) NEOMsgDecode(data []byte) (int, error) {
if len(data) < 4 {
goto overflow
}
{
l := binary.BigEndian.Uint32(data[0 : 0+4])
data = data[4:]
if uint64(len(data)) < 4+uint64(l) {
goto overflow
}
nread += 4 + uint64(l)
p.ClusterName = string(data[:l])
data = data[l:]
}
{
l := binary.BigEndian.Uint32(data[0 : 0+4])
data = data[4:]
p.DevPath = make([]string, l)
for i := 0; uint32(i) < l; i++ {
a := &p.DevPath[i]
if len(data) < 4 {
goto overflow
}
{
l := binary.BigEndian.Uint32(data[0 : 0+4])
data = data[4:]
......@@ -114,9 +154,12 @@ func (p *RequestIdentification) NEOMsgDecode(data []byte) (int, error) {
goto overflow
}
nread += uint64(l)
p.ClusterName = string(data[:l])
(*a) = string(data[:l])
data = data[l:]
}
}
nread += uint64(l) * 4
}
{
n, ok := p.IdTime.neoDecode(data)
if !ok {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment