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
261f9303
Commit
261f9303
authored
Dec 23, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
dde695db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
9 deletions
+47
-9
t/neo/proto.go
t/neo/proto.go
+42
-2
t/neo/protogen.go
t/neo/protogen.go
+5
-7
No files found.
t/neo/proto.go
View file @
261f9303
...
...
@@ -83,7 +83,27 @@ type UUID int32
type
Address
struct
{
Host
string
Port
uint16
// TODO if Host == 0 -> Port not added to wire (see py.PAddress)
Port
uint16
}
// NOTE if Host == "" -> Port not added to wire (see py.PAddress):
func
(
a
*
Address
)
NEOEncode
(
b
[]
byte
)
int
{
n
:=
a
.
Host
.
NEOEncode
(
b
[
0
:
])
if
a
.
Host
!=
""
{
BigEndian
.
PutUint16
(
b
[
n
:
],
a
.
Port
)
n
+=
2
}
return
n
}
func
(
a
*
Address
)
NEODecode
(
b
[]
byte
)
int
{
n
:=
a
.
Host
.
NEODecode
(
b
)
if
a
.
Host
!=
""
{
n
+=
a
.
Port
.
NEODecode
(
b
[
n
:
])
}
else
{
a
.
Port
=
0
}
return
n
}
// A SHA1 hash
...
...
@@ -93,9 +113,29 @@ type Checksum [20]byte
// Zero value means "invalid id" (<-> None in py.PPTID)
type
PTid
uint64
// XXX move to common place ?
// TODO None encodes as '\xff' * 8 (-> use NaN for None)
type
Float64
float64
// NOTE py.None encodes as '\xff' * 8 (-> use NaN for None)
// NOTE '\xff' * 8 represents FP NaN but many other NaN bits representation exist
func
(
f
Float64
)
NEOEncode
(
b
[]
byte
)
int
{
var
fu
uint64
if
!
math
.
IsNaN
(
f
)
{
fu
=
math
.
Float64Bits
(
f
)
}
else
{
// convert all NaNs to canonical \xff * 8
fu
=
1
<<
64
-
1
}
BigEndian
.
PutUint64
(
b
,
fu
)
return
8
}
func
(
f
*
Float64
)
NEODecode
(
b
[]
byte
)
int
{
fu
:=
BigEndian
.
Uint64
(
b
)
f
*=
math
.
Float64FromBits
(
fu
)
return
8
}
// NOTE original NodeList = []NodeInfo
type
NodeInfo
struct
{
NodeType
...
...
t/neo/protogen.go
View file @
261f9303
...
...
@@ -37,8 +37,8 @@ func main() {
ncode
:=
0
//
ast.Print(fset, f)
//
return
//ast.Print(fset, f)
//return
for
_
,
decl
:=
range
f
.
Decls
{
// we look for types (which can be only under GenDecl)
...
...
@@ -57,11 +57,9 @@ func main() {
continue
}
/*
fmt.Printf("%s:\n", tname)
fmt.Println(tstruct)
ast.Print(fset, tstruct)
*/
//fmt.Printf("\n%s:\n", tname)
//fmt.Println(tstruct)
//ast.Print(fset, tstruct)
if
ncode
!=
0
{
fmt
.
Println
()
...
...
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