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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
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
Show 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) {
...
@@ -304,3 +304,18 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
func
(
p
*
LockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
LockedTransactions
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
/* + TODO variable part */
,
nil
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 {
...
@@ -327,12 +327,12 @@ type AnswerUnfinishedTransactions struct {
// Answer locked transactions S -> PM.
// Answer locked transactions S -> PM.
type
LockedTransactions
struct
{
type
LockedTransactions
struct
{
}
}
/*
type
AnswerLockedTransactions
struct
{
type
AnswerLockedTransactions
struct
{
TidDict
map
[
Tid
]
Tid
// ttid -> tid
TidDict
map
[
Tid
]
Tid
// ttid -> tid
}
}
/*
// Return final tid if ttid has been committed. * -> S. C -> PM.
// Return final tid if ttid has been committed. * -> S. C -> PM.
type FinalTID struct {
type FinalTID struct {
TTID Tid
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)
...
@@ -209,13 +209,13 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
// [len]item
// [len]item
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typ
)
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typ
)
// TODO size check
// TODO size check
// TODO if size(item)==const - check l in one go
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d
.
emit
(
"for i := 0; i < l; i++ {"
)
d
.
emit
(
"for i := 0; i < l; i++ {"
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
d
.
n
=
0
d
.
emitobjtype
(
"a"
,
obj
,
typ
.
Elem
())
// XXX also obj.Elem() ?
d
.
emitobjtype
(
"a"
,
obj
,
typ
.
Elem
())
// XXX also obj.Elem() ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"}"
)
d
.
emit
(
"}"
)
...
@@ -224,6 +224,27 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
...
@@ -224,6 +224,27 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
d
.
n
=
0
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
// top-level driver for emitting decode code for obj/type
func
(
d
*
decoder
)
emitobjtype
(
assignto
string
,
obj
types
.
Object
,
typ
types
.
Type
)
{
func
(
d
*
decoder
)
emitobjtype
(
assignto
string
,
obj
types
.
Object
,
typ
types
.
Type
)
{
switch
u
:=
typ
.
Underlying
()
.
(
type
)
{
switch
u
:=
typ
.
Underlying
()
.
(
type
)
{
...
@@ -238,8 +259,8 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
...
@@ -238,8 +259,8 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
case
*
types
.
Slice
:
case
*
types
.
Slice
:
d
.
emitslice
(
assignto
,
obj
,
u
)
d
.
emitslice
(
assignto
,
obj
,
u
)
//
case *types.Map:
case
*
types
.
Map
:
// // TODO
d
.
emitmap
(
assignto
,
obj
,
u
)
case
*
types
.
Struct
:
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