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
a41e0b4d
Commit
a41e0b4d
authored
Jul 20, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7025320e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
52 deletions
+57
-52
go/neo/server/storage.go
go/neo/server/storage.go
+57
-52
No files found.
go/neo/server/storage.go
View file @
a41e0b4d
...
...
@@ -372,7 +372,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
var
serveConn
func
(
context
.
Context
,
*
neo
.
Conn
)
switch
nodeInfo
.
NodeType
{
case
neo
.
CLIENT
:
serveConn
=
stor
.
S
erveClient
serveConn
=
stor
.
s
erveClient
default
:
// XXX vvv should be reply to peer
...
...
@@ -388,7 +388,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
break
}
// XXX wrap conn close to happen here, not in
S
erveClient ?
// XXX wrap conn close to happen here, not in
s
erveClient ?
go
serveConn
(
ctx
,
conn
)
}
...
...
@@ -396,9 +396,9 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
}
//
S
erveClient serves incoming connection on which peer identified itself as client
//
s
erveClient serves incoming connection on which peer identified itself as client
// XXX +error return?
func
(
stor
*
Storage
)
S
erveClient
(
ctx
context
.
Context
,
conn
*
neo
.
Conn
)
{
func
(
stor
*
Storage
)
s
erveClient
(
ctx
context
.
Context
,
conn
*
neo
.
Conn
)
{
fmt
.
Printf
(
"stor: %s: serving new client conn
\n
"
,
conn
)
// rederive ctx to be also cancelled if M tells us StopOperation
...
...
@@ -418,62 +418,67 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *neo.Conn) {
}()
for
{
req
,
err
:=
conn
.
Recv
()
if
err
!=
nil
{
return
// XXX log / err / send error before closing
}
serveClient1
(
conn
)
// XXX err check
}
}
switch
req
:=
req
.
(
type
)
{
case
*
neo
.
GetObject
:
xid
:=
zodb
.
Xid
{
Oid
:
req
.
Oid
}
if
req
.
Serial
!=
neo
.
INVALID_TID
{
xid
.
Tid
=
req
.
Serial
xid
.
TidBefore
=
false
}
else
{
xid
.
Tid
=
req
.
Tid
xid
.
TidBefore
=
true
}
// serveClient1 serves 1 request from a client
func
(
stor
*
Storage
)
serveClient1
(
conn
*
neo
.
Conn
)
error
{
req
,
err
:=
conn
.
Recv
()
if
err
!=
nil
{
return
// XXX log / err / send error before closing
}
var
reply
neo
.
Msg
data
,
tid
,
err
:=
stor
.
zstor
.
Load
(
xid
)
if
err
!=
nil
{
// TODO translate err to NEO protocol error codes
reply
=
neo
.
ErrEncode
(
err
)
}
else
{
reply
=
&
neo
.
AnswerGetObject
{
Oid
:
xid
.
Oid
,
Serial
:
tid
,
Compression
:
false
,
Data
:
data
,
// XXX .CheckSum
// XXX .NextSerial
// XXX .DataSerial
}
}
switch
req
:=
req
.
(
type
)
{
case
*
neo
.
GetObject
:
xid
:=
zodb
.
Xid
{
Oid
:
req
.
Oid
}
if
req
.
Serial
!=
neo
.
INVALID_TID
{
xid
.
Tid
=
req
.
Serial
xid
.
TidBefore
=
false
}
else
{
xid
.
Tid
=
req
.
Tid
xid
.
TidBefore
=
true
}
conn
.
Send
(
reply
)
// XXX err
var
reply
neo
.
Msg
data
,
tid
,
err
:=
stor
.
zstor
.
Load
(
xid
)
if
err
!=
nil
{
// TODO translate err to NEO protocol error codes
reply
=
neo
.
ErrEncode
(
err
)
}
else
{
reply
=
&
neo
.
AnswerGetObject
{
Oid
:
xid
.
Oid
,
Serial
:
tid
,
Compression
:
false
,
Data
:
data
,
// XXX .CheckSum
// XXX .NextSerial
// XXX .DataSerial
}
}
case
*
neo
.
LastTransaction
:
var
reply
neo
.
Msg
conn
.
Send
(
reply
)
// XXX err
lastTid
,
err
:=
stor
.
zstor
.
LastTid
()
if
err
!=
nil
{
reply
=
neo
.
ErrEncode
(
err
)
}
else
{
reply
=
&
neo
.
AnswerLastTransaction
{
lastTid
}
}
case
*
neo
.
LastTransaction
:
var
reply
neo
.
Msg
conn
.
Send
(
reply
)
// XXX err
lastTid
,
err
:=
stor
.
zstor
.
LastTid
()
if
err
!=
nil
{
reply
=
neo
.
ErrEncode
(
err
)
}
else
{
reply
=
&
neo
.
AnswerLastTransaction
{
lastTid
}
}
//case *ObjectHistory:
//case *StoreObject:
conn
.
Send
(
reply
)
// XXX err
default
:
panic
(
"unexpected packet"
)
// XXX
}
//case *ObjectHistory:
//case *StoreObject:
//req.Put(...)
default
:
panic
(
"unexpected packet"
)
// XXX
}
//req.Put(...)
}
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