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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
8796c221
Commit
8796c221
authored
Sep 03, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
40d336af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
221 additions
and
17 deletions
+221
-17
go/neo/proto.go
go/neo/proto.go
+29
-6
go/neo/py/pyneo-gen-testdata
go/neo/py/pyneo-gen-testdata
+1
-0
go/neo/zproto-marshal.go
go/neo/zproto-marshal.go
+190
-10
go/neo/ztestdata_proto_py_test.go
go/neo/ztestdata_proto_py_test.go
+1
-1
No files found.
go/neo/proto.go
View file @
8796c221
...
...
@@ -36,6 +36,8 @@ package neo
// bit set if either message name starts with "Answer" or message definition is
// prefixed with `//neo:proto answer` comment.
// XXX bit-to-bit comparible with protocol.py
// TODO regroup messages definitions to stay more close to 1 communication topic
// TODO document protocol itself better (who sends who what with which semantic)
...
...
@@ -957,15 +959,36 @@ type ReplicationDone struct {
// S -> S
type
FetchTransactions
struct
{
Partition
uint32
// PNumber
Length
uint32
// PNumber
MinTid
zodb
.
Tid
MaxTid
zodb
.
Tid
TxnKnownList
[]
zodb
.
Tid
// already known transactions
}
type
AnswerFetchTransactions
struct
{
PackTid
zodb
.
Tid
NextTid
zodb
.
Tid
TxnDeleteList
[]
zodb
.
Tid
// transactions to delete
}
// S -> S
type
FetchObjects
struct
{
Partition
uint32
// PNumber
Length
uint32
// PNumber
MinTid
zodb
.
Tid
Length
uint32
// PNumber
MinTid
zodb
.
Tid
MaxTid
zodb
.
Tid
TidList
[]
zodb
.
Tid
// already known transactions
MinOid
zodb
.
Oid
// already known objects
ObjKnownDict
map
[
zodb
.
Tid
][]
zodb
.
Oid
// serial -> []oid
}
type
AnswerFetch
Transaction
s
struct
{
type
AnswerFetch
Object
s
struct
{
PackTid
zodb
.
Tid
NextTid
zodb
.
Tid
TidList
[]
zodb
.
Tid
// transactions to delete
NextTid
zodb
.
Tid
NextOid
zodb
.
Oid
// objects to delete
ObjDeleteDict
map
[
zodb
.
Tid
][]
zodb
.
Oid
// serial -> []oid
}
go/neo/py/pyneo-gen-testdata
View file @
8796c221
...
...
@@ -54,6 +54,7 @@ noask('LastTransaction')
noask
(
'CheckCurrentSerial'
)
nonotify
(
'ReplicationDone'
)
noask
(
'FetchTransactions'
)
noask
(
'FetchObjects'
)
_
=
renames
_
[
'AskPrimary'
]
=
'PrimaryMaster'
...
...
go/neo/zproto-marshal.go
View file @
8796c221
...
...
@@ -3572,7 +3572,7 @@ func (*FetchTransactions) neoMsgCode() uint16 {
}
func
(
p
*
FetchTransactions
)
neoMsgEncodedLen
()
int
{
return
28
+
len
(
p
.
T
id
List
)
*
8
return
28
+
len
(
p
.
T
xnKnown
List
)
*
8
}
func
(
p
*
FetchTransactions
)
neoMsgEncode
(
data
[]
byte
)
{
...
...
@@ -3581,11 +3581,11 @@ func (p *FetchTransactions) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
MaxTid
))
{
l
:=
uint32
(
len
(
p
.
T
id
List
))
l
:=
uint32
(
len
(
p
.
T
xnKnown
List
))
binary
.
BigEndian
.
PutUint32
(
data
[
24
:
],
l
)
data
=
data
[
28
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
T
id
List
[
i
]
a
:=
&
p
.
T
xnKnown
List
[
i
]
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
((
*
a
)))
data
=
data
[
8
:
]
}
...
...
@@ -3608,9 +3608,9 @@ func (p *FetchTransactions) neoMsgDecode(data []byte) (int, error) {
goto
overflow
}
nread
+=
l
*
8
p
.
T
id
List
=
make
([]
zodb
.
Tid
,
l
)
p
.
T
xnKnown
List
=
make
([]
zodb
.
Tid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
T
id
List
[
i
]
a
:=
&
p
.
T
xnKnown
List
[
i
]
(
*
a
)
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
}
...
...
@@ -3628,18 +3628,18 @@ func (*AnswerFetchTransactions) neoMsgCode() uint16 {
}
func
(
p
*
AnswerFetchTransactions
)
neoMsgEncodedLen
()
int
{
return
20
+
len
(
p
.
T
id
List
)
*
8
return
20
+
len
(
p
.
T
xnDelete
List
)
*
8
}
func
(
p
*
AnswerFetchTransactions
)
neoMsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
{
l
:=
uint32
(
len
(
p
.
T
id
List
))
l
:=
uint32
(
len
(
p
.
T
xnDelete
List
))
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
l
)
data
=
data
[
20
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
T
id
List
[
i
]
a
:=
&
p
.
T
xnDelete
List
[
i
]
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
((
*
a
)))
data
=
data
[
8
:
]
}
...
...
@@ -3660,9 +3660,9 @@ func (p *AnswerFetchTransactions) neoMsgDecode(data []byte) (int, error) {
goto
overflow
}
nread
+=
l
*
8
p
.
T
id
List
=
make
([]
zodb
.
Tid
,
l
)
p
.
T
xnDelete
List
=
make
([]
zodb
.
Tid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
T
id
List
[
i
]
a
:=
&
p
.
T
xnDelete
List
[
i
]
(
*
a
)
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
}
...
...
@@ -3673,6 +3673,184 @@ overflow:
return
0
,
ErrDecodeOverflow
}
// 94. FetchObjects
func
(
*
FetchObjects
)
neoMsgCode
()
uint16
{
return
94
}
func
(
p
*
FetchObjects
)
neoMsgEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
ObjKnownDict
{
size
+=
len
(
p
.
ObjKnownDict
[
key
])
*
8
}
return
36
+
len
(
p
.
ObjKnownDict
)
*
12
+
size
}
func
(
p
*
FetchObjects
)
neoMsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
MaxTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MinOid
))
{
l
:=
uint32
(
len
(
p
.
ObjKnownDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
32
:
],
l
)
data
=
data
[
36
:
]
keyv
:=
make
([]
zodb
.
Tid
,
0
,
l
)
for
key
:=
range
p
.
ObjKnownDict
{
keyv
=
append
(
keyv
,
key
)
}
sort
.
Slice
(
keyv
,
func
(
i
,
j
int
)
bool
{
return
keyv
[
i
]
<
keyv
[
j
]
})
for
_
,
key
:=
range
keyv
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
key
))
{
l
:=
uint32
(
len
(
p
.
ObjKnownDict
[
key
]))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
l
)
data
=
data
[
12
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
ObjKnownDict
[
key
][
i
]
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
((
*
a
)))
data
=
data
[
8
:
]
}
}
data
=
data
[
0
:
]
}
}
}
func
(
p
*
FetchObjects
)
neoMsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint32
if
uint32
(
len
(
data
))
<
36
{
goto
overflow
}
p
.
Partition
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
p
.
Length
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
p
.
MinTid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
MaxTid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
MinOid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
24
:
]))
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
32
:
])
data
=
data
[
36
:
]
p
.
ObjKnownDict
=
make
(
map
[
zodb
.
Tid
][]
zodb
.
Oid
,
l
)
m
:=
p
.
ObjKnownDict
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
}
key
:=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
var
v
[]
zodb
.
Oid
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
if
uint32
(
len
(
data
))
<
l
*
8
{
goto
overflow
}
nread
+=
l
*
8
v
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
v
[
i
]
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
}
}
m
[
key
]
=
v
}
nread
+=
l
*
12
}
return
36
+
int
(
nread
),
nil
overflow
:
return
0
,
ErrDecodeOverflow
}
// 95. AnswerFetchObjects
func
(
*
AnswerFetchObjects
)
neoMsgCode
()
uint16
{
return
95
|
answerBit
}
func
(
p
*
AnswerFetchObjects
)
neoMsgEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
ObjDeleteDict
{
size
+=
len
(
p
.
ObjDeleteDict
[
key
])
*
8
}
return
28
+
len
(
p
.
ObjDeleteDict
)
*
12
+
size
}
func
(
p
*
AnswerFetchObjects
)
neoMsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextOid
))
{
l
:=
uint32
(
len
(
p
.
ObjDeleteDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
24
:
],
l
)
data
=
data
[
28
:
]
keyv
:=
make
([]
zodb
.
Tid
,
0
,
l
)
for
key
:=
range
p
.
ObjDeleteDict
{
keyv
=
append
(
keyv
,
key
)
}
sort
.
Slice
(
keyv
,
func
(
i
,
j
int
)
bool
{
return
keyv
[
i
]
<
keyv
[
j
]
})
for
_
,
key
:=
range
keyv
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
key
))
{
l
:=
uint32
(
len
(
p
.
ObjDeleteDict
[
key
]))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
l
)
data
=
data
[
12
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
ObjDeleteDict
[
key
][
i
]
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
((
*
a
)))
data
=
data
[
8
:
]
}
}
data
=
data
[
0
:
]
}
}
}
func
(
p
*
AnswerFetchObjects
)
neoMsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint32
if
uint32
(
len
(
data
))
<
28
{
goto
overflow
}
p
.
PackTid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
NextTid
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
NextOid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
24
:
])
data
=
data
[
28
:
]
p
.
ObjDeleteDict
=
make
(
map
[
zodb
.
Tid
][]
zodb
.
Oid
,
l
)
m
:=
p
.
ObjDeleteDict
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
12
{
goto
overflow
}
key
:=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
var
v
[]
zodb
.
Oid
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
if
uint32
(
len
(
data
))
<
l
*
8
{
goto
overflow
}
nread
+=
l
*
8
v
=
make
([]
zodb
.
Oid
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
v
[
i
]
(
*
a
)
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
data
=
data
[
8
:
]
}
}
m
[
key
]
=
v
}
nread
+=
l
*
12
}
return
28
+
int
(
nread
),
nil
overflow
:
return
0
,
ErrDecodeOverflow
}
// registry of message types
var
msgTypeRegistry
=
map
[
uint16
]
reflect
.
Type
{
0
|
answerBit
:
reflect
.
TypeOf
(
Error
{}),
...
...
@@ -3769,4 +3947,6 @@ var msgTypeRegistry = map[uint16]reflect.Type{
91
:
reflect
.
TypeOf
(
ReplicationDone
{}),
92
:
reflect
.
TypeOf
(
FetchTransactions
{}),
93
|
answerBit
:
reflect
.
TypeOf
(
AnswerFetchTransactions
{}),
94
:
reflect
.
TypeOf
(
FetchObjects
{}),
95
|
answerBit
:
reflect
.
TypeOf
(
AnswerFetchObjects
{}),
}
go/neo/ztestdata_proto_py_test.go
View file @
8796c221
...
...
@@ -62,7 +62,7 @@ var pyMsgRegistry = map[uint16]string{
90
:
"Replicate"
,
91
:
"ReplicationDone"
,
92
:
"FetchTransactions"
,
94
:
"
Ask
FetchObjects"
,
94
:
"FetchObjects"
,
96
:
"AddTransaction"
,
97
:
"AddObject"
,
98
:
"Truncate"
,
...
...
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