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

go/neo/proto: Update msgcode increment logic to new protocol

In pre-msgpack protocol, the msgcode increment logic is like this:

Notify 	 add +1 to next msgcode
Request  add +0 to next msgcode   (next msg is answer & should therefore be the same)
Answer 	 add +1 to next msgcode

('Answer' msgcode is adjusted by 'AnswerBit')

In post-msgpack protocol, the logic is a bit different:

Notify 	 add +1 to next msgcode
Request  add +0 to next msgcode   (next msg is answer & should therefore be the same)
Answer 	 add +2 to next msgcode

So here we produce gaps after Request/Answer pairs.
parent 2d27b4a1
...@@ -371,12 +371,18 @@ import ( ...@@ -371,12 +371,18 @@ import (
// generate code for this type to implement neo.Msg // generate code for this type to implement neo.Msg
var msgCode MsgCode var msgCode MsgCode
msgCode.answer = specAnnotation.answer || strings.HasPrefix(typename, "Answer") msgCode.answer = specAnnotation.answer || strings.HasPrefix(typename, "Answer")
msgCode.msgSerial = msgSerial
// increment msgSerial only by +1 when going from // increment msgSerial only by +1 when going from
// request1->request2 in `Request1 Answer1 Request2`. // request1->request2 in `Request1 Answer1 Request2`.
// Unlike as it was in pre-msgpack protocol, the global
// increment is still +1, only for the answer packet
// itself it's the same as the request packet. This means
// in the post-msgpack protocol there are gaps.
if msgCode.answer && typename != "Error" { if msgCode.answer && typename != "Error" {
msgSerial-- msgCode.msgSerial = msgSerial - 1
} }
msgCode.msgSerial = msgSerial
fmt.Fprintf(&buf, "// %s. %s\n\n", msgCode, typename) fmt.Fprintf(&buf, "// %s. %s\n\n", msgCode, typename)
......
This diff is collapsed.
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