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
ef5e0a40
Commit
ef5e0a40
authored
Dec 01, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3ec038b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
t/neo/connection.go
t/neo/connection.go
+10
-11
t/neo/storage.go
t/neo/storage.go
+0
-2
No files found.
t/neo/connection.go
View file @
ef5e0a40
...
@@ -60,11 +60,17 @@ type Conn struct {
...
@@ -60,11 +60,17 @@ type Conn struct {
rxq
chan
Pkt
// XXX chan &Pkt ?
rxq
chan
Pkt
// XXX chan &Pkt ?
}
}
// Buffer with packet data
type
PktBuf
struct
{
PktHead
Body
[]
byte
}
// Send packet via connection
// Send packet via connection
// XXX vs cancel
// XXX vs cancel
func
(
Conn
*
c
)
Send
(
pkt
Pkt
)
error
{
func
(
Conn
*
c
)
Send
(
pkt
Pkt
)
error
{
pkt
.
MsgId
=
...
// TODO next msgid, or using same msgid as received
pkt
.
MsgId
=
0
// TODO next msgid, or using same msgid as received
_
,
err
:=
c
.
nodeLink
.
peerLink
.
Write
(
pkt
.
WholeBuffer
())
// TODO -> sendPkt(pkt)
_
,
err
:=
c
.
nodeLink
.
peerLink
.
Write
(
pkt
.
WholeBuffer
())
// TODO -> sendPkt(pkt)
if
err
!=
nil
{
if
err
!=
nil
{
// TODO data could be written partially and thus the message stream is now broken
// TODO data could be written partially and thus the message stream is now broken
...
@@ -76,7 +82,7 @@ func (Conn *c) Send(pkt Pkt) error {
...
@@ -76,7 +82,7 @@ func (Conn *c) Send(pkt Pkt) error {
// Receive packet from connection
// Receive packet from connection
// XXX vs cancel
// XXX vs cancel
func
(
Conn
*
c
)
Recv
()
(
PktBuf
,
error
)
{
func
(
Conn
*
c
)
Recv
()
(
PktBuf
,
error
)
{
pkt
,
ok
<-
rxq
pkt
,
ok
:=
<-
rxq
if
!
ok
{
if
!
ok
{
return
PktBuf
{},
io
.
EOF
// XXX check erroring & other errors?
return
PktBuf
{},
io
.
EOF
// XXX check erroring & other errors?
}
}
...
@@ -108,7 +114,7 @@ func NewNodeLink(c net.Conn) *NodeLink {
...
@@ -108,7 +114,7 @@ func NewNodeLink(c net.Conn) *NodeLink {
func
(
nl
*
NodeLink
)
NewConn
()
*
Conn
{
func
(
nl
*
NodeLink
)
NewConn
()
*
Conn
{
c
:=
&
Conn
{
nodeLink
:
nl
,
rxq
:
make
(
chan
Pkt
)}
c
:=
&
Conn
{
nodeLink
:
nl
,
rxq
:
make
(
chan
Pkt
)}
// XXX locking
// XXX locking
nl
.
connTab
[
...
]
=
c
//
XXX also check not a duplicate
nl
.
connTab
[
0
]
=
c
// FIXME 0 -> msgid;
XXX also check not a duplicate
return
c
return
c
}
}
...
@@ -135,7 +141,7 @@ func (nl *NodeLink) serveRecv() error {
...
@@ -135,7 +141,7 @@ func (nl *NodeLink) serveRecv() error {
continue
continue
}
}
conn
=
nl
.
NewConn
(
...
)
// XXX should also update connTab
conn
=
nl
.
NewConn
(
)
// TODO avoid spawning goroutine for each new Ask request -
// TODO avoid spawning goroutine for each new Ask request -
// - by keeping pool of read inactive goroutine / conn pool
// - by keeping pool of read inactive goroutine / conn pool
go
nl
.
handleNewConn
(
conn
)
go
nl
.
handleNewConn
(
conn
)
...
@@ -153,13 +159,6 @@ func (nl *NodeLink) HandleNewConn(h func(*Conn)) {
...
@@ -153,13 +159,6 @@ func (nl *NodeLink) HandleNewConn(h func(*Conn)) {
}
}
// information about (received ?) packet
// XXX place?
type
PktBuf
struct
{
PktHead
Body
[]
byte
}
// receive 1 packet from peer
// receive 1 packet from peer
func
(
c
*
NodeLink
)
recvPkt
()
(
pkt
Pkt
,
err
error
)
{
func
(
c
*
NodeLink
)
recvPkt
()
(
pkt
Pkt
,
err
error
)
{
// TODO organize rx buffers management (freelist etc)
// TODO organize rx buffers management (freelist etc)
...
...
t/neo/storage.go
View file @
ef5e0a40
...
@@ -4,10 +4,8 @@ package neo
...
@@ -4,10 +4,8 @@ package neo
import
(
import
(
"context"
"context"
"encoding/binary"
"net"
"net"
"fmt"
"fmt"
"io"
//"../neo/proto"
//"../neo/proto"
)
)
...
...
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