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
605e2e88
Commit
605e2e88
authored
Mar 01, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
eb3028a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+11
-16
No files found.
t/neo/storage/fs1/filestorage.go
View file @
605e2e88
...
...
@@ -18,7 +18,6 @@ package fs1
import
(
"encoding/binary"
//"errors"
"fmt"
"io"
"os"
...
...
@@ -48,7 +47,7 @@ type TxnHeader struct {
// (0 if there is no previous txn record)
Len
int64
// whole transaction record length
// transaction metadata tself
// transaction metadata
i
tself
zodb
.
TxnInfo
// underlying memory for header loading and for user/desc/extension strings
...
...
@@ -101,15 +100,17 @@ func (txnh *TxnHeader) err(subj string, err error) *ErrTxnRecord {
return
&
ErrTxnRecord
{
txnh
.
Pos
,
subj
,
err
}
}
// errf is syntatic shortcut for err and fmt.Errorf
// errf is synta
c
tic shortcut for err and fmt.Errorf
func
(
txnh
*
TxnHeader
)
errf
(
subj
,
format
string
,
a
...
interface
{})
*
ErrTxnRecord
{
return
txnh
.
err
(
subj
,
fmt
.
Errorf
(
format
,
a
...
))
}
// decodeErr is syntactic shortcut for errf("decode", ...)
func
(
txnh
*
TxnHeader
)
decodeErr
(
format
string
,
a
...
interface
{})
*
ErrTxnRecord
{
return
txnh
.
errf
(
"decode"
,
format
,
a
...
)
}
// bug panics with errf("bug", ...)
func
(
txnh
*
TxnHeader
)
bug
(
format
string
,
a
...
interface
{})
{
panic
(
txnh
.
errf
(
"bug"
,
format
,
a
...
))
}
...
...
@@ -131,20 +132,21 @@ func (dh *DataHeader) err(subj string, err error) *ErrDataRecord {
return
&
ErrDataRecord
{
dh
.
Pos
,
subj
,
err
}
}
// errf is syntatic shortcut for err and fmt.Errorf
// errf is synta
c
tic shortcut for err and fmt.Errorf
func
(
dh
*
DataHeader
)
errf
(
subj
,
format
string
,
a
...
interface
{})
*
ErrDataRecord
{
return
dh
.
err
(
subj
,
fmt
.
Errorf
(
format
,
a
...
))
}
// TODO decodeErr
// decodeErr is syntactic shortcut for errf("decode", ...)
func
(
dh
*
DataHeader
)
decodeErr
(
format
string
,
a
...
interface
{})
*
ErrDataRecord
{
return
dh
.
errf
(
"decode"
,
format
,
a
...
)
}
// bug panics with errf("bug", ...)
func
(
dh
*
DataHeader
)
bug
(
format
string
,
a
...
interface
{})
{
panic
(
dh
.
errf
(
"bug"
,
format
,
a
...
))
}
// // XXX -> zodb?
// var ErrVersionNonZero = errors.New("non-zero version")
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
func
noEOF
(
err
error
)
error
{
if
err
==
io
.
EOF
{
...
...
@@ -161,10 +163,6 @@ const (
LoadNoStrings
=
0x01
// do not load user/desc/ext strings
)
// // it is software bug to pass invalid position to Load*()
// // this error will be panicked
// var bugPositionInvalid = errors.New("software bug: invalid position")
// Load reads and decodes transaction record header
// pos: points to transaction start
// no prerequisite requirements are made to previous txnh state
...
...
@@ -352,6 +350,7 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
// decode reads and decodes data record header
func
(
dh
*
DataHeader
)
load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
tmpBuf
*
[
DataHeaderSize
]
byte
)
error
{
dh
.
Pos
=
pos
// XXX .Len = 0 = read error ?
if
pos
<
dataValidFrom
{
dh
.
bug
(
"Load() on invalid position"
)
...
...
@@ -362,10 +361,6 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
return
&
ErrDataRecord
{
pos
,
"read"
,
noEOF
(
err
)}
}
decodeErr
:=
func
(
format
string
,
a
...
interface
{})
*
ErrDataRecord
{
return
&
ErrDataRecord
{
pos
,
"decode"
,
fmt
.
Errorf
(
format
,
a
...
)}
}
// XXX also check oid.Valid() ?
dh
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
0
:
]))
// XXX -> zodb.Oid.Decode() ?
dh
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
8
:
]))
// XXX -> zodb.Tid.Decode() ?
...
...
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