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
3398c0af
Commit
3398c0af
authored
Aug 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
78681a6e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
go/neo/client/client.go
go/neo/client/client.go
+41
-3
No files found.
go/neo/client/client.go
View file @
3398c0af
...
@@ -21,7 +21,11 @@
...
@@ -21,7 +21,11 @@
package
client
package
client
import
(
import
(
"bytes"
"compress/zlib"
"context"
"context"
"crypto/sha1"
"io"
"math/rand"
"math/rand"
"net/url"
"net/url"
...
@@ -99,6 +103,29 @@ func (c *Client) LastOid() (zodb.Oid, error) {
...
@@ -99,6 +103,29 @@ func (c *Client) LastOid() (zodb.Oid, error) {
panic
(
"TODO"
)
panic
(
"TODO"
)
}
}
// decompress decompresses data according to zlib encoding.
//
// out buffer, if there is enough capacity, is used for decompression destionation.
// if out has not not enough capacity a new buffer is allocated and used.
//
// return: destination buffer with full decompressed data.
func
decompress
(
in
[]
byte
,
out
[]
byte
)
([]
byte
,
error
)
{
bin
:=
bytes
.
NewReader
(
in
)
zr
,
err
:=
zlib
.
NewReader
(
bin
)
if
err
!=
nil
{
return
nil
,
err
}
defer
zr
.
Close
()
bout
:=
bytes
.
NewBuffer
(
out
)
_
,
err
=
io
.
Copy
(
bout
,
bin
)
if
err
!=
nil
{
return
nil
,
err
}
return
bout
.
Bytes
(),
nil
}
func
(
c
*
Client
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
tid
zodb
.
Tid
,
err
error
)
{
func
(
c
*
Client
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
tid
zodb
.
Tid
,
err
error
)
{
// XXX check pt is operational first? -> no if there is no data - we'll
// XXX check pt is operational first? -> no if there is no data - we'll
// just won't find ready cell
// just won't find ready cell
...
@@ -115,6 +142,7 @@ func (c *Client) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
...
@@ -115,6 +142,7 @@ func (c *Client) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
0
)
// XXX
panic
(
0
)
// XXX
}
}
defer
lclose
(
Sconn
)
req
:=
neo
.
GetObject
{
Oid
:
xid
.
Oid
}
req
:=
neo
.
GetObject
{
Oid
:
xid
.
Oid
}
if
xid
.
TidBefore
{
if
xid
.
TidBefore
{
...
@@ -131,12 +159,22 @@ func (c *Client) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
...
@@ -131,12 +159,22 @@ func (c *Client) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
return
nil
,
0
,
err
// XXX err context
return
nil
,
0
,
err
// XXX err context
}
}
// TODO reply.Checksum - check sha1
checksum
:=
sha1
.
Sum
(
data
)
// TODO reply.Compression - decompress
if
checksum
!=
reply
.
Checksum
{
// XXX data corrupt
}
data
:=
resp
.
Data
if
reply
.
Compression
{
data
,
err
=
decompress
(
resp
.
Data
,
make
([]
byte
,
0
,
len
(
resp
.
Data
)))
if
err
!=
nil
{
// XXX data corrupt
}
}
// reply.NextSerial
// reply.NextSerial
// reply.DataSerial
// reply.DataSerial
return
resp
.
D
ata
,
resp
.
Serial
,
nil
return
d
ata
,
resp
.
Serial
,
nil
}
}
func
(
c
*
Client
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
func
(
c
*
Client
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
...
...
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