Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
d053cc5f
Commit
d053cc5f
authored
Jan 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
dd43cd5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
9 deletions
+83
-9
t/neo/marshal.go
t/neo/marshal.go
+56
-6
t/neo/protogen.go
t/neo/protogen.go
+27
-3
No files found.
t/neo/marshal.go
View file @
d053cc5f
...
@@ -1014,12 +1014,28 @@ overflow:
...
@@ -1014,12 +1014,28 @@ overflow:
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
var
size
uint32
var
size
uint32
// TODO map
{
size
+=
0
for
key
,
v
:=
range
p
.
TidDict
{
_
=
key
_
=
v
size
+=
16
}
}
return
int
(
size
)
+
0
return
int
(
size
)
+
0
}
}
func
(
p
*
AnswerLockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
// TODO map
{
l
:=
uint32
(
len
(
p
.
TidDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
for
key
,
v
:=
range
p
.
TidDict
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
key
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
v
))
data
=
data
[
16
:
]
}
}
}
}
func
(
p
*
AnswerLockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerLockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
...
@@ -2795,12 +2811,30 @@ overflow:
...
@@ -2795,12 +2811,30 @@ overflow:
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
var
size
uint32
var
size
uint32
// TODO map
{
size
+=
0
for
key
,
v
:=
range
p
.
ObjectTIDDict
{
_
=
key
_
=
v
size
+=
25
}
}
return
int
(
size
)
+
0
return
int
(
size
)
+
0
}
}
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
// TODO map
{
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
for
key
,
v
:=
range
p
.
ObjectTIDDict
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
key
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
v
.
CurrentSerial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
v
.
UndoSerial
))
(
data
[
24
:
])[
0
]
=
bool2byte
(
v
.
IsCurrent
)
data
=
data
[
25
:
]
}
}
}
}
func
(
p
*
AnswerObjectUndoSerial
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerObjectUndoSerial
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
...
@@ -2979,12 +3013,28 @@ overflow:
...
@@ -2979,12 +3013,28 @@ overflow:
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
var
size
uint32
var
size
uint32
// TODO map
{
size
+=
0
for
key
,
v
:=
range
p
.
PartitionDict
{
_
=
key
_
=
v
size
+=
8
}
}
return
int
(
size
)
+
16
return
int
(
size
)
+
16
}
}
func
(
p
*
CheckReplicas
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
CheckReplicas
)
NEOEncode
(
data
[]
byte
)
{
// TODO map
{
l
:=
uint32
(
len
(
p
.
PartitionDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
for
key
,
v
:=
range
p
.
PartitionDict
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
key
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
v
)))
data
=
data
[
8
:
]
}
}
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
}
}
...
...
t/neo/protogen.go
View file @
d053cc5f
...
@@ -357,13 +357,37 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
...
@@ -357,13 +357,37 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
d
.
n
=
0
d
.
n
=
0
}
}
// generate code to encode/decode map
// len u32
// [len](key, value)
func
(
e
*
encoder
)
genMap
(
path
string
,
typ
*
types
.
Map
,
obj
types
.
Object
)
{
func
(
e
*
encoder
)
genMap
(
path
string
,
typ
*
types
.
Map
,
obj
types
.
Object
)
{
e
.
emit
(
"// TODO map"
)
e
.
emit
(
"{"
)
if
!
e
.
SizeOnly
{
e
.
emit
(
"l := uint32(len(%s))"
,
path
)
e
.
genBasic
(
"l"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
}
else
{
e
.
emit
(
"size += %v"
,
e
.
n
)
}
e
.
n
=
0
// TODO if size(item)==const - size update in one go
e
.
emit
(
"for key, v := range %s {"
,
path
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
"v"
,
typ
.
Elem
(),
obj
,
e
)
if
!
e
.
SizeOnly
{
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
}
else
{
e
.
emit
(
"_ = key"
)
// FIXME remove
e
.
emit
(
"_ = v"
)
// FIXME remove
e
.
emit
(
"size += %v"
,
e
.
n
)
}
e
.
emit
(
"}"
)
// XXX vvv ?
e
.
emit
(
"}"
)
e
.
n
=
0
}
}
func
(
d
*
decoder
)
genMap
(
assignto
string
,
typ
*
types
.
Map
,
obj
types
.
Object
)
{
func
(
d
*
decoder
)
genMap
(
assignto
string
,
typ
*
types
.
Map
,
obj
types
.
Object
)
{
// len u32
// [len](key, value)
d
.
emit
(
"{"
)
d
.
emit
(
"{"
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment