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
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
Stefane Fermigier
neo
Commits
85666824
Commit
85666824
authored
Apr 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
028efc96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
2 deletions
+33
-2
go/neo/connection.go
go/neo/connection.go
+6
-0
go/neo/pkt.go
go/neo/pkt.go
+25
-0
go/neo/proto-marshal.go
go/neo/proto-marshal.go
+1
-1
go/neo/protogen.go
go/neo/protogen.go
+1
-1
No files found.
go/neo/connection.go
View file @
85666824
...
...
@@ -20,6 +20,8 @@ import (
"io"
"net"
"sync"
"fmt"
)
// NodeLink is a node-node link in NEO
...
...
@@ -150,6 +152,10 @@ func (nl *NodeLink) Close() error {
// send raw packet to peer
func
(
nl
*
NodeLink
)
sendPkt
(
pkt
*
PktBuf
)
error
{
if
true
{
// XXX -> log
fmt
.
Printf
(
"%v > %v: %v
\n
"
,
nl
.
peerLink
.
LocalAddr
(),
nl
.
peerLink
.
RemoteAddr
(),
pkt
)
}
_
,
err
:=
nl
.
peerLink
.
Write
(
pkt
.
Data
)
// FIXME write Data in full
if
err
!=
nil
{
// XXX do we need to retry if err is temporary?
...
...
go/neo/pkt.go
View file @
85666824
...
...
@@ -15,6 +15,7 @@
package
neo
import
(
"fmt"
"unsafe"
)
...
...
@@ -42,3 +43,27 @@ func (pkt *PktBuf) Header() *PktHead {
func
(
pkt
*
PktBuf
)
Payload
()
[]
byte
{
return
pkt
.
Data
[
PktHeadLen
:
]
}
// packet dumping
func
(
pkt
*
PktBuf
)
String
()
string
{
if
len
(
pkt
.
Data
)
<
PktHeadLen
{
return
fmt
.
Sprintf
(
"(! < PktHeadLen) % x"
,
pkt
.
Data
)
}
h
:=
pkt
.
Header
()
s
:=
fmt
.
Sprintf
(
".%d"
,
ntoh32
(
h
.
ConnId
))
msgCode
:=
ntoh16
(
h
.
MsgCode
)
msgType
:=
pktTypeRegistry
[
msgCode
]
if
msgType
==
nil
{
s
+=
fmt
.
Sprintf
(
" ? (%d)"
,
msgCode
)
}
else
{
s
+=
fmt
.
Sprintf
(
" %s"
,
msgType
)
}
s
+=
fmt
.
Sprintf
(
" #%d | "
,
ntoh32
(
h
.
Len
))
s
+=
fmt
.
Sprintf
(
"% x
\n
"
,
pkt
.
Payload
())
// XXX better decode
return
s
}
go/neo/proto-marshal.go
View file @
85666824
...
...
@@ -3345,7 +3345,7 @@ func (p *NotifyReady) NEODecode(data []byte) (int, error) {
}
// registry of packet types
var
pktTypeRegistry
=
map
[
int
]
reflect
.
Type
{
var
pktTypeRegistry
=
map
[
uint16
]
reflect
.
Type
{
0
:
reflect
.
TypeOf
(
Address
{}),
1
:
reflect
.
TypeOf
(
NodeInfo
{}),
2
:
reflect
.
TypeOf
(
CellInfo
{}),
...
...
go/neo/protogen.go
View file @
85666824
...
...
@@ -204,7 +204,7 @@ import (
// now generate packet types registry
buf
.
emit
(
"
\n
// registry of packet types"
)
buf
.
emit
(
"var pktTypeRegistry = map[
int
]reflect.Type {"
)
// XXX key -> PktCode ?
buf
.
emit
(
"var pktTypeRegistry = map[
uint16
]reflect.Type {"
)
// XXX key -> PktCode ?
// ordered by pktCode
pktCodeV
:=
[]
int
{}
...
...
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