Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Levin Zimmermann
neoppod
Commits
dea3870f
Commit
dea3870f
authored
Mar 06, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0e570f8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+24
-4
No files found.
t/neo/storage/fs1/filestorage.go
View file @
dea3870f
...
...
@@ -56,7 +56,7 @@ type TxnHeader struct {
// underlying memory for header loading and for user/desc/extension strings
// invariant: after successful TxnHeader load len(.workMem) = lenUser + lenDesc + lenExt
// as specfied by on-disk header
// as spec
i
fied by on-disk header
workMem
[]
byte
}
...
...
@@ -340,7 +340,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt /* *os.File */) error {
}
// LoadPrev reads and decodes previous transaction record header
// prerequisite: txnh .Pos
and .LenPrev are initialized:
// prerequisite: txnh .Pos
, .LenPrev and .Len are initialized: XXX (.Len for .Tid)
// - by successful call to Load() initially XXX but EOF also works
// - by subsequent successful calls to LoadPrev / LoadNext XXX recheck
func
(
txnh
*
TxnHeader
)
LoadPrev
(
r
io
.
ReaderAt
,
flags
TxnLoadFlags
)
error
{
...
...
@@ -352,6 +352,9 @@ func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error {
return
io
.
EOF
}
lenCur
:=
txnh
.
Len
tidCur
:=
txnh
.
Tid
// here we know: Load already checked txnh.Pos - lenPrev to be valid position
err
:=
txnh
.
Load
(
r
,
txnh
.
Pos
-
lenPrev
,
flags
)
if
err
!=
nil
{
...
...
@@ -362,11 +365,16 @@ func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error {
return
decodeErr
(
txnh
,
"head/tail lengths mismatch: %v, %v"
,
txnh
.
Len
,
lenPrev
)
}
// check tid↓ if we had txnh for "cur" loaded
if
lenCur
>
0
&&
txnh
.
Tid
>=
tidCur
{
return
decodeErr
(
txnh
,
"tid monitonity broken: %v ; next: %v"
,
txnh
.
Tid
,
tidCur
)
}
return
nil
}
// LoadNext reads and decodes next transaction record header
// prerequisite: txnh .Pos and .Len should be already initialized by:
// prerequisite: txnh .Pos and .Len should be already initialized by:
XXX also .Tid
// - previous successful call to Load() initially XXX ^^^
// - TODO
func
(
txnh
*
TxnHeader
)
LoadNext
(
r
io
.
ReaderAt
,
flags
TxnLoadFlags
)
error
{
...
...
@@ -379,6 +387,9 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
return
io
.
EOF
}
// valid .Len means txnh was read ok
tidCur
:=
txnh
.
Tid
err
:=
txnh
.
Load
(
r
,
txnh
.
Pos
+
lenCur
,
flags
)
// before checking loading error for next txn, let's first check redundant length
...
...
@@ -388,7 +399,16 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
return
decodeErr
(
t
,
"head/tail lengths mismatch: %v, %v"
,
lenCur
,
txnh
.
LenPrev
)
}
return
err
if
err
!=
nil
{
return
err
}
// check tid↑
if
txnh
.
Tid
<=
tidCur
{
return
decodeErr
(
txnh
,
"tid monotonity broken: %v ; prev: %v"
,
txnh
.
Tid
,
tidCur
)
}
return
nil
}
// --- Data record ---
...
...
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