Commit 6e705e4e authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/proto: protogen: Factor-out handling of slice and map heads into common place

genSliceHead and genMapHead will be reused for MsgPack encoding.
Changes in generated code are mostly due to move of where things are
typecasted to e.g. uint32 without any change in semantic.
parent 1bb595cf
...@@ -479,6 +479,15 @@ type CodeGenerator interface { ...@@ -479,6 +479,15 @@ type CodeGenerator interface {
generatedCode() string generatedCode() string
} }
// interface for codegenerators to inject themselves into {sizer/encoder/decoder}Common.
type CodeGenCustomize interface {
CodeGenerator
// generate code to process slice or map header
genSliceHead(path string, typ *types.Slice, obj types.Object)
genMapHead(path string, typ *types.Map, obj types.Object)
}
// X reports encoding=X // X reports encoding=X
type N struct{}; func (_ *N) encoding() byte { return 'N' } type N struct{}; func (_ *N) encoding() byte { return 'N' }
...@@ -981,11 +990,18 @@ func (d *decoderN) genBuf(assignto string) { ...@@ -981,11 +990,18 @@ func (d *decoderN) genBuf(assignto string) {
// emit code to size/encode/decode slice // emit code to size/encode/decode slice
// len u32 // len u32
// [len]item // [len]item
func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) { func (s *sizerN) genSliceHead(path string, typ *types.Slice, obj types.Object) {
s.size.Add(4) s.size.Add(4)
}
func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) {
s.genSliceCommon(s, path, typ, obj)
}
func (s *sizerCommon) genSliceCommon(xs CodeGenCustomize, path string, typ *types.Slice, obj types.Object) {
xs.genSliceHead(path, typ, obj)
// if size(item)==const - size update in one go // if size(item)==const - size update in one go
elemSize, ok := typeSizeFixed(s.encoding(), typ.Elem()) elemSize, ok := typeSizeFixed(xs.encoding(), typ.Elem())
if ok { if ok {
s.size.AddExpr("len(%v) * %v", path, elemSize) s.size.AddExpr("len(%v) * %v", path, elemSize)
return return
...@@ -997,7 +1013,7 @@ func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) { ...@@ -997,7 +1013,7 @@ func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) {
s.emit("for i := 0; i < len(%v); i++ {", path) s.emit("for i := 0; i < len(%v); i++ {", path)
s.emit("a := &%s[i]", path) s.emit("a := &%s[i]", path)
codegenType("(*a)", typ.Elem(), obj, s) codegenType("(*a)", typ.Elem(), obj, xs)
// merge-in size updates // merge-in size updates
s.emit("%v += %v", s.var_("size"), s.size.ExprString()) s.emit("%v += %v", s.var_("size"), s.size.ExprString())
...@@ -1008,29 +1024,45 @@ func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) { ...@@ -1008,29 +1024,45 @@ func (s *sizerN) genSlice(path string, typ *types.Slice, obj types.Object) {
s.size = curSize s.size = curSize
} }
func (e *encoderN) genSlice(path string, typ *types.Slice, obj types.Object) { func (e *encoderN) genSliceHead(path string, typ *types.Slice, obj types.Object) {
e.emit("{") e.emit("l := len(%s)", path)
e.emit("l := uint32(len(%s))", path) e.genBasic("l", types.Typ[types.Uint32], types.Typ[types.Int])
e.genBasic("l", types.Typ[types.Uint32], nil)
e.emit("data = data[%v:]", e.n) e.emit("data = data[%v:]", e.n)
e.n = 0 e.n = 0
e.emit("for i := 0; uint32(i) <l; i++ {") }
func (e *encoderN) genSlice(path string, typ *types.Slice, obj types.Object) {
e.genSliceCommon(e, path, typ, obj)
}
func (e *encoderCommon) genSliceCommon(xe CodeGenCustomize, path string, typ *types.Slice, obj types.Object) {
e.emit("{")
xe.genSliceHead(path, typ, obj)
e.emit("for i := 0; i <l; i++ {")
e.emit("a := &%s[i]", path) e.emit("a := &%s[i]", path)
codegenType("(*a)", typ.Elem(), obj, e) codegenType("(*a)", typ.Elem(), obj, xe)
if e.n != 0 {
e.emit("data = data[%v:]", e.n) e.emit("data = data[%v:]", e.n)
e.n = 0
}
e.emit("}") e.emit("}")
e.emit("}") e.emit("}")
e.n = 0
} }
func (d *decoderN) genSliceHead(assignto string, typ *types.Slice, obj types.Object) {
d.genBasic("l:", types.Typ[types.Uint32], nil)
}
func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object) { func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object) {
d.genSliceCommon(d, assignto, typ, obj)
}
func (d *decoderCommon) genSliceCommon(xd CodeGenCustomize, assignto string, typ *types.Slice, obj types.Object) {
d.emit("{") d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil) xd.genSliceHead(assignto, typ, obj)
d.resetPos() d.resetPos()
// if size(item)==const - check overflow in one go // if size(item)==const - check overflow in one go
elemSize, elemFixed := typeSizeFixed(d.encoding(), typ.Elem()) elemSize, elemFixed := typeSizeFixed(xd.encoding(), typ.Elem())
if elemFixed { if elemFixed {
d.overflowCheck() d.overflowCheck()
d.overflow.AddExpr("uint64(l) * %v", elemSize) d.overflow.AddExpr("uint64(l) * %v", elemSize)
...@@ -1043,7 +1075,7 @@ func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object) ...@@ -1043,7 +1075,7 @@ func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object)
d.emit("a := &%s[i]", assignto) d.emit("a := &%s[i]", assignto)
d.overflowCheckLoopEntry() d.overflowCheckLoopEntry()
codegenType("(*a)", typ.Elem(), obj, d) codegenType("(*a)", typ.Elem(), obj, xd)
d.resetPos() d.resetPos()
d.emit("}") d.emit("}")
...@@ -1055,24 +1087,31 @@ func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object) ...@@ -1055,24 +1087,31 @@ func (d *decoderN) genSlice(assignto string, typ *types.Slice, obj types.Object)
// generate code to encode/decode map // generate code to encode/decode map
// len u32 // len u32
// [len](key, value) // [len](key, value)
func (s *sizerN) genMapHead(path string, typ *types.Map, obj types.Object) {
s.size.Add(4)
}
func (s *sizerN) genMap(path string, typ *types.Map, obj types.Object) { func (s *sizerN) genMap(path string, typ *types.Map, obj types.Object) {
keySize, keyFixed := typeSizeFixed(s.encoding(), typ.Key()) s.genMapCommon(s, path, typ, obj)
elemSize, elemFixed := typeSizeFixed(s.encoding(), typ.Elem()) }
func (s *sizerCommon) genMapCommon(xs CodeGenCustomize, path string, typ *types.Map, obj types.Object) {
xs.genMapHead(path, typ, obj)
keySize, keyFixed := typeSizeFixed(xs.encoding(), typ.Key())
elemSize, elemFixed := typeSizeFixed(xs.encoding(), typ.Elem())
if keyFixed && elemFixed { if keyFixed && elemFixed {
s.size.Add(4)
s.size.AddExpr("len(%v) * %v", path, keySize+elemSize) s.size.AddExpr("len(%v) * %v", path, keySize+elemSize)
return return
} }
s.size.Add(4)
curSize := s.size curSize := s.size
s.size.Reset() s.size.Reset()
// FIXME for map of map gives ...[key][key] => key -> different variables // FIXME for map of map gives ...[key][key] => key -> different variables
s.emit("for key := range %s {", path) s.emit("for key := range %s {", path)
codegenType("key", typ.Key(), obj, s) codegenType("key", typ.Key(), obj, xs)
codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, s) codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, xs)
// merge-in size updates // merge-in size updates
s.emit("%v += %v", s.var_("size"), s.size.ExprString()) s.emit("%v += %v", s.var_("size"), s.size.ExprString())
...@@ -1083,12 +1122,19 @@ func (s *sizerN) genMap(path string, typ *types.Map, obj types.Object) { ...@@ -1083,12 +1122,19 @@ func (s *sizerN) genMap(path string, typ *types.Map, obj types.Object) {
s.size = curSize s.size = curSize
} }
func (e *encoderN) genMap(path string, typ *types.Map, obj types.Object) { func (e *encoderN) genMapHead(path string, typ *types.Map, obj types.Object) {
e.emit("{") e.emit("l := len(%s)", path)
e.emit("l := uint32(len(%s))", path) e.genBasic("l", types.Typ[types.Uint32], types.Typ[types.Int])
e.genBasic("l", types.Typ[types.Uint32], nil)
e.emit("data = data[%v:]", e.n) e.emit("data = data[%v:]", e.n)
e.n = 0 e.n = 0
}
func (e *encoderN) genMap(path string, typ *types.Map, obj types.Object) {
e.genMapCommon(e, path, typ, obj)
}
func (e *encoderCommon) genMapCommon(xe CodeGenCustomize, path string, typ *types.Map, obj types.Object) {
e.emit("{")
xe.genMapHead(path, typ, obj)
// output keys in sorted order on the wire // output keys in sorted order on the wire
// (easier for debugging & deterministic for testing) // (easier for debugging & deterministic for testing)
...@@ -1099,23 +1145,32 @@ func (e *encoderN) genMap(path string, typ *types.Map, obj types.Object) { ...@@ -1099,23 +1145,32 @@ func (e *encoderN) genMap(path string, typ *types.Map, obj types.Object) {
e.emit("sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })") e.emit("sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })")
e.emit("for _, key := range keyv {") e.emit("for _, key := range keyv {")
codegenType("key", typ.Key(), obj, e) codegenType("key", typ.Key(), obj, xe)
codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, e) codegenType(fmt.Sprintf("%s[key]", path), typ.Elem(), obj, xe)
if e.n != 0 {
e.emit("data = data[%v:]", e.n) // XXX wrt map of map? e.emit("data = data[%v:]", e.n) // XXX wrt map of map?
e.n = 0
}
e.emit("}") e.emit("}")
e.emit("}") e.emit("}")
e.n = 0
} }
func (d *decoderN) genMapHead(assignto string, typ *types.Map, obj types.Object) {
d.genBasic("l:", types.Typ[types.Uint32], nil)
}
func (d *decoderN) genMap(assignto string, typ *types.Map, obj types.Object) { func (d *decoderN) genMap(assignto string, typ *types.Map, obj types.Object) {
d.genMapCommon(d, assignto, typ, obj)
}
func (d *decoderCommon) genMapCommon(xd CodeGenCustomize, assignto string, typ *types.Map, obj types.Object) {
d.emit("{") d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil) xd.genMapHead(assignto, typ, obj)
d.resetPos() d.resetPos()
// if size(key,item)==const - check overflow in one go // if size(key,item)==const - check overflow in one go
keySize, keyFixed := typeSizeFixed(d.encoding(), typ.Key()) keySize, keyFixed := typeSizeFixed(xd.encoding(), typ.Key())
elemSize, elemFixed := typeSizeFixed(d.encoding(), typ.Elem()) elemSize, elemFixed := typeSizeFixed(xd.encoding(), typ.Elem())
if keyFixed && elemFixed { if keyFixed && elemFixed {
d.overflowCheck() d.overflowCheck()
d.overflow.AddExpr("uint64(l) * %v", keySize+elemSize) d.overflow.AddExpr("uint64(l) * %v", keySize+elemSize)
...@@ -1128,18 +1183,19 @@ func (d *decoderN) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -1128,18 +1183,19 @@ func (d *decoderN) genMap(assignto string, typ *types.Map, obj types.Object) {
d.emit("for i := 0; uint32(i) < l; i++ {") d.emit("for i := 0; uint32(i) < l; i++ {")
d.overflowCheckLoopEntry() d.overflowCheckLoopEntry()
codegenType("key:", typ.Key(), obj, d) d.emit("var key %s", typeName(typ.Key()))
codegenType("key", typ.Key(), obj, xd)
switch typ.Elem().Underlying().(type) { switch typ.Elem().Underlying().(type) {
// basic types can be directly assigned to map entry // basic types can be directly assigned to map entry
case *types.Basic: case *types.Basic:
codegenType("m[key]", typ.Elem(), obj, d) codegenType("m[key]", typ.Elem(), obj, xd)
// otherwise assign via temporary // otherwise assign via temporary
default: default:
d.emit("var v %v", typeName(typ.Elem())) d.emit("var mv %v", typeName(typ.Elem()))
codegenType("v", typ.Elem(), obj, d) codegenType("mv", typ.Elem(), obj, xd)
d.emit("m[key] = v") d.emit("m[key] = mv")
} }
d.resetPos() d.resetPos()
......
...@@ -92,10 +92,10 @@ func (p *RequestIdentification) neoMsgEncodeN(data []byte) { ...@@ -92,10 +92,10 @@ func (p *RequestIdentification) neoMsgEncodeN(data []byte) {
data = data[0+n:] data = data[0+n:]
} }
{ {
l := uint32(len(p.DevPath)) l := len(p.DevPath)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.DevPath[i] a := &p.DevPath[i]
{ {
l := uint32(len((*a))) l := uint32(len((*a)))
...@@ -104,14 +104,13 @@ func (p *RequestIdentification) neoMsgEncodeN(data []byte) { ...@@ -104,14 +104,13 @@ func (p *RequestIdentification) neoMsgEncodeN(data []byte) {
copy(data, (*a)) copy(data, (*a))
data = data[l:] data = data[l:]
} }
data = data[0:]
} }
} }
{ {
l := uint32(len(p.NewNID)) l := len(p.NewNID)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NewNID[i] a := &p.NewNID[i]
binary.BigEndian.PutUint32(data[0:], (*a)) binary.BigEndian.PutUint32(data[0:], (*a))
data = data[4:] data = data[4:]
...@@ -344,16 +343,15 @@ func (p *NotPrimaryMaster) neoMsgEncodedLenN() int { ...@@ -344,16 +343,15 @@ func (p *NotPrimaryMaster) neoMsgEncodedLenN() int {
func (p *NotPrimaryMaster) neoMsgEncodeN(data []byte) { func (p *NotPrimaryMaster) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint32(data[0:], uint32(int32(p.Primary))) binary.BigEndian.PutUint32(data[0:], uint32(int32(p.Primary)))
{ {
l := uint32(len(p.KnownMasterList)) l := len(p.KnownMasterList)
binary.BigEndian.PutUint32(data[4:], l) binary.BigEndian.PutUint32(data[4:], uint32(l))
data = data[8:] data = data[8:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.KnownMasterList[i] a := &p.KnownMasterList[i]
{ {
n := (*a).neoEncodeN(data[0:]) n := (*a).neoEncodeN(data[0:])
data = data[0+n:] data = data[0+n:]
} }
data = data[0:]
} }
} }
} }
...@@ -407,10 +405,10 @@ func (p *NotifyNodeInformation) neoMsgEncodeN(data []byte) { ...@@ -407,10 +405,10 @@ func (p *NotifyNodeInformation) neoMsgEncodeN(data []byte) {
data = data[0+n:] data = data[0+n:]
} }
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
(data[0:])[0] = uint8(int8((*a).Type)) (data[0:])[0] = uint8(int8((*a).Type))
{ {
...@@ -423,7 +421,6 @@ func (p *NotifyNodeInformation) neoMsgEncodeN(data []byte) { ...@@ -423,7 +421,6 @@ func (p *NotifyNodeInformation) neoMsgEncodeN(data []byte) {
n := (*a).IdTime.neoEncodeN(data[5:]) n := (*a).IdTime.neoEncodeN(data[5:])
data = data[5+n:] data = data[5+n:]
} }
data = data[0:]
} }
} }
} }
...@@ -609,23 +606,22 @@ func (p *AnswerPartitionTable) neoMsgEncodeN(data []byte) { ...@@ -609,23 +606,22 @@ func (p *AnswerPartitionTable) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.PTid)) binary.BigEndian.PutUint64(data[0:], uint64(p.PTid))
binary.BigEndian.PutUint32(data[8:], p.NumReplicas) binary.BigEndian.PutUint32(data[8:], p.NumReplicas)
{ {
l := uint32(len(p.RowList)) l := len(p.RowList)
binary.BigEndian.PutUint32(data[12:], l) binary.BigEndian.PutUint32(data[12:], uint32(l))
data = data[16:] data = data[16:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := len((*a).CellList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID)))
(data[4:])[0] = uint8(int8((*a).State)) (data[4:])[0] = uint8(int8((*a).State))
data = data[5:] data = data[5:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -689,23 +685,22 @@ func (p *SendPartitionTable) neoMsgEncodeN(data []byte) { ...@@ -689,23 +685,22 @@ func (p *SendPartitionTable) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.PTid)) binary.BigEndian.PutUint64(data[0:], uint64(p.PTid))
binary.BigEndian.PutUint32(data[8:], p.NumReplicas) binary.BigEndian.PutUint32(data[8:], p.NumReplicas)
{ {
l := uint32(len(p.RowList)) l := len(p.RowList)
binary.BigEndian.PutUint32(data[12:], l) binary.BigEndian.PutUint32(data[12:], uint32(l))
data = data[16:] data = data[16:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := len((*a).CellList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID)))
(data[4:])[0] = uint8(int8((*a).State)) (data[4:])[0] = uint8(int8((*a).State))
data = data[5:] data = data[5:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -764,10 +759,10 @@ func (p *NotifyPartitionChanges) neoMsgEncodeN(data []byte) { ...@@ -764,10 +759,10 @@ func (p *NotifyPartitionChanges) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.PTid)) binary.BigEndian.PutUint64(data[0:], uint64(p.PTid))
binary.BigEndian.PutUint32(data[8:], p.NumReplicas) binary.BigEndian.PutUint32(data[8:], p.NumReplicas)
{ {
l := uint32(len(p.CellList)) l := len(p.CellList)
binary.BigEndian.PutUint32(data[12:], l) binary.BigEndian.PutUint32(data[12:], uint32(l))
data = data[16:] data = data[16:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
binary.BigEndian.PutUint32(data[0:], (*a).Offset) binary.BigEndian.PutUint32(data[0:], (*a).Offset)
binary.BigEndian.PutUint32(data[4:], uint32(int32((*a).CellInfo.UUID))) binary.BigEndian.PutUint32(data[4:], uint32(int32((*a).CellInfo.UUID)))
...@@ -863,10 +858,10 @@ func (p *UnfinishedTransactions) neoMsgEncodedLenN() int { ...@@ -863,10 +858,10 @@ func (p *UnfinishedTransactions) neoMsgEncodedLenN() int {
func (p *UnfinishedTransactions) neoMsgEncodeN(data []byte) { func (p *UnfinishedTransactions) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.RowList)) l := len(p.RowList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
binary.BigEndian.PutUint32(data[0:], (*a).Offset) binary.BigEndian.PutUint32(data[0:], (*a).Offset)
data = data[4:] data = data[4:]
...@@ -912,10 +907,10 @@ func (p *AnswerUnfinishedTransactions) neoMsgEncodedLenN() int { ...@@ -912,10 +907,10 @@ func (p *AnswerUnfinishedTransactions) neoMsgEncodedLenN() int {
func (p *AnswerUnfinishedTransactions) neoMsgEncodeN(data []byte) { func (p *AnswerUnfinishedTransactions) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.MaxTID)) binary.BigEndian.PutUint64(data[0:], uint64(p.MaxTID))
{ {
l := uint32(len(p.TidList)) l := len(p.TidList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a).UnfinishedTID)) binary.BigEndian.PutUint64(data[0:], uint64((*a).UnfinishedTID))
data = data[8:] data = data[8:]
...@@ -978,8 +973,8 @@ func (p *AnswerLockedTransactions) neoMsgEncodedLenN() int { ...@@ -978,8 +973,8 @@ func (p *AnswerLockedTransactions) neoMsgEncodedLenN() int {
func (p *AnswerLockedTransactions) neoMsgEncodeN(data []byte) { func (p *AnswerLockedTransactions) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.TidDict)) l := len(p.TidDict)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
keyv := make([]zodb.Tid, 0, l) keyv := make([]zodb.Tid, 0, l)
for key := range p.TidDict { for key := range p.TidDict {
...@@ -1009,7 +1004,8 @@ func (p *AnswerLockedTransactions) neoMsgDecodeN(data []byte) (int, error) { ...@@ -1009,7 +1004,8 @@ func (p *AnswerLockedTransactions) neoMsgDecodeN(data []byte) (int, error) {
p.TidDict = make(map[zodb.Tid]zodb.Tid, l) p.TidDict = make(map[zodb.Tid]zodb.Tid, l)
m := p.TidDict m := p.TidDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
key := zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8])) var key zodb.Tid
key = zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8]))
m[key] = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8])) m[key] = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8]))
data = data[16:] data = data[16:]
} }
...@@ -1160,10 +1156,10 @@ func (p *FailedVote) neoMsgEncodedLenN() int { ...@@ -1160,10 +1156,10 @@ func (p *FailedVote) neoMsgEncodedLenN() int {
func (p *FailedVote) neoMsgEncodeN(data []byte) { func (p *FailedVote) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Tid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Tid))
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -1210,20 +1206,20 @@ func (p *FinishTransaction) neoMsgEncodedLenN() int { ...@@ -1210,20 +1206,20 @@ func (p *FinishTransaction) neoMsgEncodedLenN() int {
func (p *FinishTransaction) neoMsgEncodeN(data []byte) { func (p *FinishTransaction) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Tid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Tid))
{ {
l := uint32(len(p.OIDList)) l := len(p.OIDList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OIDList[i] a := &p.OIDList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
} }
} }
{ {
l := uint32(len(p.CheckedList)) l := len(p.CheckedList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.CheckedList[i] a := &p.CheckedList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -1363,10 +1359,10 @@ func (p *InvalidateObjects) neoMsgEncodedLenN() int { ...@@ -1363,10 +1359,10 @@ func (p *InvalidateObjects) neoMsgEncodedLenN() int {
func (p *InvalidateObjects) neoMsgEncodeN(data []byte) { func (p *InvalidateObjects) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Tid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Tid))
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -1462,10 +1458,10 @@ func (p *AnswerNewOIDs) neoMsgEncodedLenN() int { ...@@ -1462,10 +1458,10 @@ func (p *AnswerNewOIDs) neoMsgEncodedLenN() int {
func (p *AnswerNewOIDs) neoMsgEncodeN(data []byte) { func (p *AnswerNewOIDs) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -1564,10 +1560,10 @@ func (p *AnswerRebaseTransaction) neoMsgEncodedLenN() int { ...@@ -1564,10 +1560,10 @@ func (p *AnswerRebaseTransaction) neoMsgEncodedLenN() int {
func (p *AnswerRebaseTransaction) neoMsgEncodeN(data []byte) { func (p *AnswerRebaseTransaction) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -1769,10 +1765,10 @@ func (p *AbortTransaction) neoMsgEncodedLenN() int { ...@@ -1769,10 +1765,10 @@ func (p *AbortTransaction) neoMsgEncodedLenN() int {
func (p *AbortTransaction) neoMsgEncodeN(data []byte) { func (p *AbortTransaction) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Tid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Tid))
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -1840,10 +1836,10 @@ func (p *StoreTransaction) neoMsgEncodeN(data []byte) { ...@@ -1840,10 +1836,10 @@ func (p *StoreTransaction) neoMsgEncodeN(data []byte) {
data = data[l:] data = data[l:]
} }
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -2090,10 +2086,10 @@ func (p *AnswerTIDs) neoMsgEncodedLenN() int { ...@@ -2090,10 +2086,10 @@ func (p *AnswerTIDs) neoMsgEncodedLenN() int {
func (p *AnswerTIDs) neoMsgEncodeN(data []byte) { func (p *AnswerTIDs) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.TIDList)) l := len(p.TIDList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.TIDList[i] a := &p.TIDList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -2186,10 +2182,10 @@ func (p *AnswerTransactionInformation) neoMsgEncodeN(data []byte) { ...@@ -2186,10 +2182,10 @@ func (p *AnswerTransactionInformation) neoMsgEncodeN(data []byte) {
} }
(data[0:])[0] = bool2byte(p.Packed) (data[0:])[0] = bool2byte(p.Packed)
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[1:], l) binary.BigEndian.PutUint32(data[1:], uint32(l))
data = data[5:] data = data[5:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -2296,10 +2292,10 @@ func (p *AnswerObjectHistory) neoMsgEncodedLenN() int { ...@@ -2296,10 +2292,10 @@ func (p *AnswerObjectHistory) neoMsgEncodedLenN() int {
func (p *AnswerObjectHistory) neoMsgEncodeN(data []byte) { func (p *AnswerObjectHistory) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Oid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Oid))
{ {
l := uint32(len(p.HistoryList)) l := len(p.HistoryList)
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.HistoryList[i] a := &p.HistoryList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a).Serial)) binary.BigEndian.PutUint64(data[0:], uint64((*a).Serial))
binary.BigEndian.PutUint32(data[8:], (*a).Size) binary.BigEndian.PutUint32(data[8:], (*a).Size)
...@@ -2386,23 +2382,22 @@ func (p *AnswerPartitionList) neoMsgEncodeN(data []byte) { ...@@ -2386,23 +2382,22 @@ func (p *AnswerPartitionList) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.PTid)) binary.BigEndian.PutUint64(data[0:], uint64(p.PTid))
binary.BigEndian.PutUint32(data[8:], p.NumReplicas) binary.BigEndian.PutUint32(data[8:], p.NumReplicas)
{ {
l := uint32(len(p.RowList)) l := len(p.RowList)
binary.BigEndian.PutUint32(data[12:], l) binary.BigEndian.PutUint32(data[12:], uint32(l))
data = data[16:] data = data[16:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := len((*a).CellList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID)))
(data[4:])[0] = uint8(int8((*a).State)) (data[4:])[0] = uint8(int8((*a).State))
data = data[5:] data = data[5:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -2489,10 +2484,10 @@ func (p *AnswerNodeList) neoMsgEncodedLenN() int { ...@@ -2489,10 +2484,10 @@ func (p *AnswerNodeList) neoMsgEncodedLenN() int {
func (p *AnswerNodeList) neoMsgEncodeN(data []byte) { func (p *AnswerNodeList) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
(data[0:])[0] = uint8(int8((*a).Type)) (data[0:])[0] = uint8(int8((*a).Type))
{ {
...@@ -2505,7 +2500,6 @@ func (p *AnswerNodeList) neoMsgEncodeN(data []byte) { ...@@ -2505,7 +2500,6 @@ func (p *AnswerNodeList) neoMsgEncodeN(data []byte) {
n := (*a).IdTime.neoEncodeN(data[5:]) n := (*a).IdTime.neoEncodeN(data[5:])
data = data[5+n:] data = data[5+n:]
} }
data = data[0:]
} }
} }
} }
...@@ -2596,10 +2590,10 @@ func (p *AddPendingNodes) neoMsgEncodedLenN() int { ...@@ -2596,10 +2590,10 @@ func (p *AddPendingNodes) neoMsgEncodedLenN() int {
func (p *AddPendingNodes) neoMsgEncodeN(data []byte) { func (p *AddPendingNodes) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -2645,10 +2639,10 @@ func (p *TweakPartitionTable) neoMsgEncodedLenN() int { ...@@ -2645,10 +2639,10 @@ func (p *TweakPartitionTable) neoMsgEncodedLenN() int {
func (p *TweakPartitionTable) neoMsgEncodeN(data []byte) { func (p *TweakPartitionTable) neoMsgEncodeN(data []byte) {
(data[0:])[0] = bool2byte(p.DryRun) (data[0:])[0] = bool2byte(p.DryRun)
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[1:], l) binary.BigEndian.PutUint32(data[1:], uint32(l))
data = data[5:] data = data[5:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -2700,23 +2694,22 @@ func (p *AnswerTweakPartitionTable) neoMsgEncodedLenN() int { ...@@ -2700,23 +2694,22 @@ func (p *AnswerTweakPartitionTable) neoMsgEncodedLenN() int {
func (p *AnswerTweakPartitionTable) neoMsgEncodeN(data []byte) { func (p *AnswerTweakPartitionTable) neoMsgEncodeN(data []byte) {
(data[0:])[0] = bool2byte(p.Changed) (data[0:])[0] = bool2byte(p.Changed)
{ {
l := uint32(len(p.RowList)) l := len(p.RowList)
binary.BigEndian.PutUint32(data[1:], l) binary.BigEndian.PutUint32(data[1:], uint32(l))
data = data[5:] data = data[5:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
{ {
l := uint32(len((*a).CellList)) l := len((*a).CellList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a).UUID)))
(data[4:])[0] = uint8(int8((*a).State)) (data[4:])[0] = uint8(int8((*a).State))
data = data[5:] data = data[5:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -2822,10 +2815,10 @@ func (p *Repair) neoMsgEncodedLenN() int { ...@@ -2822,10 +2815,10 @@ func (p *Repair) neoMsgEncodedLenN() int {
func (p *Repair) neoMsgEncodeN(data []byte) { func (p *Repair) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.NodeList)) l := len(p.NodeList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -2967,10 +2960,10 @@ func (p *ObjectUndoSerial) neoMsgEncodeN(data []byte) { ...@@ -2967,10 +2960,10 @@ func (p *ObjectUndoSerial) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[8:], uint64(p.LTID)) binary.BigEndian.PutUint64(data[8:], uint64(p.LTID))
binary.BigEndian.PutUint64(data[16:], uint64(p.UndoneTID)) binary.BigEndian.PutUint64(data[16:], uint64(p.UndoneTID))
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[24:], l) binary.BigEndian.PutUint32(data[24:], uint32(l))
data = data[28:] data = data[28:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -3018,8 +3011,8 @@ func (p *AnswerObjectUndoSerial) neoMsgEncodedLenN() int { ...@@ -3018,8 +3011,8 @@ func (p *AnswerObjectUndoSerial) neoMsgEncodedLenN() int {
func (p *AnswerObjectUndoSerial) neoMsgEncodeN(data []byte) { func (p *AnswerObjectUndoSerial) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.ObjectTIDDict)) l := len(p.ObjectTIDDict)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
keyv := make([]zodb.Oid, 0, l) keyv := make([]zodb.Oid, 0, l)
for key := range p.ObjectTIDDict { for key := range p.ObjectTIDDict {
...@@ -3055,16 +3048,17 @@ func (p *AnswerObjectUndoSerial) neoMsgDecodeN(data []byte) (int, error) { ...@@ -3055,16 +3048,17 @@ func (p *AnswerObjectUndoSerial) neoMsgDecodeN(data []byte) (int, error) {
}, l) }, l)
m := p.ObjectTIDDict m := p.ObjectTIDDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
key := zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8])) var key zodb.Oid
var v struct { key = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8]))
var mv struct {
CurrentSerial zodb.Tid CurrentSerial zodb.Tid
UndoSerial zodb.Tid UndoSerial zodb.Tid
IsCurrent bool IsCurrent bool
} }
v.CurrentSerial = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8])) mv.CurrentSerial = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8]))
v.UndoSerial = zodb.Tid(binary.BigEndian.Uint64(data[16 : 16+8])) mv.UndoSerial = zodb.Tid(binary.BigEndian.Uint64(data[16 : 16+8]))
v.IsCurrent = byte2bool((data[24 : 24+1])[0]) mv.IsCurrent = byte2bool((data[24 : 24+1])[0])
m[key] = v m[key] = mv
data = data[25:] data = data[25:]
} }
} }
...@@ -3117,10 +3111,10 @@ func (p *AnswerTIDsFrom) neoMsgEncodedLenN() int { ...@@ -3117,10 +3111,10 @@ func (p *AnswerTIDsFrom) neoMsgEncodedLenN() int {
func (p *AnswerTIDsFrom) neoMsgEncodeN(data []byte) { func (p *AnswerTIDsFrom) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.TidList)) l := len(p.TidList)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -3215,8 +3209,8 @@ func (p *CheckReplicas) neoMsgEncodedLenN() int { ...@@ -3215,8 +3209,8 @@ func (p *CheckReplicas) neoMsgEncodedLenN() int {
func (p *CheckReplicas) neoMsgEncodeN(data []byte) { func (p *CheckReplicas) neoMsgEncodeN(data []byte) {
{ {
l := uint32(len(p.PartitionDict)) l := len(p.PartitionDict)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
keyv := make([]uint32, 0, l) keyv := make([]uint32, 0, l)
for key := range p.PartitionDict { for key := range p.PartitionDict {
...@@ -3248,7 +3242,8 @@ func (p *CheckReplicas) neoMsgDecodeN(data []byte) (int, error) { ...@@ -3248,7 +3242,8 @@ func (p *CheckReplicas) neoMsgDecodeN(data []byte) (int, error) {
p.PartitionDict = make(map[uint32]NodeUUID, l) p.PartitionDict = make(map[uint32]NodeUUID, l)
m := p.PartitionDict m := p.PartitionDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
key := binary.BigEndian.Uint32(data[0 : 0+4]) var key uint32
key = binary.BigEndian.Uint32(data[0 : 0+4])
m[key] = NodeUUID(int32(binary.BigEndian.Uint32(data[4 : 4+4]))) m[key] = NodeUUID(int32(binary.BigEndian.Uint32(data[4 : 4+4])))
data = data[8:] data = data[8:]
} }
...@@ -3462,10 +3457,10 @@ func (p *PartitionCorrupted) neoMsgEncodedLenN() int { ...@@ -3462,10 +3457,10 @@ func (p *PartitionCorrupted) neoMsgEncodedLenN() int {
func (p *PartitionCorrupted) neoMsgEncodeN(data []byte) { func (p *PartitionCorrupted) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint32(data[0:], p.Partition) binary.BigEndian.PutUint32(data[0:], p.Partition)
{ {
l := uint32(len(p.CellList)) l := len(p.CellList)
binary.BigEndian.PutUint32(data[4:], l) binary.BigEndian.PutUint32(data[4:], uint32(l))
data = data[8:] data = data[8:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
binary.BigEndian.PutUint32(data[0:], uint32(int32((*a)))) binary.BigEndian.PutUint32(data[0:], uint32(int32((*a))))
data = data[4:] data = data[4:]
...@@ -3663,8 +3658,8 @@ func (p *Replicate) neoMsgEncodeN(data []byte) { ...@@ -3663,8 +3658,8 @@ func (p *Replicate) neoMsgEncodeN(data []byte) {
data = data[l:] data = data[l:]
} }
{ {
l := uint32(len(p.SourceDict)) l := len(p.SourceDict)
binary.BigEndian.PutUint32(data[0:], l) binary.BigEndian.PutUint32(data[0:], uint32(l))
data = data[4:] data = data[4:]
keyv := make([]uint32, 0, l) keyv := make([]uint32, 0, l)
for key := range p.SourceDict { for key := range p.SourceDict {
...@@ -3680,7 +3675,6 @@ func (p *Replicate) neoMsgEncodeN(data []byte) { ...@@ -3680,7 +3675,6 @@ func (p *Replicate) neoMsgEncodeN(data []byte) {
copy(data, p.SourceDict[key]) copy(data, p.SourceDict[key])
data = data[l:] data = data[l:]
} }
data = data[0:]
} }
} }
} }
...@@ -3710,7 +3704,8 @@ func (p *Replicate) neoMsgDecodeN(data []byte) (int, error) { ...@@ -3710,7 +3704,8 @@ func (p *Replicate) neoMsgDecodeN(data []byte) (int, error) {
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
key := binary.BigEndian.Uint32(data[0 : 0+4]) var key uint32
key = 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:]
...@@ -3773,10 +3768,10 @@ func (p *FetchTransactions) neoMsgEncodeN(data []byte) { ...@@ -3773,10 +3768,10 @@ func (p *FetchTransactions) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[8:], uint64(p.MinTid)) binary.BigEndian.PutUint64(data[8:], uint64(p.MinTid))
binary.BigEndian.PutUint64(data[16:], uint64(p.MaxTid)) binary.BigEndian.PutUint64(data[16:], uint64(p.MaxTid))
{ {
l := uint32(len(p.TxnKnownList)) l := len(p.TxnKnownList)
binary.BigEndian.PutUint32(data[24:], l) binary.BigEndian.PutUint32(data[24:], uint32(l))
data = data[28:] data = data[28:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.TxnKnownList[i] a := &p.TxnKnownList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -3827,10 +3822,10 @@ func (p *AnswerFetchTransactions) neoMsgEncodeN(data []byte) { ...@@ -3827,10 +3822,10 @@ func (p *AnswerFetchTransactions) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.PackTid)) binary.BigEndian.PutUint64(data[0:], uint64(p.PackTid))
binary.BigEndian.PutUint64(data[8:], uint64(p.NextTid)) binary.BigEndian.PutUint64(data[8:], uint64(p.NextTid))
{ {
l := uint32(len(p.TxnDeleteList)) l := len(p.TxnDeleteList)
binary.BigEndian.PutUint32(data[16:], l) binary.BigEndian.PutUint32(data[16:], uint32(l))
data = data[20:] data = data[20:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.TxnDeleteList[i] a := &p.TxnDeleteList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
...@@ -3886,8 +3881,8 @@ func (p *FetchObjects) neoMsgEncodeN(data []byte) { ...@@ -3886,8 +3881,8 @@ func (p *FetchObjects) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[16:], uint64(p.MaxTid)) binary.BigEndian.PutUint64(data[16:], uint64(p.MaxTid))
binary.BigEndian.PutUint64(data[24:], uint64(p.MinOid)) binary.BigEndian.PutUint64(data[24:], uint64(p.MinOid))
{ {
l := uint32(len(p.ObjKnownDict)) l := len(p.ObjKnownDict)
binary.BigEndian.PutUint32(data[32:], l) binary.BigEndian.PutUint32(data[32:], uint32(l))
data = data[36:] data = data[36:]
keyv := make([]zodb.Tid, 0, l) keyv := make([]zodb.Tid, 0, l)
for key := range p.ObjKnownDict { for key := range p.ObjKnownDict {
...@@ -3897,16 +3892,15 @@ func (p *FetchObjects) neoMsgEncodeN(data []byte) { ...@@ -3897,16 +3892,15 @@ func (p *FetchObjects) neoMsgEncodeN(data []byte) {
for _, key := range keyv { for _, key := range keyv {
binary.BigEndian.PutUint64(data[0:], uint64(key)) binary.BigEndian.PutUint64(data[0:], uint64(key))
{ {
l := uint32(len(p.ObjKnownDict[key])) l := len(p.ObjKnownDict[key])
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.ObjKnownDict[key][i] a := &p.ObjKnownDict[key][i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -3930,8 +3924,9 @@ func (p *FetchObjects) neoMsgDecodeN(data []byte) (int, error) { ...@@ -3930,8 +3924,9 @@ func (p *FetchObjects) neoMsgDecodeN(data []byte) (int, error) {
if len(data) < 12 { if len(data) < 12 {
goto overflow goto overflow
} }
key := zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8])) var key zodb.Tid
var v []zodb.Oid key = zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8]))
var mv []zodb.Oid
{ {
l := binary.BigEndian.Uint32(data[8 : 8+4]) l := binary.BigEndian.Uint32(data[8 : 8+4])
data = data[12:] data = data[12:]
...@@ -3939,14 +3934,14 @@ func (p *FetchObjects) neoMsgDecodeN(data []byte) (int, error) { ...@@ -3939,14 +3934,14 @@ func (p *FetchObjects) neoMsgDecodeN(data []byte) (int, error) {
goto overflow goto overflow
} }
nread += uint64(l) * 8 nread += uint64(l) * 8
v = make([]zodb.Oid, l) mv = make([]zodb.Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &v[i] a := &mv[i]
(*a) = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8])) (*a) = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8]))
data = data[8:] data = data[8:]
} }
} }
m[key] = v m[key] = mv
} }
nread += uint64(l) * 12 nread += uint64(l) * 12
} }
...@@ -3975,8 +3970,8 @@ func (p *AnswerFetchObjects) neoMsgEncodeN(data []byte) { ...@@ -3975,8 +3970,8 @@ func (p *AnswerFetchObjects) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint64(data[8:], uint64(p.NextTid)) binary.BigEndian.PutUint64(data[8:], uint64(p.NextTid))
binary.BigEndian.PutUint64(data[16:], uint64(p.NextOid)) binary.BigEndian.PutUint64(data[16:], uint64(p.NextOid))
{ {
l := uint32(len(p.ObjDeleteDict)) l := len(p.ObjDeleteDict)
binary.BigEndian.PutUint32(data[24:], l) binary.BigEndian.PutUint32(data[24:], uint32(l))
data = data[28:] data = data[28:]
keyv := make([]zodb.Tid, 0, l) keyv := make([]zodb.Tid, 0, l)
for key := range p.ObjDeleteDict { for key := range p.ObjDeleteDict {
...@@ -3986,16 +3981,15 @@ func (p *AnswerFetchObjects) neoMsgEncodeN(data []byte) { ...@@ -3986,16 +3981,15 @@ func (p *AnswerFetchObjects) neoMsgEncodeN(data []byte) {
for _, key := range keyv { for _, key := range keyv {
binary.BigEndian.PutUint64(data[0:], uint64(key)) binary.BigEndian.PutUint64(data[0:], uint64(key))
{ {
l := uint32(len(p.ObjDeleteDict[key])) l := len(p.ObjDeleteDict[key])
binary.BigEndian.PutUint32(data[8:], l) binary.BigEndian.PutUint32(data[8:], uint32(l))
data = data[12:] data = data[12:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.ObjDeleteDict[key][i] a := &p.ObjDeleteDict[key][i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
} }
} }
data = data[0:]
} }
} }
} }
...@@ -4017,8 +4011,9 @@ func (p *AnswerFetchObjects) neoMsgDecodeN(data []byte) (int, error) { ...@@ -4017,8 +4011,9 @@ func (p *AnswerFetchObjects) neoMsgDecodeN(data []byte) (int, error) {
if len(data) < 12 { if len(data) < 12 {
goto overflow goto overflow
} }
key := zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8])) var key zodb.Tid
var v []zodb.Oid key = zodb.Tid(binary.BigEndian.Uint64(data[0 : 0+8]))
var mv []zodb.Oid
{ {
l := binary.BigEndian.Uint32(data[8 : 8+4]) l := binary.BigEndian.Uint32(data[8 : 8+4])
data = data[12:] data = data[12:]
...@@ -4026,14 +4021,14 @@ func (p *AnswerFetchObjects) neoMsgDecodeN(data []byte) (int, error) { ...@@ -4026,14 +4021,14 @@ func (p *AnswerFetchObjects) neoMsgDecodeN(data []byte) (int, error) {
goto overflow goto overflow
} }
nread += uint64(l) * 8 nread += uint64(l) * 8
v = make([]zodb.Oid, l) mv = make([]zodb.Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &v[i] a := &mv[i]
(*a) = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8])) (*a) = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8]))
data = data[8:] data = data[8:]
} }
} }
m[key] = v m[key] = mv
} }
nread += uint64(l) * 12 nread += uint64(l) * 12
} }
...@@ -4079,10 +4074,10 @@ func (p *AddTransaction) neoMsgEncodeN(data []byte) { ...@@ -4079,10 +4074,10 @@ func (p *AddTransaction) neoMsgEncodeN(data []byte) {
(data[0:])[0] = bool2byte(p.Packed) (data[0:])[0] = bool2byte(p.Packed)
binary.BigEndian.PutUint64(data[1:], uint64(p.TTid)) binary.BigEndian.PutUint64(data[1:], uint64(p.TTid))
{ {
l := uint32(len(p.OidList)) l := len(p.OidList)
binary.BigEndian.PutUint32(data[9:], l) binary.BigEndian.PutUint32(data[9:], uint32(l))
data = data[13:] data = data[13:]
for i := 0; uint32(i) < l; i++ { for i := 0; i < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
binary.BigEndian.PutUint64(data[0:], uint64((*a))) binary.BigEndian.PutUint64(data[0:], uint64((*a)))
data = data[8:] data = data[8:]
......
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