Commit 5d93e434 authored by Levin Zimmermann's avatar Levin Zimmermann

proto.NotPrimaryMaster: Fix .Primary data type

The '.Primary' attribute of the 'NotPrimaryMaster' packet has been
assigned to 'NodeID' data type. This is incorrect, because the data
doesn't represent the ID of the node, but an index of the
'.KnownMasterList' [1]. In the old protocol NEO/py therefore also
used 'PSignedNull' instead of 'PUUID' [2]. This patches fixes the data
type of '.Primary' and uses 'int8' instead of 'NodeID'. Technically this
doesn't make any difference, but semantically for human beings the code
is easier to understand now.

[1] https://lab.nexedi.com/nexedi/neoppod/blob/c6453626/neo/lib/handler.py#L161
[2] https://lab.nexedi.com/nexedi/neoppod/blob/c6453626/neo/lib/protocol.py#L716
parent 22e5d1e9
...@@ -457,7 +457,7 @@ type AnswerPrimary struct { ...@@ -457,7 +457,7 @@ type AnswerPrimary struct {
// //
//neo:nodes SM -> * //neo:nodes SM -> *
type NotPrimaryMaster struct { type NotPrimaryMaster struct {
Primary NodeID // XXX PSignedNull in py Primary int8
KnownMasterList []struct { KnownMasterList []struct {
Address Address
} }
......
...@@ -807,7 +807,7 @@ func (p *NotPrimaryMaster) neoMsgDecodeN(data []byte) (int, error) { ...@@ -807,7 +807,7 @@ func (p *NotPrimaryMaster) neoMsgDecodeN(data []byte) (int, error) {
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Primary = NodeID(int32(binary.BigEndian.Uint32(data[0 : 0+4]))) p.Primary = int8(int32(binary.BigEndian.Uint32(data[0 : 0+4])))
{ {
l := binary.BigEndian.Uint32(data[4 : 4+4]) l := binary.BigEndian.Uint32(data[4 : 4+4])
data = data[8:] data = data[8:]
...@@ -882,7 +882,7 @@ func (p *NotPrimaryMaster) neoMsgDecodeM(data []byte) (int, error) { ...@@ -882,7 +882,7 @@ func (p *NotPrimaryMaster) neoMsgDecodeM(data []byte) (int, error) {
if err != nil { if err != nil {
return 0, mdecodeErr("NotPrimaryMaster.Primary", err) return 0, mdecodeErr("NotPrimaryMaster.Primary", err)
} }
p.Primary = NodeID(v) p.Primary = int8(v)
nread += uint64(len(data) - len(tail)) nread += uint64(len(data) - len(tail))
data = tail data = tail
} }
......
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