Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
02ec3a41
Commit
02ec3a41
authored
Dec 27, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
395e91bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
t/neo/marshal.go
t/neo/marshal.go
+15
-0
t/neo/proto.go
t/neo/proto.go
+1
-1
t/neo/protogen.go
t/neo/protogen.go
+24
-3
No files found.
t/neo/marshal.go
View file @
02ec3a41
...
...
@@ -304,3 +304,18 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
func
(
p
*
LockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
/* + TODO variable part */
,
nil
}
func
(
p
*
AnswerLockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
{
l
:=
BigEndian
.
Uint32
(
data
[
0
:
])
data
=
data
[
4
:
]
p
.
TidDict
=
make
(
map
[
neo
.
Tid
]
neo
.
Tid
,
l
)
m
:=
p
.
TidDict
for
i
:=
0
;
i
<
l
;
i
++
{
key
=
BigEndian
.
Uint64
(
data
[
0
:
])
m
[
key
]
=
BigEndian
.
Uint64
(
data
[
8
:
])
data
=
data
[
16
:
]
}
}
return
0
/* + TODO variable part */
,
nil
}
t/neo/proto.go
View file @
02ec3a41
...
...
@@ -327,12 +327,12 @@ type AnswerUnfinishedTransactions struct {
// Answer locked transactions S -> PM.
type
LockedTransactions
struct
{
}
/*
type
AnswerLockedTransactions
struct
{
TidDict
map
[
Tid
]
Tid
// ttid -> tid
}
/*
// Return final tid if ttid has been committed. * -> S. C -> PM.
type FinalTID struct {
TTID Tid
...
...
t/neo/protogen.go
View file @
02ec3a41
...
...
@@ -209,13 +209,13 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
// [len]item
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typ
)
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d
.
emit
(
"for i := 0; i < l; i++ {"
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
d
.
n
=
0
d
.
emitobjtype
(
"a"
,
obj
,
typ
.
Elem
())
// XXX also obj.Elem() ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"}"
)
...
...
@@ -224,6 +224,27 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
d
.
n
=
0
}
func
(
d
*
decoder
)
emitmap
(
assignto
string
,
obj
types
.
Object
,
typ
*
types
.
Map
)
{
// len u32
// [len](key, value)
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typ
)
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d
.
emit
(
"m := %v"
,
assignto
)
d
.
emit
(
"for i := 0; i < l; i++ {"
)
d
.
emitobjtype
(
"key"
,
obj
,
typ
.
Key
())
// TODO -> :=
d
.
emitobjtype
(
"m[key]"
,
obj
,
typ
.
Elem
())
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt map of map ?
d
.
emit
(
"}"
)
//d.emit("%v = string(data[:l])", assignto)
d
.
emit
(
"}"
)
d
.
n
=
0
}
// top-level driver for emitting decode code for obj/type
func
(
d
*
decoder
)
emitobjtype
(
assignto
string
,
obj
types
.
Object
,
typ
types
.
Type
)
{
switch
u
:=
typ
.
Underlying
()
.
(
type
)
{
...
...
@@ -238,8 +259,8 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
case
*
types
.
Slice
:
d
.
emitslice
(
assignto
,
obj
,
u
)
//
case *types.Map:
// // TODO
case
*
types
.
Map
:
d
.
emitmap
(
assignto
,
obj
,
u
)
case
*
types
.
Struct
:
...
...
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