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
f21b6a69
Commit
f21b6a69
authored
Feb 02, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6a8f9f71
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
327 additions
and
285 deletions
+327
-285
t/neo/marshal.go
t/neo/marshal.go
+105
-103
t/neo/neo.go
t/neo/neo.go
+12
-85
t/neo/proto.go
t/neo/proto.go
+85
-83
t/neo/protogen.go
t/neo/protogen.go
+44
-14
t/neo/zodb/zodb.go
t/neo/zodb/zodb.go
+81
-0
No files found.
t/neo/marshal.go
View file @
f21b6a69
...
@@ -6,6 +6,8 @@ import (
...
@@ -6,6 +6,8 @@ import (
"encoding/binary"
"encoding/binary"
"reflect"
"reflect"
"sort"
"sort"
"./zodb"
)
)
// packets marshalling
// packets marshalling
...
@@ -595,8 +597,8 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
...
@@ -595,8 +597,8 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
p
.
PTid
=
PTid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
PTid
=
PTid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
BackupTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
BackupTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
TruncateTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
TruncateTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
return
24
,
nil
return
24
,
nil
overflow
:
overflow
:
...
@@ -631,8 +633,8 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
...
@@ -631,8 +633,8 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
LastOID
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
LastOID
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
LastTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
LastTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -930,7 +932,7 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
...
@@ -930,7 +932,7 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -938,10 +940,10 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
...
@@ -938,10 +940,10 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
TidList
=
make
([]
struct
{
UnfinishedTID
Tid
},
l
)
p
.
TidList
=
make
([]
struct
{
UnfinishedTID
zodb
.
Tid
},
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TidList
[
i
]
a
:=
&
p
.
TidList
[
i
]
(
*
a
)
.
UnfinishedTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
.
UnfinishedTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -975,7 +977,7 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
...
@@ -975,7 +977,7 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
l
:=
uint32
(
len
(
p
.
TidDict
))
l
:=
uint32
(
len
(
p
.
TidDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
data
=
data
[
4
:
]
keyv
:=
make
([]
Tid
,
0
,
l
)
keyv
:=
make
([]
zodb
.
Tid
,
0
,
l
)
for
key
:=
range
p
.
TidDict
{
for
key
:=
range
p
.
TidDict
{
keyv
=
append
(
keyv
,
key
)
keyv
=
append
(
keyv
,
key
)
}
}
...
@@ -1000,11 +1002,11 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
...
@@ -1000,11 +1002,11 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
16
nread
+=
l
*
16
p
.
TidDict
=
make
(
map
[
Tid
]
Tid
,
l
)
p
.
TidDict
=
make
(
map
[
zodb
.
Tid
]
zodb
.
Tid
,
l
)
m
:=
p
.
TidDict
m
:=
p
.
TidDict
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
key
:=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
key
:=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
m
[
key
]
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
m
[
key
]
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
data
=
data
[
16
:
]
data
=
data
[
16
:
]
}
}
}
}
...
@@ -1028,7 +1030,7 @@ func (p *FinalTID) NEODecode(data []byte) (int, error) {
...
@@ -1028,7 +1030,7 @@ func (p *FinalTID) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
TTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
TTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1049,7 +1051,7 @@ func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) {
...
@@ -1049,7 +1051,7 @@ func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1071,8 +1073,8 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1071,8 +1073,8 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
TTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
TTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -1093,7 +1095,7 @@ func (p *BeginTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1093,7 +1095,7 @@ func (p *BeginTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1114,7 +1116,7 @@ func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1114,7 +1116,7 @@ func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1156,7 +1158,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1156,7 +1158,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -1164,10 +1166,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1164,10 +1166,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
4
+
l
*
8
nread
+=
4
+
l
*
8
p
.
OIDList
=
make
([]
Oid
,
l
)
p
.
OIDList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OIDList
[
i
]
a
:=
&
p
.
OIDList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1178,10 +1180,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1178,10 +1180,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
CheckedList
=
make
([]
Oid
,
l
)
p
.
CheckedList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
CheckedList
[
i
]
a
:=
&
p
.
CheckedList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1206,8 +1208,8 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1206,8 +1208,8 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
TTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
TTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -1229,8 +1231,8 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
...
@@ -1229,8 +1231,8 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
TTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
TTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -1252,8 +1254,8 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) {
...
@@ -1252,8 +1254,8 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
Ttid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Ttid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -1274,7 +1276,7 @@ func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) {
...
@@ -1274,7 +1276,7 @@ func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Ttid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Ttid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1306,7 +1308,7 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
...
@@ -1306,7 +1308,7 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -1314,10 +1316,10 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
...
@@ -1314,10 +1316,10 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
OidList
=
make
([]
Oid
,
l
)
p
.
OidList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
a
:=
&
p
.
OidList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1341,7 +1343,7 @@ func (p *UnlockInformation) NEODecode(data []byte) (int, error) {
...
@@ -1341,7 +1343,7 @@ func (p *UnlockInformation) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
TTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
TTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1400,10 +1402,10 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
...
@@ -1400,10 +1402,10 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
OidList
=
make
([]
Oid
,
l
)
p
.
OidList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
a
:=
&
p
.
OidList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1441,8 +1443,8 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
...
@@ -1441,8 +1443,8 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
41
{
if
uint32
(
len
(
data
))
<
41
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Compression
=
byte2bool
((
data
[
16
:
])[
0
])
p
.
Compression
=
byte2bool
((
data
[
16
:
])[
0
])
copy
(
p
.
Checksum
[
:
],
data
[
17
:
37
])
copy
(
p
.
Checksum
[
:
],
data
[
17
:
37
])
{
{
...
@@ -1456,8 +1458,8 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
...
@@ -1456,8 +1458,8 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
copy
(
p
.
Data
,
data
[
:
l
])
copy
(
p
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
p
.
DataSerial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
DataSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Unlock
=
byte2bool
((
data
[
16
:
])[
0
])
p
.
Unlock
=
byte2bool
((
data
[
16
:
])[
0
])
return
41
+
int
(
nread
),
nil
return
41
+
int
(
nread
),
nil
...
@@ -1482,8 +1484,8 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
...
@@ -1482,8 +1484,8 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
p
.
Conflicting
=
byte2bool
((
data
[
0
:
])[
0
])
p
.
Conflicting
=
byte2bool
((
data
[
0
:
])[
0
])
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
1
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
1
:
]))
p
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
9
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
9
:
]))
return
17
,
nil
return
17
,
nil
overflow
:
overflow
:
...
@@ -1504,7 +1506,7 @@ func (p *AbortTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1504,7 +1506,7 @@ func (p *AbortTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1557,7 +1559,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1557,7 +1559,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -1595,10 +1597,10 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1595,10 +1597,10 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
OidList
=
make
([]
Oid
,
l
)
p
.
OidList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
a
:=
&
p
.
OidList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1622,7 +1624,7 @@ func (p *VoteTransaction) NEODecode(data []byte) (int, error) {
...
@@ -1622,7 +1624,7 @@ func (p *VoteTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1645,9 +1647,9 @@ func (p *GetObject) NEODecode(data []byte) (int, error) {
...
@@ -1645,9 +1647,9 @@ func (p *GetObject) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
24
{
if
uint32
(
len
(
data
))
<
24
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
return
24
,
nil
return
24
,
nil
overflow
:
overflow
:
...
@@ -1681,9 +1683,9 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
...
@@ -1681,9 +1683,9 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
49
{
if
uint32
(
len
(
data
))
<
49
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
SerialStart
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
SerialStart
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
SerialEnd
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
SerialEnd
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
Compression
=
byte2bool
((
data
[
24
:
])[
0
])
p
.
Compression
=
byte2bool
((
data
[
24
:
])[
0
])
copy
(
p
.
Checksum
[
:
],
data
[
25
:
45
])
copy
(
p
.
Checksum
[
:
],
data
[
25
:
45
])
{
{
...
@@ -1697,7 +1699,7 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
...
@@ -1697,7 +1699,7 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
copy
(
p
.
Data
,
data
[
:
l
])
copy
(
p
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
p
.
DataSerial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
DataSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
49
+
int
(
nread
),
nil
return
49
+
int
(
nread
),
nil
overflow
:
overflow
:
...
@@ -1760,10 +1762,10 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
...
@@ -1760,10 +1762,10 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
TIDList
=
make
([]
Tid
,
l
)
p
.
TIDList
=
make
([]
zodb
.
Tid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TIDList
[
i
]
a
:=
&
p
.
TIDList
[
i
]
(
*
a
)
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1790,8 +1792,8 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
...
@@ -1790,8 +1792,8 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
24
{
if
uint32
(
len
(
data
))
<
24
{
goto
overflow
goto
overflow
}
}
p
.
MinTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MinTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
16
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
16
:
])
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
20
:
])
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
20
:
])
return
24
,
nil
return
24
,
nil
...
@@ -1831,10 +1833,10 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
...
@@ -1831,10 +1833,10 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
TidList
=
make
([]
Tid
,
l
)
p
.
TidList
=
make
([]
zodb
.
Tid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
TidList
[
i
]
a
:=
&
p
.
TidList
[
i
]
(
*
a
)
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1858,7 +1860,7 @@ func (p *TransactionInformation) NEODecode(data []byte) (int, error) {
...
@@ -1858,7 +1860,7 @@ func (p *TransactionInformation) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -1912,7 +1914,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
...
@@ -1912,7 +1914,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -1951,10 +1953,10 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
...
@@ -1951,10 +1953,10 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
OidList
=
make
([]
Oid
,
l
)
p
.
OidList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
a
:=
&
p
.
OidList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -1980,7 +1982,7 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
...
@@ -1980,7 +1982,7 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
24
{
if
uint32
(
len
(
data
))
<
24
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
First
=
binary
.
BigEndian
.
Uint64
(
data
[
8
:
])
p
.
First
=
binary
.
BigEndian
.
Uint64
(
data
[
8
:
])
p
.
Last
=
binary
.
BigEndian
.
Uint64
(
data
[
16
:
])
p
.
Last
=
binary
.
BigEndian
.
Uint64
(
data
[
16
:
])
return
24
,
nil
return
24
,
nil
...
@@ -2015,7 +2017,7 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
...
@@ -2015,7 +2017,7 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
...
@@ -2024,12 +2026,12 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
...
@@ -2024,12 +2026,12 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
}
}
nread
+=
l
*
12
nread
+=
l
*
12
p
.
HistoryList
=
make
([]
struct
{
p
.
HistoryList
=
make
([]
struct
{
Serial
Tid
Serial
zodb
.
Tid
Size
uint32
Size
uint32
},
l
)
},
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
HistoryList
[
i
]
a
:=
&
p
.
HistoryList
[
i
]
(
*
a
)
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
.
Size
=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
(
*
a
)
.
Size
=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
}
}
...
@@ -2612,9 +2614,9 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
...
@@ -2612,9 +2614,9 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
28
{
if
uint32
(
len
(
data
))
<
28
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
LTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
LTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
UndoneTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
UndoneTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
24
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
24
:
])
data
=
data
[
28
:
]
data
=
data
[
28
:
]
...
@@ -2622,10 +2624,10 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
...
@@ -2622,10 +2624,10 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
8
nread
+=
l
*
8
p
.
OidList
=
make
([]
Oid
,
l
)
p
.
OidList
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
OidList
[
i
]
a
:=
&
p
.
OidList
[
i
]
(
*
a
)
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
...
@@ -2646,7 +2648,7 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
...
@@ -2646,7 +2648,7 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
data
=
data
[
4
:
]
keyv
:=
make
([]
Oid
,
0
,
l
)
keyv
:=
make
([]
zodb
.
Oid
,
0
,
l
)
for
key
:=
range
p
.
ObjectTIDDict
{
for
key
:=
range
p
.
ObjectTIDDict
{
keyv
=
append
(
keyv
,
key
)
keyv
=
append
(
keyv
,
key
)
}
}
...
@@ -2673,21 +2675,21 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
...
@@ -2673,21 +2675,21 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
l
*
25
nread
+=
l
*
25
p
.
ObjectTIDDict
=
make
(
map
[
Oid
]
struct
{
p
.
ObjectTIDDict
=
make
(
map
[
zodb
.
Oid
]
struct
{
CurrentSerial
Tid
CurrentSerial
zodb
.
Tid
UndoSerial
Tid
UndoSerial
zodb
.
Tid
IsCurrent
bool
IsCurrent
bool
},
l
)
},
l
)
m
:=
p
.
ObjectTIDDict
m
:=
p
.
ObjectTIDDict
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
key
:=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
key
:=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
var
v
struct
{
var
v
struct
{
CurrentSerial
Tid
CurrentSerial
zodb
.
Tid
UndoSerial
Tid
UndoSerial
zodb
.
Tid
IsCurrent
bool
IsCurrent
bool
}
}
v
.
CurrentSerial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
v
.
CurrentSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
v
.
UndoSerial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
v
.
UndoSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
v
.
IsCurrent
=
byte2bool
((
data
[
24
:
])[
0
])
v
.
IsCurrent
=
byte2bool
((
data
[
24
:
])[
0
])
m
[
key
]
=
v
m
[
key
]
=
v
data
=
data
[
25
:
]
data
=
data
[
25
:
]
...
@@ -2714,8 +2716,8 @@ func (p *HasLock) NEODecode(data []byte) (int, error) {
...
@@ -2714,8 +2716,8 @@ func (p *HasLock) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
16
{
if
uint32
(
len
(
data
))
<
16
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
16
,
nil
return
16
,
nil
overflow
:
overflow
:
...
@@ -2737,7 +2739,7 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
...
@@ -2737,7 +2739,7 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
12
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
goto
overflow
}
}
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
LockState
=
LockState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])))
p
.
LockState
=
LockState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])))
return
12
,
nil
return
12
,
nil
...
@@ -2761,9 +2763,9 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
...
@@ -2761,9 +2763,9 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
24
{
if
uint32
(
len
(
data
))
<
24
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
return
24
,
nil
return
24
,
nil
overflow
:
overflow
:
...
@@ -2787,8 +2789,8 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
...
@@ -2787,8 +2789,8 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
p
.
Conflicting
=
byte2bool
((
data
[
0
:
])[
0
])
p
.
Conflicting
=
byte2bool
((
data
[
0
:
])[
0
])
p
.
Oid
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
1
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
1
:
]))
p
.
Serial
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
9
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
9
:
]))
return
17
,
nil
return
17
,
nil
overflow
:
overflow
:
...
@@ -2809,7 +2811,7 @@ func (p *Pack) NEODecode(data []byte) (int, error) {
...
@@ -2809,7 +2811,7 @@ func (p *Pack) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
@@ -2883,8 +2885,8 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
...
@@ -2883,8 +2885,8 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
data
=
data
[
8
:
]
data
=
data
[
8
:
]
}
}
}
}
p
.
MinTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MinTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
return
4
+
int
(
nread
),
nil
return
4
+
int
(
nread
),
nil
overflow
:
overflow
:
...
@@ -2945,8 +2947,8 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
...
@@ -2945,8 +2947,8 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
p
.
Source
.
Address
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
p
.
Source
.
Address
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
p
.
MinTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
2
:
]))
p
.
MinTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
2
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
10
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
10
:
]))
return
8
+
int
(
nread
),
nil
return
8
+
int
(
nread
),
nil
overflow
:
overflow
:
...
@@ -2972,8 +2974,8 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
...
@@ -2972,8 +2974,8 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
}
}
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
p
.
MinTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MinTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
return
24
,
nil
return
24
,
nil
overflow
:
overflow
:
...
@@ -2998,7 +3000,7 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
...
@@ -2998,7 +3000,7 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
}
}
p
.
Count
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Count
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
copy
(
p
.
Checksum
[
:
],
data
[
4
:
24
])
copy
(
p
.
Checksum
[
:
],
data
[
4
:
24
])
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
return
32
,
nil
return
32
,
nil
overflow
:
overflow
:
...
@@ -3025,9 +3027,9 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
...
@@ -3025,9 +3027,9 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
}
}
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
p
.
MinTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MinTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
MinOID
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
p
.
MinOID
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
return
32
,
nil
return
32
,
nil
overflow
:
overflow
:
...
@@ -3054,9 +3056,9 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
...
@@ -3054,9 +3056,9 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
}
}
p
.
Count
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Count
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
copy
(
p
.
TidChecksum
[
:
],
data
[
4
:
24
])
copy
(
p
.
TidChecksum
[
:
],
data
[
4
:
24
])
p
.
MaxTID
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
p
.
MaxTID
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
copy
(
p
.
OidChecksum
[
:
],
data
[
32
:
52
])
copy
(
p
.
OidChecksum
[
:
],
data
[
32
:
52
])
p
.
MaxOID
=
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
52
:
]))
p
.
MaxOID
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
52
:
]))
return
60
,
nil
return
60
,
nil
overflow
:
overflow
:
...
@@ -3136,7 +3138,7 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
...
@@ -3136,7 +3138,7 @@ func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Tid
=
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Tid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
return
8
,
nil
return
8
,
nil
overflow
:
overflow
:
...
...
t/neo/neo.go
View file @
f21b6a69
...
@@ -4,97 +4,24 @@
...
@@ -4,97 +4,24 @@
// TODO text
// TODO text
package
neo
package
neo
// ZODB types
import
(
// XXX naming -> TID, OID ?
"./zodb"
type
Tid
uint64
// transaction identifier TODO encode as BE
)
type
Oid
uint64
// object identifier TODO encode as BE
/*
// XXX "extended" oid - oid + serial, completely specifying object revision
type Xid struct {
Tid
Oid
}
*/
const
(
const
(
//INVALID_UUID UUID = 0
//INVALID_UUID UUID = 0
INVALID_TID
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
Oid
=
1
<<
64
-
1
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
ZERO_TID
Tid
=
0
// XXX or simply TID{} ?
TID0
Tid
=
ZERO_TID
// XXX ^^^ choose 1
// XXX vvv move to ZODB ?
ZERO_TID
zodb
.
Tid
=
0
// XXX or simply TID{} ?
TID0
zodb
.
Tid
=
ZERO_TID
// XXX ^^^ choose 1
ZERO_OID
Oid
=
0
// XXX or simply OID{} ? // XXX -> OID0
ZERO_OID
zodb
.
Oid
=
0
// XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8
// OID_LEN = 8
// TID_LEN = 8
// TID_LEN = 8
MAX_TID
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
MAX_TID
zodb
.
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
// SQLite does not accept numbers above 2^63-1
// SQLite does not accept numbers above 2^63-1
// ZODB also defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
// ZODB also defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
TIDMAX
Tid
=
MAX_TID
// XXX ^^^ choose 1
TIDMAX
zodb
.
Tid
=
MAX_TID
// XXX ^^^ choose 1
)
)
// ----------------------------------------
type
TxnStatus
byte
// TODO Tid.String(), Oid.String() +verbose, scanning (?)
// Information about single storage transaction
// XXX -> storage.ITransactionInformation
//type IStorageTransactionInformation interface {
type
StorageTransactionInformation
struct
{
Tid
Tid
Status
TxnStatus
User
[]
byte
Description
[]
byte
Extension
[]
byte
// TODO iter -> IStorageRecordInformation
Iter
IStorageRecordIterator
}
// Information about single storage record
type
StorageRecordInformation
struct
{
Oid
Oid
Tid
Tid
Data
[]
byte
// XXX .version ?
// XXX .data_txn (The previous transaction id)
}
type
IStorage
interface
{
Close
()
error
// TODO:
// Name()
// History(oid, size=1)
// LastTid()
// LoadBefore(oid Oid, beforeTid Tid) (data []bytes, tid Tid, err error)
// LoadSerial(oid Oid, serial Tid) (data []bytes, err error)
// PrefetchBefore(oidv []Oid, beforeTid Tid) error (?)
// Store(oid Oid, serial Tid, data []byte, txn ITransaction) error
// XXX Restore ?
// CheckCurrentSerialInTransaction(oid Oid, serial Tid, txn ITransaction) // XXX naming
// tpc_begin(txn)
// tpc_vote(txn)
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
Iterate
(
start
,
stop
Tid
)
IStorageIterator
// XXX -> Iter() ?
}
type
IStorageIterator
interface
{
Next
()
(
*
StorageTransactionInformation
,
error
)
// XXX -> NextTxn() ?
}
type
IStorageRecordIterator
interface
{
// XXX naming -> IRecordIterator
Next
()
(
*
StorageRecordInformation
,
error
)
// XXX vs ptr & nil ?
// XXX -> NextTxnObject() ?
}
t/neo/proto.go
View file @
f21b6a69
...
@@ -6,6 +6,8 @@ package neo
...
@@ -6,6 +6,8 @@ package neo
// XXX move imports out of here
// XXX move imports out of here
import
(
import
(
"./zodb"
"encoding/binary"
"encoding/binary"
"errors"
"errors"
"math"
"math"
...
@@ -281,8 +283,8 @@ type Recovery struct {
...
@@ -281,8 +283,8 @@ type Recovery struct {
type
AnswerRecovery
struct
{
type
AnswerRecovery
struct
{
PTid
PTid
BackupTID
Tid
BackupTID
zodb
.
Tid
TruncateTID
Tid
TruncateTID
zodb
.
Tid
}
}
// Ask the last OID/TID so that a master can initialize its TransactionManager.
// Ask the last OID/TID so that a master can initialize its TransactionManager.
...
@@ -291,8 +293,8 @@ type LastIDs struct {
...
@@ -291,8 +293,8 @@ type LastIDs struct {
}
}
type
AnswerLastIDs
struct
{
type
AnswerLastIDs
struct
{
LastOID
Oid
LastOID
zodb
.
Oid
LastTID
Tid
LastTID
zodb
.
Tid
}
}
// Ask the full partition table. PM -> S.
// Ask the full partition table. PM -> S.
...
@@ -343,9 +345,9 @@ type UnfinishedTransactions struct {
...
@@ -343,9 +345,9 @@ type UnfinishedTransactions struct {
}
}
type
AnswerUnfinishedTransactions
struct
{
type
AnswerUnfinishedTransactions
struct
{
MaxTID
Tid
MaxTID
zodb
.
Tid
TidList
[]
struct
{
TidList
[]
struct
{
UnfinishedTID
Tid
UnfinishedTID
zodb
.
Tid
}
}
}
}
...
@@ -355,77 +357,77 @@ type LockedTransactions struct {
...
@@ -355,77 +357,77 @@ type LockedTransactions struct {
}
}
type
AnswerLockedTransactions
struct
{
type
AnswerLockedTransactions
struct
{
TidDict
map
[
Tid
]
Tid
// ttid -> tid
TidDict
map
[
zodb
.
Tid
]
zodb
.
Tid
// ttid -> tid
}
}
// Return final tid if ttid has been committed. * -> S. C -> PM.
// Return final tid if ttid has been committed. * -> S. C -> PM.
type
FinalTID
struct
{
type
FinalTID
struct
{
TTID
Tid
TTID
zodb
.
Tid
}
}
type
AnswerFinalTID
struct
{
type
AnswerFinalTID
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
// Commit a transaction. PM -> S.
// Commit a transaction. PM -> S.
type
ValidateTransaction
struct
{
type
ValidateTransaction
struct
{
TTID
Tid
TTID
zodb
.
Tid
Tid
Tid
Tid
zodb
.
Tid
}
}
// Ask to begin a new transaction. C -> PM.
// Ask to begin a new transaction. C -> PM.
// Answer when a transaction begin, give a TID if necessary. PM -> C.
// Answer when a transaction begin, give a TID if necessary. PM -> C.
type
BeginTransaction
struct
{
type
BeginTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
type
AnswerBeginTransaction
struct
{
type
AnswerBeginTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
// Finish a transaction. C -> PM.
// Finish a transaction. C -> PM.
// Answer when a transaction is finished. PM -> C.
// Answer when a transaction is finished. PM -> C.
type
FinishTransaction
struct
{
type
FinishTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
OIDList
[]
Oid
OIDList
[]
zodb
.
Oid
CheckedList
[]
Oid
CheckedList
[]
zodb
.
Oid
}
}
type
AnswerFinishTransaction
struct
{
type
AnswerFinishTransaction
struct
{
TTID
Tid
TTID
zodb
.
Tid
Tid
Tid
Tid
zodb
.
Tid
}
}
// Notify that a transaction blocking a replication is now finished
// Notify that a transaction blocking a replication is now finished
// M -> S
// M -> S
type
NotifyTransactionFinished
struct
{
type
NotifyTransactionFinished
struct
{
TTID
Tid
TTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
}
}
// Lock information on a transaction. PM -> S.
// Lock information on a transaction. PM -> S.
// Notify information on a transaction locked. S -> PM.
// Notify information on a transaction locked. S -> PM.
type
LockInformation
struct
{
type
LockInformation
struct
{
Ttid
Tid
Ttid
zodb
.
Tid
Tid
Tid
Tid
zodb
.
Tid
}
}
// XXX AnswerInformationLocked ?
// XXX AnswerInformationLocked ?
type
AnswerLockInformation
struct
{
type
AnswerLockInformation
struct
{
Ttid
Tid
Ttid
zodb
.
Tid
}
}
// Invalidate objects. PM -> C.
// Invalidate objects. PM -> C.
// XXX ask_finish_transaction ?
// XXX ask_finish_transaction ?
type
InvalidateObjects
struct
{
type
InvalidateObjects
struct
{
Tid
Tid
Tid
zodb
.
Tid
OidList
[]
Oid
OidList
[]
zodb
.
Oid
}
}
// Unlock information on a transaction. PM -> S.
// Unlock information on a transaction. PM -> S.
type
UnlockInformation
struct
{
type
UnlockInformation
struct
{
TTID
Tid
TTID
zodb
.
Tid
}
}
// Ask new object IDs. C -> PM.
// Ask new object IDs. C -> PM.
...
@@ -436,7 +438,7 @@ type GenerateOIDs struct {
...
@@ -436,7 +438,7 @@ type GenerateOIDs struct {
// XXX answer_new_oids ?
// XXX answer_new_oids ?
type
AnswerGenerateOIDs
struct
{
type
AnswerGenerateOIDs
struct
{
OidList
[]
Oid
OidList
[]
zodb
.
Oid
}
}
...
@@ -447,42 +449,42 @@ type AnswerGenerateOIDs struct {
...
@@ -447,42 +449,42 @@ type AnswerGenerateOIDs struct {
// if this serial is newer than the current transaction ID, a client
// if this serial is newer than the current transaction ID, a client
// node must not try to resolve the conflict. S -> C.
// node must not try to resolve the conflict. S -> C.
type
StoreObject
struct
{
type
StoreObject
struct
{
Oid
Oid
Oid
zodb
.
Oid
Serial
Tid
Serial
zodb
.
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// TODO separately (for writev)
Data
[]
byte
// TODO separately (for writev)
DataSerial
Tid
DataSerial
zodb
.
Tid
Tid
Tid
Tid
zodb
.
Tid
Unlock
bool
Unlock
bool
}
}
type
AnswerStoreObject
struct
{
type
AnswerStoreObject
struct
{
Conflicting
bool
Conflicting
bool
Oid
Oid
Oid
zodb
.
Oid
Serial
Tid
Serial
zodb
.
Tid
}
}
// Abort a transaction. C -> S, PM.
// Abort a transaction. C -> S, PM.
type
AbortTransaction
struct
{
type
AbortTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
// Ask to store a transaction. C -> S.
// Ask to store a transaction. C -> S.
// Answer if transaction has been stored. S -> C.
// Answer if transaction has been stored. S -> C.
type
StoreTransaction
struct
{
type
StoreTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
User
string
User
string
Description
string
Description
string
Extension
string
Extension
string
OidList
[]
Oid
OidList
[]
zodb
.
Oid
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
// Ask to store a transaction. C -> S.
// Ask to store a transaction. C -> S.
// Answer if transaction has been stored. S -> C.
// Answer if transaction has been stored. S -> C.
type
VoteTransaction
struct
{
type
VoteTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
...
@@ -491,20 +493,20 @@ type VoteTransaction struct {
...
@@ -491,20 +493,20 @@ type VoteTransaction struct {
// a TID is specified, an object right before the TID will be returned. C -> S.
// a TID is specified, an object right before the TID will be returned. C -> S.
// Answer the requested object. S -> C.
// Answer the requested object. S -> C.
type
GetObject
struct
{
type
GetObject
struct
{
Oid
Oid
Oid
zodb
.
Oid
Serial
Tid
Serial
zodb
.
Tid
Tid
Tid
Tid
zodb
.
Tid
}
}
// XXX answer_object ?
// XXX answer_object ?
type
AnswerGetObject
struct
{
type
AnswerGetObject
struct
{
Oid
Oid
Oid
zodb
.
Oid
SerialStart
Tid
SerialStart
zodb
.
Tid
SerialEnd
Tid
SerialEnd
zodb
.
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// TODO separately (for writev)
Data
[]
byte
// TODO separately (for writev)
DataSerial
Tid
DataSerial
zodb
.
Tid
}
}
// Ask for TIDs between a range of offsets. The order of TIDs is descending,
// Ask for TIDs between a range of offsets. The order of TIDs is descending,
...
@@ -518,52 +520,52 @@ type TIDList struct {
...
@@ -518,52 +520,52 @@ type TIDList struct {
// XXX answer_tids ?
// XXX answer_tids ?
type
AnswerTIDList
struct
{
type
AnswerTIDList
struct
{
TIDList
[]
Tid
TIDList
[]
zodb
.
Tid
}
}
// Ask for length TIDs starting at min_tid. The order of TIDs is ascending.
// Ask for length TIDs starting at min_tid. The order of TIDs is ascending.
// C -> S.
// C -> S.
// Answer the requested TIDs. S -> C
// Answer the requested TIDs. S -> C
type
TIDListFrom
struct
{
type
TIDListFrom
struct
{
MinTID
Tid
MinTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
Length
uint32
// PNumber
Length
uint32
// PNumber
Partition
uint32
// PNumber
Partition
uint32
// PNumber
}
}
// XXX answer_tids ?
// XXX answer_tids ?
type
AnswerTIDListFrom
struct
{
type
AnswerTIDListFrom
struct
{
TidList
[]
Tid
TidList
[]
zodb
.
Tid
}
}
// Ask information about a transaction. Any -> S.
// Ask information about a transaction. Any -> S.
// Answer information (user, description) about a transaction. S -> Any.
// Answer information (user, description) about a transaction. S -> Any.
type
TransactionInformation
struct
{
type
TransactionInformation
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
type
AnswerTransactionInformation
struct
{
type
AnswerTransactionInformation
struct
{
Tid
Tid
Tid
zodb
.
Tid
User
string
User
string
Description
string
Description
string
Extension
string
Extension
string
Packed
bool
Packed
bool
OidList
[]
Oid
OidList
[]
zodb
.
Oid
}
}
// Ask history information for a given object. The order of serials is
// Ask history information for a given object. The order of serials is
// descending, and the range is [first, last]. C -> S.
// descending, and the range is [first, last]. C -> S.
// Answer history information (serial, size) for an object. S -> C.
// Answer history information (serial, size) for an object. S -> C.
type
ObjectHistory
struct
{
type
ObjectHistory
struct
{
Oid
Oid
Oid
zodb
.
Oid
First
uint64
// PIndex XXX this is actually TID
First
uint64
// PIndex XXX this is actually TID
Last
uint64
// PIndex ----//----
Last
uint64
// PIndex ----//----
}
}
type
AnswerObjectHistory
struct
{
type
AnswerObjectHistory
struct
{
Oid
Oid
Oid
zodb
.
Oid
HistoryList
[]
struct
{
HistoryList
[]
struct
{
Serial
Tid
Serial
zodb
.
Tid
Size
uint32
// PNumber
Size
uint32
// PNumber
}
}
}
}
...
@@ -677,17 +679,17 @@ type X_ClusterState struct { // XXX conflicts with ClusterState enum
...
@@ -677,17 +679,17 @@ type X_ClusterState struct { // XXX conflicts with ClusterState enum
// If current_serial's data is current on storage.
// If current_serial's data is current on storage.
// S -> C
// S -> C
type
ObjectUndoSerial
struct
{
type
ObjectUndoSerial
struct
{
Tid
Tid
Tid
zodb
.
Tid
LTID
Tid
LTID
zodb
.
Tid
UndoneTID
Tid
UndoneTID
zodb
.
Tid
OidList
[]
Oid
OidList
[]
zodb
.
Oid
}
}
// XXX answer_undo_transaction ?
// XXX answer_undo_transaction ?
type
AnswerObjectUndoSerial
struct
{
type
AnswerObjectUndoSerial
struct
{
ObjectTIDDict
map
[
Oid
]
struct
{
ObjectTIDDict
map
[
zodb
.
Oid
]
struct
{
CurrentSerial
Tid
CurrentSerial
zodb
.
Tid
UndoSerial
Tid
UndoSerial
zodb
.
Tid
IsCurrent
bool
IsCurrent
bool
}
}
}
}
...
@@ -696,12 +698,12 @@ type AnswerObjectUndoSerial struct {
...
@@ -696,12 +698,12 @@ type AnswerObjectUndoSerial struct {
// C -> S
// C -> S
// Answer whether a transaction holds the write lock for requested object.
// Answer whether a transaction holds the write lock for requested object.
type
HasLock
struct
{
type
HasLock
struct
{
Tid
Tid
Tid
zodb
.
Tid
Oid
Oid
Oid
zodb
.
Oid
}
}
type
AnswerHasLock
struct
{
type
AnswerHasLock
struct
{
Oid
Oid
Oid
zodb
.
Oid
LockState
LockState
LockState
LockState
}
}
...
@@ -713,16 +715,16 @@ type AnswerHasLock struct {
...
@@ -713,16 +715,16 @@ type AnswerHasLock struct {
// Same structure as AnswerStoreObject, to handle the same way, except there
// Same structure as AnswerStoreObject, to handle the same way, except there
// is nothing to invalidate in any client's cache.
// is nothing to invalidate in any client's cache.
type
CheckCurrentSerial
struct
{
type
CheckCurrentSerial
struct
{
Tid
Tid
Tid
zodb
.
Tid
Serial
Tid
Serial
zodb
.
Tid
Oid
Oid
Oid
zodb
.
Oid
}
}
// XXX answer_store_object ?
// XXX answer_store_object ?
type
AnswerCheckCurrentSerial
struct
{
type
AnswerCheckCurrentSerial
struct
{
Conflicting
bool
Conflicting
bool
Oid
Oid
Oid
zodb
.
Oid
Serial
Tid
Serial
zodb
.
Tid
}
}
// Request a pack at given TID.
// Request a pack at given TID.
...
@@ -732,7 +734,7 @@ type AnswerCheckCurrentSerial struct {
...
@@ -732,7 +734,7 @@ type AnswerCheckCurrentSerial struct {
// S -> M
// S -> M
// M -> C
// M -> C
type
Pack
struct
{
type
Pack
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
type
AnswerPack
struct
{
type
AnswerPack
struct
{
...
@@ -744,8 +746,8 @@ type AnswerPack struct {
...
@@ -744,8 +746,8 @@ type AnswerPack struct {
// A -> M
// A -> M
type
CheckReplicas
struct
{
type
CheckReplicas
struct
{
PartitionDict
map
[
uint32
]
UUID
// partition -> source (PNumber)
PartitionDict
map
[
uint32
]
UUID
// partition -> source (PNumber)
MinTID
Tid
MinTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
// XXX _answer = Error
// XXX _answer = Error
}
}
...
@@ -757,8 +759,8 @@ type CheckPartition struct {
...
@@ -757,8 +759,8 @@ type CheckPartition struct {
UpstreamName
string
UpstreamName
string
Address
Address
Address
Address
}
}
MinTID
Tid
MinTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
}
}
...
@@ -773,14 +775,14 @@ type CheckPartition struct {
...
@@ -773,14 +775,14 @@ type CheckPartition struct {
type
CheckTIDRange
struct
{
type
CheckTIDRange
struct
{
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
}
}
type
AnswerCheckTIDRange
struct
{
type
AnswerCheckTIDRange
struct
{
Count
uint32
// PNumber
Count
uint32
// PNumber
Checksum
Checksum
Checksum
Checksum
MaxTID
Tid
MaxTID
zodb
.
Tid
}
}
// Ask some stats about a range of object history.
// Ask some stats about a range of object history.
...
@@ -794,17 +796,17 @@ type AnswerCheckTIDRange struct {
...
@@ -794,17 +796,17 @@ type AnswerCheckTIDRange struct {
type
CheckSerialRange
struct
{
type
CheckSerialRange
struct
{
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
zodb
.
Tid
MaxTID
Tid
MaxTID
zodb
.
Tid
MinOID
Oid
MinOID
zodb
.
Oid
}
}
type
AnswerCheckSerialRange
struct
{
type
AnswerCheckSerialRange
struct
{
Count
uint32
// PNumber
Count
uint32
// PNumber
TidChecksum
Checksum
TidChecksum
Checksum
MaxTID
Tid
MaxTID
zodb
.
Tid
OidChecksum
Checksum
OidChecksum
Checksum
MaxOID
Oid
MaxOID
zodb
.
Oid
}
}
// S -> M
// S -> M
...
@@ -822,7 +824,7 @@ type LastTransaction struct {
...
@@ -822,7 +824,7 @@ type LastTransaction struct {
}
}
type
AnswerLastTransaction
struct
{
type
AnswerLastTransaction
struct
{
Tid
Tid
Tid
zodb
.
Tid
}
}
...
...
t/neo/protogen.go
View file @
f21b6a69
...
@@ -71,7 +71,9 @@ import (
...
@@ -71,7 +71,9 @@ import (
// parsed & typechecked input
// parsed & typechecked input
var
fset
=
token
.
NewFileSet
()
var
fset
=
token
.
NewFileSet
()
var
info
=
&
types
.
Info
{
var
fileMap
=
map
[
string
]
*
ast
.
File
{}
// fileName -> AST
var
pkgMap
=
map
[
string
]
*
types
.
Package
{}
// pkgName -> Package
var
typeInfo
=
&
types
.
Info
{
Types
:
make
(
map
[
ast
.
Expr
]
types
.
TypeAndValue
),
Types
:
make
(
map
[
ast
.
Expr
]
types
.
TypeAndValue
),
Defs
:
make
(
map
[
*
ast
.
Ident
]
types
.
Object
),
Defs
:
make
(
map
[
*
ast
.
Ident
]
types
.
Object
),
}
}
...
@@ -97,33 +99,59 @@ func (b *Buffer) emit(format string, a ...interface{}) {
...
@@ -97,33 +99,59 @@ func (b *Buffer) emit(format string, a ...interface{}) {
}
}
func
main
()
{
// importer that takes into account our already-loaded packages
var
err
error
type
localImporter
struct
{
types
.
Importer
}
log
.
SetFlags
(
0
)
func
(
li
*
localImporter
)
Import
(
path
string
)
(
*
types
.
Package
,
error
)
{
xpath
:=
strings
.
TrimPrefix
(
path
,
"./"
)
// ./zodb -> zodb
pkg
:=
pkgMap
[
xpath
]
if
pkg
!=
nil
{
return
pkg
,
nil
}
// go through proto.go and AST'ify & typecheck it
return
li
.
Importer
.
Import
(
path
)
var
fv
[]
*
ast
.
File
}
for
_
,
src
:=
range
[]
string
{
"proto.go"
,
"neo.go"
}
{
func
loadPkg
(
pkgName
string
,
sources
...
string
)
*
types
.
Package
{
var
filev
[]
*
ast
.
File
// parse
for
_
,
src
:=
range
sources
{
f
,
err
:=
parser
.
ParseFile
(
fset
,
src
,
nil
,
0
)
f
,
err
:=
parser
.
ParseFile
(
fset
,
src
,
nil
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"parse: %v"
,
err
)
log
.
Fatalf
(
"parse: %v"
,
err
)
}
}
fv
=
append
(
fv
,
f
)
fileMap
[
src
]
=
f
filev
=
append
(
filev
,
f
)
}
}
//ast.Print(fset, fv[0])
//ast.Print(fset, fv[0])
//return
//return
conf
:=
types
.
Config
{
Importer
:
importer
.
Default
()}
// typecheck
neoPkg
,
err
:=
conf
.
Check
(
"neo"
,
fset
,
fv
,
info
)
conf
:=
types
.
Config
{
Importer
:
&
localImporter
{
importer
.
Default
()}}
pkg
,
err
:=
conf
.
Check
(
pkgName
,
fset
,
filev
,
typeInfo
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"typecheck: %v"
,
err
)
log
.
Fatalf
(
"typecheck: %v"
,
err
)
}
}
neoQualifier
=
types
.
RelativeTo
(
neoPkg
)
pkgMap
[
pkgName
]
=
pkg
return
pkg
}
func
main
()
{
var
err
error
log
.
SetFlags
(
0
)
// go through proto.go and AST'ify & typecheck it
loadPkg
(
"zodb"
,
"zodb/zodb.go"
)
loadPkg
(
"neo"
,
"proto.go"
,
"neo.go"
)
neoQualifier
=
types
.
RelativeTo
(
pkgMap
[
"neo"
])
// prologue
// prologue
f
:=
f
v
[
0
]
// proto.go comes first
f
:=
f
ileMap
[
"proto.go"
]
buf
:=
Buffer
{}
buf
:=
Buffer
{}
buf
.
emit
(
`// DO NOT EDIT - AUTOGENERATED (by protogen.go)
buf
.
emit
(
`// DO NOT EDIT - AUTOGENERATED (by protogen.go)
...
@@ -132,6 +160,8 @@ import (
...
@@ -132,6 +160,8 @@ import (
"encoding/binary"
"encoding/binary"
"reflect"
"reflect"
"sort"
"sort"
"./zodb"
)`
)
)`
)
pktTypeRegistry
:=
map
[
int
]
string
{}
// pktCode -> typename
pktTypeRegistry
:=
map
[
int
]
string
{}
// pktCode -> typename
...
@@ -964,8 +994,8 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGene
...
@@ -964,8 +994,8 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGene
// generate size/encode/decode functions for a type declaration typespec
// generate size/encode/decode functions for a type declaration typespec
func
generateCodecCode
(
typespec
*
ast
.
TypeSpec
,
codegen
CodeGenerator
)
string
{
func
generateCodecCode
(
typespec
*
ast
.
TypeSpec
,
codegen
CodeGenerator
)
string
{
// type & object which refers to this type
// type & object which refers to this type
typ
:=
i
nfo
.
Types
[
typespec
.
Type
]
.
Type
typ
:=
typeI
nfo
.
Types
[
typespec
.
Type
]
.
Type
obj
:=
i
nfo
.
Defs
[
typespec
.
Name
]
obj
:=
typeI
nfo
.
Defs
[
typespec
.
Name
]
codegen
.
setFunc
(
"p"
,
typespec
.
Name
.
Name
,
typ
)
codegen
.
setFunc
(
"p"
,
typespec
.
Name
.
Name
,
typ
)
codegenType
(
"p"
,
typ
,
obj
,
codegen
)
codegenType
(
"p"
,
typ
,
obj
,
codegen
)
...
...
t/neo/zodb/zodb.go
0 → 100644
View file @
f21b6a69
// TODO copyright / license
// Package zodb defines types and interfaces used in ZODB databases
package
zodb
// ZODB types
type
Tid
uint64
// transaction identifier
type
Oid
uint64
// object identifier
/*
// XXX "extended" oid - oid + serial, completely specifying object revision
type Xid struct {
Tid
Oid
}
*/
// ----------------------------------------
type
TxnStatus
byte
// TODO Tid.String(), Oid.String() +verbose, scanning (?)
// Information about single storage transaction
// XXX -> storage.ITransactionInformation
//type IStorageTransactionInformation interface {
type
StorageTransactionInformation
struct
{
Tid
Tid
Status
TxnStatus
User
[]
byte
Description
[]
byte
Extension
[]
byte
// TODO iter -> IStorageRecordInformation
Iter
IStorageRecordIterator
}
// Information about single storage record
type
StorageRecordInformation
struct
{
Oid
Oid
Tid
Tid
Data
[]
byte
// XXX .version ?
// XXX .data_txn (The previous transaction id)
}
type
IStorage
interface
{
Close
()
error
// TODO:
// Name()
// History(oid, size=1)
// LastTid()
// LoadBefore(oid Oid, beforeTid Tid) (data []bytes, tid Tid, err error)
// LoadSerial(oid Oid, serial Tid) (data []bytes, err error)
// PrefetchBefore(oidv []Oid, beforeTid Tid) error (?)
// Store(oid Oid, serial Tid, data []byte, txn ITransaction) error
// XXX Restore ?
// CheckCurrentSerialInTransaction(oid Oid, serial Tid, txn ITransaction) // XXX naming
// tpc_begin(txn)
// tpc_vote(txn)
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
Iterate
(
start
,
stop
Tid
)
IStorageIterator
// XXX -> Iter() ?
}
type
IStorageIterator
interface
{
Next
()
(
*
StorageTransactionInformation
,
error
)
// XXX -> NextTxn() ?
}
type
IStorageRecordIterator
interface
{
// XXX naming -> IRecordIterator
Next
()
(
*
StorageRecordInformation
,
error
)
// XXX vs ptr & nil ?
// XXX -> NextTxnObject() ?
}
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