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
47f069a5
Commit
47f069a5
authored
Feb 12, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X move protocol bits into neo/proto/ package
parent
7b4ae7bd
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1009 additions
and
884 deletions
+1009
-884
go/neo/client/client.go
go/neo/client/client.go
+15
-14
go/neo/connection.go
go/neo/connection.go
+51
-48
go/neo/connection_test.go
go/neo/connection_test.go
+34
-31
go/neo/neo.go
go/neo/neo.go
+20
-31
go/neo/nodetab.go
go/neo/nodetab.go
+14
-12
go/neo/parttab.go
go/neo/parttab.go
+11
-10
go/neo/parttab_test.go
go/neo/parttab_test.go
+15
-13
go/neo/pkt.go
go/neo/pkt.go
+18
-15
go/neo/proto/error.go
go/neo/proto/error.go
+3
-2
go/neo/proto/proto-misc.go
go/neo/proto/proto-misc.go
+13
-2
go/neo/proto/proto.go
go/neo/proto/proto.go
+49
-22
go/neo/proto/proto_test.go
go/neo/proto/proto_test.go
+15
-15
go/neo/proto/proto_vs_py_test.go
go/neo/proto/proto_vs_py_test.go
+2
-2
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+19
-19
go/neo/proto/py/pyneo-gen-testdata
go/neo/proto/py/pyneo-gen-testdata
+2
-2
go/neo/proto/zproto-marshal.go
go/neo/proto/zproto-marshal.go
+408
-408
go/neo/proto/zproto-str.go
go/neo/proto/zproto-str.go
+2
-2
go/neo/proto/ztestdata_proto_py_test.go
go/neo/proto/ztestdata_proto_py_test.go
+1
-1
go/neo/proto/ztrace.go
go/neo/proto/ztrace.go
+39
-0
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+71
-69
go/neo/server/master.go
go/neo/server/master.go
+74
-73
go/neo/server/server.go
go/neo/server/server.go
+8
-7
go/neo/server/storage.go
go/neo/server/storage.go
+43
-42
go/neo/server/ztrace_test.go
go/neo/server/ztrace_test.go
+15
-6
go/neo/ztrace.go
go/neo/ztrace.go
+13
-38
go/xcommon/packed/packed.go
go/xcommon/packed/packed.go
+54
-0
No files found.
go/neo/client/client.go
View file @
47f069a5
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/internal/common"
"lab.nexedi.com/kirr/neo/go/neo/internal/common"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
...
@@ -77,7 +78,7 @@ var _ zodb.IStorageDriver = (*Client)(nil)
...
@@ -77,7 +78,7 @@ var _ zodb.IStorageDriver = (*Client)(nil)
// It will connect to master @masterAddr and identify with specified cluster name.
// It will connect to master @masterAddr and identify with specified cluster name.
func
NewClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
Client
{
func
NewClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
Client
{
cli
:=
&
Client
{
cli
:=
&
Client
{
node
:
neo
.
NewNodeApp
(
net
,
ne
o
.
CLIENT
,
clusterName
,
masterAddr
,
""
),
node
:
neo
.
NewNodeApp
(
net
,
prot
o
.
CLIENT
,
clusterName
,
masterAddr
,
""
),
mlinkReady
:
make
(
chan
struct
{}),
mlinkReady
:
make
(
chan
struct
{}),
operational
:
false
,
operational
:
false
,
opReady
:
make
(
chan
struct
{}),
opReady
:
make
(
chan
struct
{}),
...
@@ -225,7 +226,7 @@ func (c *Client) talkMaster(ctx context.Context) (err error) {
...
@@ -225,7 +226,7 @@ func (c *Client) talkMaster(ctx context.Context) (err error) {
}
}
func
(
c
*
Client
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
c
*
Client
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
mlink
,
accept
,
err
:=
c
.
node
.
Dial
(
ctx
,
ne
o
.
MASTER
,
c
.
node
.
MasterAddr
)
mlink
,
accept
,
err
:=
c
.
node
.
Dial
(
ctx
,
prot
o
.
MASTER
,
c
.
node
.
MasterAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
// FIXME it is not only identification - e.g. ECONNREFUSED
// FIXME it is not only identification - e.g. ECONNREFUSED
return
err
return
err
...
@@ -302,17 +303,17 @@ func (c *Client) recvMaster1(ctx context.Context, req neo.Request) error {
...
@@ -302,17 +303,17 @@ func (c *Client) recvMaster1(ctx context.Context, req neo.Request) error {
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
// M sends whole PT
// M sends whole PT
case
*
ne
o
.
SendPartitionTable
:
case
*
prot
o
.
SendPartitionTable
:
c
.
node
.
UpdatePartTab
(
ctx
,
msg
)
c
.
node
.
UpdatePartTab
(
ctx
,
msg
)
// M sends δPT
// M sends δPT
//case *
ne
o.NotifyPartitionChanges:
//case *
prot
o.NotifyPartitionChanges:
// TODO
// TODO
case
*
ne
o
.
NotifyNodeInformation
:
case
*
prot
o
.
NotifyNodeInformation
:
c
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
c
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
case
*
ne
o
.
NotifyClusterState
:
case
*
prot
o
.
NotifyClusterState
:
c
.
node
.
UpdateClusterState
(
ctx
,
msg
)
c
.
node
.
UpdateClusterState
(
ctx
,
msg
)
}
}
...
@@ -328,8 +329,8 @@ func (c *Client) initFromMaster(ctx context.Context, mlink *neo.NodeLink) (err e
...
@@ -328,8 +329,8 @@ func (c *Client) initFromMaster(ctx context.Context, mlink *neo.NodeLink) (err e
defer
task
.
Running
(
&
ctx
,
"init"
)(
&
err
)
defer
task
.
Running
(
&
ctx
,
"init"
)(
&
err
)
// ask M for PT
// ask M for PT
rpt
:=
ne
o
.
AnswerPartitionTable
{}
rpt
:=
prot
o
.
AnswerPartitionTable
{}
err
=
mlink
.
Ask1
(
&
ne
o
.
AskPartitionTable
{},
&
rpt
)
err
=
mlink
.
Ask1
(
&
prot
o
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -379,8 +380,8 @@ func (c *Client) LastTid(ctx context.Context) (_ zodb.Tid, err error) {
...
@@ -379,8 +380,8 @@ func (c *Client) LastTid(ctx context.Context) (_ zodb.Tid, err error) {
// XXX mlink can become down while we are making the call.
// XXX mlink can become down while we are making the call.
// XXX do we want to return error or retry?
// XXX do we want to return error or retry?
reply
:=
ne
o
.
AnswerLastTransaction
{}
reply
:=
prot
o
.
AnswerLastTransaction
{}
err
=
mlink
.
Ask1
(
&
ne
o
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
err
=
mlink
.
Ask1
(
&
prot
o
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
// XXX err ctx
return
0
,
err
// XXX err ctx
}
}
...
@@ -418,7 +419,7 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
...
@@ -418,7 +419,7 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
if
cell
.
Readable
()
{
if
cell
.
Readable
()
{
stor
:=
c
.
node
.
NodeTab
.
Get
(
cell
.
UUID
)
stor
:=
c
.
node
.
NodeTab
.
Get
(
cell
.
UUID
)
// this storage might not yet come up
// this storage might not yet come up
if
stor
!=
nil
&&
stor
.
State
==
ne
o
.
RUNNING
{
if
stor
!=
nil
&&
stor
.
State
==
prot
o
.
RUNNING
{
storv
=
append
(
storv
,
stor
)
storv
=
append
(
storv
,
stor
)
}
}
}
}
...
@@ -443,13 +444,13 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
...
@@ -443,13 +444,13 @@ func (c *Client) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, e
// S decides to send us something)
// S decides to send us something)
// on the wire it comes as "before", not "at"
// on the wire it comes as "before", not "at"
req
:=
ne
o
.
GetObject
{
req
:=
prot
o
.
GetObject
{
Oid
:
xid
.
Oid
,
Oid
:
xid
.
Oid
,
Tid
:
common
.
At2Before
(
xid
.
At
),
Tid
:
common
.
At2Before
(
xid
.
At
),
Serial
:
ne
o
.
INVALID_TID
,
Serial
:
prot
o
.
INVALID_TID
,
}
}
resp
:=
ne
o
.
AnswerObject
{}
resp
:=
prot
o
.
AnswerObject
{}
err
=
slink
.
Ask1
(
&
req
,
&
resp
)
err
=
slink
.
Ask1
(
&
req
,
&
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
// XXX err context
return
nil
,
0
,
err
// XXX err context
...
...
go/neo/connection.go
View file @
47f069a5
...
@@ -34,6 +34,9 @@ import (
...
@@ -34,6 +34,9 @@ import (
"sync/atomic"
"sync/atomic"
"time"
"time"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
"github.com/someonegg/gocontainer/rbuf"
"github.com/someonegg/gocontainer/rbuf"
"lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/go123/xbytes"
...
@@ -457,7 +460,7 @@ func (c *Conn) shutdownTX() {
...
@@ -457,7 +460,7 @@ func (c *Conn) shutdownTX() {
}
}
// shutdownRX marks .rxq as no loner operational and interrupts Recv.
// shutdownRX marks .rxq as no loner operational and interrupts Recv.
func
(
c
*
Conn
)
shutdownRX
(
errMsg
*
Error
)
{
func
(
c
*
Conn
)
shutdownRX
(
errMsg
*
proto
.
Error
)
{
c
.
rxdownOnce
.
Do
(
func
()
{
c
.
rxdownOnce
.
Do
(
func
()
{
// close(c.rxdown) // wakeup Conn.Recv
// close(c.rxdown) // wakeup Conn.Recv
c
.
downRX
(
errMsg
)
c
.
downRX
(
errMsg
)
...
@@ -467,7 +470,7 @@ func (c *Conn) shutdownRX(errMsg *Error) {
...
@@ -467,7 +470,7 @@ func (c *Conn) shutdownRX(errMsg *Error) {
// downRX marks .rxq as no longer operational.
// downRX marks .rxq as no longer operational.
//
//
// used in shutdownRX and separately to mark RX down for light Conns.
// used in shutdownRX and separately to mark RX down for light Conns.
func
(
c
*
Conn
)
downRX
(
errMsg
*
Error
)
{
func
(
c
*
Conn
)
downRX
(
errMsg
*
proto
.
Error
)
{
// let serveRecv know RX is down for this connection
// let serveRecv know RX is down for this connection
c
.
rxdownFlag
.
Set
(
1
)
// XXX cmpxchg and return if already down?
c
.
rxdownFlag
.
Set
(
1
)
// XXX cmpxchg and return if already down?
...
@@ -740,7 +743,7 @@ func (nl *NodeLink) serveRecv() {
...
@@ -740,7 +743,7 @@ func (nl *NodeLink) serveRecv() {
}
}
// pkt.ConnId -> Conn
// pkt.ConnId -> Conn
connId
:=
n
toh32
(
pkt
.
Header
()
.
ConnId
)
connId
:=
packed
.
N
toh32
(
pkt
.
Header
()
.
ConnId
)
accept
:=
false
accept
:=
false
nl
.
connMu
.
Lock
()
nl
.
connMu
.
Lock
()
...
@@ -921,11 +924,11 @@ func (nl *NodeLink) serveRecv() {
...
@@ -921,11 +924,11 @@ func (nl *NodeLink) serveRecv() {
// ---- network replies for closed / refused connections ----
// ---- network replies for closed / refused connections ----
var
errConnClosed
=
&
Error
{
PROTOCOL_ERROR
,
"connection closed"
}
var
errConnClosed
=
&
proto
.
Error
{
proto
.
PROTOCOL_ERROR
,
"connection closed"
}
var
errConnRefused
=
&
Error
{
PROTOCOL_ERROR
,
"connection refused"
}
var
errConnRefused
=
&
proto
.
Error
{
proto
.
PROTOCOL_ERROR
,
"connection refused"
}
// replyNoConn sends error message to peer when a packet was sent to closed / nonexistent connection
// replyNoConn sends error message to peer when a packet was sent to closed / nonexistent connection
func
(
link
*
NodeLink
)
replyNoConn
(
connId
uint32
,
errMsg
Msg
)
{
func
(
link
*
NodeLink
)
replyNoConn
(
connId
uint32
,
errMsg
proto
.
Msg
)
{
//fmt.Printf("%s .%d: -> replyNoConn %v\n", link, connId, errMsg)
//fmt.Printf("%s .%d: -> replyNoConn %v\n", link, connId, errMsg)
link
.
sendMsg
(
connId
,
errMsg
)
// ignore errors
link
.
sendMsg
(
connId
,
errMsg
)
// ignore errors
//fmt.Printf("%s .%d: replyNoConn(%v) -> %v\n", link, connId, errMsg, err)
//fmt.Printf("%s .%d: replyNoConn(%v) -> %v\n", link, connId, errMsg, err)
...
@@ -967,7 +970,7 @@ func (c *Conn) sendPkt(pkt *PktBuf) error {
...
@@ -967,7 +970,7 @@ func (c *Conn) sendPkt(pkt *PktBuf) error {
func
(
c
*
Conn
)
sendPkt2
(
pkt
*
PktBuf
)
error
{
func
(
c
*
Conn
)
sendPkt2
(
pkt
*
PktBuf
)
error
{
// connId must be set to one associated with this connection
// connId must be set to one associated with this connection
if
pkt
.
Header
()
.
ConnId
!=
h
ton32
(
c
.
connId
)
{
if
pkt
.
Header
()
.
ConnId
!=
packed
.
H
ton32
(
c
.
connId
)
{
panic
(
"Conn.sendPkt: connId wrong"
)
panic
(
"Conn.sendPkt: connId wrong"
)
}
}
...
@@ -1052,7 +1055,7 @@ func (nl *NodeLink) serveSend() {
...
@@ -1052,7 +1055,7 @@ func (nl *NodeLink) serveSend() {
// sendPktDirect sends raw packet with appropriate connection ID directly via link.
// sendPktDirect sends raw packet with appropriate connection ID directly via link.
func
(
c
*
Conn
)
sendPktDirect
(
pkt
*
PktBuf
)
error
{
func
(
c
*
Conn
)
sendPktDirect
(
pkt
*
PktBuf
)
error
{
// set pkt connId associated with this connection
// set pkt connId associated with this connection
pkt
.
Header
()
.
ConnId
=
h
ton32
(
c
.
connId
)
pkt
.
Header
()
.
ConnId
=
packed
.
H
ton32
(
c
.
connId
)
// XXX if n.peerLink was just closed by rx->shutdown we'll get ErrNetClosing
// XXX if n.peerLink was just closed by rx->shutdown we'll get ErrNetClosing
err
:=
c
.
link
.
sendPkt
(
pkt
)
err
:=
c
.
link
.
sendPkt
(
pkt
)
...
@@ -1108,13 +1111,13 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
...
@@ -1108,13 +1111,13 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
// next packet could be already prefetched in part by previous read
// next packet could be already prefetched in part by previous read
if
nl
.
rxbuf
.
Len
()
>
0
{
if
nl
.
rxbuf
.
Len
()
>
0
{
δn
,
_
:=
nl
.
rxbuf
.
Read
(
data
[
:
pktHeaderLen
])
δn
,
_
:=
nl
.
rxbuf
.
Read
(
data
[
:
p
roto
.
P
ktHeaderLen
])
n
+=
δn
n
+=
δn
}
}
// first read to read pkt header and hopefully rest of packet in 1 syscall
// first read to read pkt header and hopefully rest of packet in 1 syscall
if
n
<
pktHeaderLen
{
if
n
<
p
roto
.
P
ktHeaderLen
{
δn
,
err
:=
io
.
ReadAtLeast
(
nl
.
peerLink
,
data
[
n
:
],
pktHeaderLen
-
n
)
δn
,
err
:=
io
.
ReadAtLeast
(
nl
.
peerLink
,
data
[
n
:
],
p
roto
.
P
ktHeaderLen
-
n
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -1123,8 +1126,8 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
...
@@ -1123,8 +1126,8 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
pkth
:=
pkt
.
Header
()
pkth
:=
pkt
.
Header
()
pktLen
:=
int
(
p
ktHeaderLen
+
n
toh32
(
pkth
.
MsgLen
))
// whole packet length
pktLen
:=
int
(
p
roto
.
PktHeaderLen
+
packed
.
N
toh32
(
pkth
.
MsgLen
))
// whole packet length
if
pktLen
>
pktMaxSize
{
if
pktLen
>
p
roto
.
P
ktMaxSize
{
return
nil
,
ErrPktTooBig
return
nil
,
ErrPktTooBig
}
}
...
@@ -1171,7 +1174,7 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
...
@@ -1171,7 +1174,7 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
// On success raw connection is returned wrapped into NodeLink.
// On success raw connection is returned wrapped into NodeLink.
// On error raw connection is closed.
// On error raw connection is closed.
func
Handshake
(
ctx
context
.
Context
,
conn
net
.
Conn
,
role
LinkRole
)
(
nl
*
NodeLink
,
err
error
)
{
func
Handshake
(
ctx
context
.
Context
,
conn
net
.
Conn
,
role
LinkRole
)
(
nl
*
NodeLink
,
err
error
)
{
err
=
handshake
(
ctx
,
conn
,
Protocol
Version
)
err
=
handshake
(
ctx
,
conn
,
proto
.
Version
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -1450,21 +1453,21 @@ func (c *Conn) err(op string, e error) error {
...
@@ -1450,21 +1453,21 @@ func (c *Conn) err(op string, e error) error {
// ---- exchange of messages ----
// ---- exchange of messages ----
//trace:event traceMsgRecv(c *Conn, msg Msg)
//trace:event traceMsgRecv(c *Conn, msg
proto.
Msg)
//trace:event traceMsgSendPre(l *NodeLink, connId uint32, msg Msg)
//trace:event traceMsgSendPre(l *NodeLink, connId uint32, msg
proto.
Msg)
// XXX do we also need traceConnSend?
// XXX do we also need traceConnSend?
// msgPack allocates PktBuf and encodes msg into it.
// msgPack allocates PktBuf and encodes msg into it.
func
msgPack
(
connId
uint32
,
msg
Msg
)
*
PktBuf
{
func
msgPack
(
connId
uint32
,
msg
proto
.
Msg
)
*
PktBuf
{
l
:=
msg
.
neo
MsgEncodedLen
()
l
:=
msg
.
NEO
MsgEncodedLen
()
buf
:=
pktAlloc
(
pktHeaderLen
+
l
)
buf
:=
pktAlloc
(
p
roto
.
P
ktHeaderLen
+
l
)
h
:=
buf
.
Header
()
h
:=
buf
.
Header
()
h
.
ConnId
=
h
ton32
(
connId
)
h
.
ConnId
=
packed
.
H
ton32
(
connId
)
h
.
MsgCode
=
hton16
(
msg
.
neo
MsgCode
())
h
.
MsgCode
=
packed
.
Hton16
(
msg
.
NEO
MsgCode
())
h
.
MsgLen
=
h
ton32
(
uint32
(
l
))
// XXX casting: think again
h
.
MsgLen
=
packed
.
H
ton32
(
uint32
(
l
))
// XXX casting: think again
msg
.
neo
MsgEncode
(
buf
.
Payload
())
msg
.
NEO
MsgEncode
(
buf
.
Payload
())
return
buf
return
buf
}
}
...
@@ -1472,7 +1475,7 @@ func msgPack(connId uint32, msg Msg) *PktBuf {
...
@@ -1472,7 +1475,7 @@ func msgPack(connId uint32, msg Msg) *PktBuf {
// Recv receives message
// Recv receives message
// it receives packet and decodes message from it
// it receives packet and decodes message from it
func
(
c
*
Conn
)
Recv
()
(
Msg
,
error
)
{
func
(
c
*
Conn
)
Recv
()
(
proto
.
Msg
,
error
)
{
pkt
,
err
:=
c
.
recvPkt
()
pkt
,
err
:=
c
.
recvPkt
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -1483,11 +1486,11 @@ func (c *Conn) Recv() (Msg, error) {
...
@@ -1483,11 +1486,11 @@ func (c *Conn) Recv() (Msg, error) {
return
msg
,
err
return
msg
,
err
}
}
func
(
c
*
Conn
)
_Recv
(
pkt
*
PktBuf
)
(
Msg
,
error
)
{
func
(
c
*
Conn
)
_Recv
(
pkt
*
PktBuf
)
(
proto
.
Msg
,
error
)
{
// decode packet
// decode packet
pkth
:=
pkt
.
Header
()
pkth
:=
pkt
.
Header
()
msgCode
:=
n
toh16
(
pkth
.
MsgCode
)
msgCode
:=
packed
.
N
toh16
(
pkth
.
MsgCode
)
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
if
msgType
==
nil
{
err
:=
fmt
.
Errorf
(
"invalid msgCode (%d)"
,
msgCode
)
err
:=
fmt
.
Errorf
(
"invalid msgCode (%d)"
,
msgCode
)
// XXX "decode" -> "recv: decode"?
// XXX "decode" -> "recv: decode"?
...
@@ -1495,11 +1498,11 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
...
@@ -1495,11 +1498,11 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
}
}
// TODO use free-list for decoded messages + when possible decode in-place
// TODO use free-list for decoded messages + when possible decode in-place
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
Msg
)
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
proto
.
Msg
)
// msg := reflect.NewAt(msgType, bufAlloc(msgType.Size())
// msg := reflect.NewAt(msgType, bufAlloc(msgType.Size())
_
,
err
:=
msg
.
neo
MsgDecode
(
pkt
.
Payload
())
_
,
err
:=
msg
.
NEO
MsgDecode
(
pkt
.
Payload
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
c
.
err
(
"decode"
,
err
)
// XXX "decode:" is already in ErrDecodeOverflow
return
nil
,
c
.
err
(
"decode"
,
err
)
// XXX "decode:" is already in ErrDecodeOverflow
}
}
...
@@ -1513,7 +1516,7 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
...
@@ -1513,7 +1516,7 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
// it encodes message int packet, sets header appropriately and sends it.
// it encodes message int packet, sets header appropriately and sends it.
//
//
// it is ok to call sendMsg in parallel with serveSend. XXX link to sendPktDirect for rationale?
// it is ok to call sendMsg in parallel with serveSend. XXX link to sendPktDirect for rationale?
func
(
link
*
NodeLink
)
sendMsg
(
connId
uint32
,
msg
Msg
)
error
{
func
(
link
*
NodeLink
)
sendMsg
(
connId
uint32
,
msg
proto
.
Msg
)
error
{
traceMsgSendPre
(
link
,
connId
,
msg
)
traceMsgSendPre
(
link
,
connId
,
msg
)
buf
:=
msgPack
(
connId
,
msg
)
buf
:=
msgPack
(
connId
,
msg
)
...
@@ -1524,14 +1527,14 @@ func (link *NodeLink) sendMsg(connId uint32, msg Msg) error {
...
@@ -1524,14 +1527,14 @@ func (link *NodeLink) sendMsg(connId uint32, msg Msg) error {
// Send sends message.
// Send sends message.
//
//
// it encodes message into packet and sends it.
// it encodes message into packet and sends it.
func
(
c
*
Conn
)
Send
(
msg
Msg
)
error
{
func
(
c
*
Conn
)
Send
(
msg
proto
.
Msg
)
error
{
traceMsgSendPre
(
c
.
link
,
c
.
connId
,
msg
)
traceMsgSendPre
(
c
.
link
,
c
.
connId
,
msg
)
buf
:=
msgPack
(
c
.
connId
,
msg
)
buf
:=
msgPack
(
c
.
connId
,
msg
)
return
c
.
sendPkt
(
buf
)
// XXX more context in err? (msg type)
return
c
.
sendPkt
(
buf
)
// XXX more context in err? (msg type)
}
}
func
(
c
*
Conn
)
sendMsgDirect
(
msg
Msg
)
error
{
func
(
c
*
Conn
)
sendMsgDirect
(
msg
proto
.
Msg
)
error
{
return
c
.
link
.
sendMsg
(
c
.
connId
,
msg
)
return
c
.
link
.
sendMsg
(
c
.
connId
,
msg
)
}
}
...
@@ -1542,7 +1545,7 @@ func (c *Conn) sendMsgDirect(msg Msg) error {
...
@@ -1542,7 +1545,7 @@ func (c *Conn) sendMsgDirect(msg Msg) error {
// which indicates index of received message.
// which indicates index of received message.
//
//
// on error (-1, err) is returned
// on error (-1, err) is returned
func
(
c
*
Conn
)
Expect
(
msgv
...
Msg
)
(
which
int
,
err
error
)
{
func
(
c
*
Conn
)
Expect
(
msgv
...
proto
.
Msg
)
(
which
int
,
err
error
)
{
// XXX a bit dup wrt Recv
// XXX a bit dup wrt Recv
pkt
,
err
:=
c
.
recvPkt
()
pkt
,
err
:=
c
.
recvPkt
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -1554,13 +1557,13 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) {
...
@@ -1554,13 +1557,13 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) {
return
which
,
err
return
which
,
err
}
}
func
(
c
*
Conn
)
_Expect
(
pkt
*
PktBuf
,
msgv
...
Msg
)
(
int
,
error
)
{
func
(
c
*
Conn
)
_Expect
(
pkt
*
PktBuf
,
msgv
...
proto
.
Msg
)
(
int
,
error
)
{
pkth
:=
pkt
.
Header
()
pkth
:=
pkt
.
Header
()
msgCode
:=
n
toh16
(
pkth
.
MsgCode
)
msgCode
:=
packed
.
N
toh16
(
pkth
.
MsgCode
)
for
i
,
msg
:=
range
msgv
{
for
i
,
msg
:=
range
msgv
{
if
msg
.
neo
MsgCode
()
==
msgCode
{
if
msg
.
NEO
MsgCode
()
==
msgCode
{
_
,
err
:=
msg
.
neo
MsgDecode
(
pkt
.
Payload
())
_
,
err
:=
msg
.
NEO
MsgDecode
(
pkt
.
Payload
())
if
err
!=
nil
{
if
err
!=
nil
{
return
-
1
,
c
.
err
(
"decode"
,
err
)
return
-
1
,
c
.
err
(
"decode"
,
err
)
}
}
...
@@ -1569,7 +1572,7 @@ func (c *Conn) _Expect(pkt *PktBuf, msgv ...Msg) (int, error) {
...
@@ -1569,7 +1572,7 @@ func (c *Conn) _Expect(pkt *PktBuf, msgv ...Msg) (int, error) {
}
}
// unexpected message
// unexpected message
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
if
msgType
==
nil
{
return
-
1
,
c
.
err
(
"decode"
,
fmt
.
Errorf
(
"invalid msgCode (%d)"
,
msgCode
))
return
-
1
,
c
.
err
(
"decode"
,
fmt
.
Errorf
(
"invalid msgCode (%d)"
,
msgCode
))
}
}
...
@@ -1583,19 +1586,19 @@ func (c *Conn) _Expect(pkt *PktBuf, msgv ...Msg) (int, error) {
...
@@ -1583,19 +1586,19 @@ func (c *Conn) _Expect(pkt *PktBuf, msgv ...Msg) (int, error) {
// It expects response to be exactly of resp type and errors otherwise
// It expects response to be exactly of resp type and errors otherwise
// XXX clarify error semantic (when Error is decoded)
// XXX clarify error semantic (when Error is decoded)
// XXX do the same as Expect wrt respv ?
// XXX do the same as Expect wrt respv ?
func
(
c
*
Conn
)
Ask
(
req
Msg
,
resp
Msg
)
error
{
func
(
c
*
Conn
)
Ask
(
req
proto
.
Msg
,
resp
proto
.
Msg
)
error
{
err
:=
c
.
Send
(
req
)
err
:=
c
.
Send
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
nerr
:=
&
Error
{}
nerr
:=
&
proto
.
Error
{}
which
,
err
:=
c
.
Expect
(
resp
,
nerr
)
which
,
err
:=
c
.
Expect
(
resp
,
nerr
)
switch
which
{
switch
which
{
case
0
:
case
0
:
return
nil
return
nil
case
1
:
case
1
:
return
ErrDecode
(
nerr
)
return
proto
.
ErrDecode
(
nerr
)
}
}
return
err
return
err
...
@@ -1637,7 +1640,7 @@ func (c *Conn) lightClose() {
...
@@ -1637,7 +1640,7 @@ func (c *Conn) lightClose() {
//
//
// Request represents 1 request - 0|1 reply interaction model XXX
// Request represents 1 request - 0|1 reply interaction model XXX
type
Request
struct
{
type
Request
struct
{
Msg
Msg
Msg
proto
.
Msg
conn
*
Conn
conn
*
Conn
}
}
...
@@ -1668,7 +1671,7 @@ func (link *NodeLink) Recv1() (Request, error) {
...
@@ -1668,7 +1671,7 @@ func (link *NodeLink) Recv1() (Request, error) {
// Reply sends response to request.
// Reply sends response to request.
//
//
// XXX doc
// XXX doc
func
(
req
*
Request
)
Reply
(
resp
Msg
)
error
{
func
(
req
*
Request
)
Reply
(
resp
proto
.
Msg
)
error
{
return
req
.
conn
.
sendMsgDirect
(
resp
)
return
req
.
conn
.
sendMsgDirect
(
resp
)
//err1 := req.conn.Send(resp)
//err1 := req.conn.Send(resp)
//err2 := req.conn.Close() // XXX no - only Send here?
//err2 := req.conn.Close() // XXX no - only Send here?
...
@@ -1690,7 +1693,7 @@ func (req *Request) Close() { // XXX +error?
...
@@ -1690,7 +1693,7 @@ func (req *Request) Close() { // XXX +error?
// Send1 sends one message over link.
// Send1 sends one message over link.
//
//
// XXX doc
// XXX doc
func
(
link
*
NodeLink
)
Send1
(
msg
Msg
)
error
{
func
(
link
*
NodeLink
)
Send1
(
msg
proto
.
Msg
)
error
{
conn
,
err
:=
link
.
NewConn
()
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -1708,7 +1711,7 @@ func (link *NodeLink) Send1(msg Msg) error {
...
@@ -1708,7 +1711,7 @@ func (link *NodeLink) Send1(msg Msg) error {
//
//
// See Conn.Ask for semantic details.
// See Conn.Ask for semantic details.
// XXX doc
// XXX doc
func
(
link
*
NodeLink
)
Ask1
(
req
Msg
,
resp
Msg
)
(
err
error
)
{
func
(
link
*
NodeLink
)
Ask1
(
req
proto
.
Msg
,
resp
proto
.
Msg
)
(
err
error
)
{
conn
,
err
:=
link
.
NewConn
()
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -1720,19 +1723,19 @@ func (link *NodeLink) Ask1(req Msg, resp Msg) (err error) {
...
@@ -1720,19 +1723,19 @@ func (link *NodeLink) Ask1(req Msg, resp Msg) (err error) {
return
err
return
err
}
}
func
(
conn
*
Conn
)
_Ask1
(
req
Msg
,
resp
Msg
)
error
{
func
(
conn
*
Conn
)
_Ask1
(
req
proto
.
Msg
,
resp
proto
.
Msg
)
error
{
err
:=
conn
.
sendMsgDirect
(
req
)
err
:=
conn
.
sendMsgDirect
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
nerr
:=
&
Error
{}
nerr
:=
&
proto
.
Error
{}
which
,
err
:=
conn
.
Expect
(
resp
,
nerr
)
which
,
err
:=
conn
.
Expect
(
resp
,
nerr
)
switch
which
{
switch
which
{
case
0
:
case
0
:
return
nil
return
nil
case
1
:
case
1
:
return
ErrDecode
(
nerr
)
return
proto
.
ErrDecode
(
nerr
)
}
}
return
err
return
err
...
...
go/neo/connection_test.go
View file @
47f069a5
...
@@ -35,7 +35,10 @@ import (
...
@@ -35,7 +35,10 @@ import (
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"github.com/kylelemons/godebug/pretty"
"github.com/kylelemons/godebug/pretty"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -103,11 +106,11 @@ func xconnError(err error) error {
...
@@ -103,11 +106,11 @@ func xconnError(err error) error {
// Prepare PktBuf with content
// Prepare PktBuf with content
func
_mkpkt
(
connid
uint32
,
msgcode
uint16
,
payload
[]
byte
)
*
PktBuf
{
func
_mkpkt
(
connid
uint32
,
msgcode
uint16
,
payload
[]
byte
)
*
PktBuf
{
pkt
:=
&
PktBuf
{
make
([]
byte
,
pktHeaderLen
+
len
(
payload
))}
pkt
:=
&
PktBuf
{
make
([]
byte
,
p
roto
.
P
ktHeaderLen
+
len
(
payload
))}
h
:=
pkt
.
Header
()
h
:=
pkt
.
Header
()
h
.
ConnId
=
h
ton32
(
connid
)
h
.
ConnId
=
packed
.
H
ton32
(
connid
)
h
.
MsgCode
=
h
ton16
(
msgcode
)
h
.
MsgCode
=
packed
.
H
ton16
(
msgcode
)
h
.
MsgLen
=
h
ton32
(
uint32
(
len
(
payload
)))
h
.
MsgLen
=
packed
.
H
ton32
(
uint32
(
len
(
payload
)))
copy
(
pkt
.
Payload
(),
payload
)
copy
(
pkt
.
Payload
(),
payload
)
return
pkt
return
pkt
}
}
...
@@ -122,14 +125,14 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
...
@@ -122,14 +125,14 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
errv
:=
xerr
.
Errorv
{}
errv
:=
xerr
.
Errorv
{}
h
:=
pkt
.
Header
()
h
:=
pkt
.
Header
()
// TODO include caller location
// TODO include caller location
if
n
toh32
(
h
.
ConnId
)
!=
connid
{
if
packed
.
N
toh32
(
h
.
ConnId
)
!=
connid
{
errv
.
Appendf
(
"header: unexpected connid %v (want %v)"
,
n
toh32
(
h
.
ConnId
),
connid
)
errv
.
Appendf
(
"header: unexpected connid %v (want %v)"
,
packed
.
N
toh32
(
h
.
ConnId
),
connid
)
}
}
if
n
toh16
(
h
.
MsgCode
)
!=
msgcode
{
if
packed
.
N
toh16
(
h
.
MsgCode
)
!=
msgcode
{
errv
.
Appendf
(
"header: unexpected msgcode %v (want %v)"
,
n
toh16
(
h
.
MsgCode
),
msgcode
)
errv
.
Appendf
(
"header: unexpected msgcode %v (want %v)"
,
packed
.
N
toh16
(
h
.
MsgCode
),
msgcode
)
}
}
if
n
toh32
(
h
.
MsgLen
)
!=
uint32
(
len
(
payload
))
{
if
packed
.
N
toh32
(
h
.
MsgLen
)
!=
uint32
(
len
(
payload
))
{
errv
.
Appendf
(
"header: unexpected msglen %v (want %v)"
,
n
toh32
(
h
.
MsgLen
),
len
(
payload
))
errv
.
Appendf
(
"header: unexpected msglen %v (want %v)"
,
packed
.
N
toh32
(
h
.
MsgLen
),
len
(
payload
))
}
}
if
!
bytes
.
Equal
(
pkt
.
Payload
(),
payload
)
{
if
!
bytes
.
Equal
(
pkt
.
Payload
(),
payload
)
{
errv
.
Appendf
(
"payload differ:
\n
%s"
,
errv
.
Appendf
(
"payload differ:
\n
%s"
,
...
@@ -140,10 +143,10 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
...
@@ -140,10 +143,10 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
}
}
// Verify PktBuf to match expected message
// Verify PktBuf to match expected message
func
xverifyPktMsg
(
pkt
*
PktBuf
,
connid
uint32
,
msg
Msg
)
{
func
xverifyPktMsg
(
pkt
*
PktBuf
,
connid
uint32
,
msg
proto
.
Msg
)
{
data
:=
make
([]
byte
,
msg
.
neo
MsgEncodedLen
())
data
:=
make
([]
byte
,
msg
.
NEO
MsgEncodedLen
())
msg
.
neo
MsgEncode
(
data
)
msg
.
NEO
MsgEncode
(
data
)
xverifyPkt
(
pkt
,
connid
,
msg
.
neo
MsgCode
(),
data
)
xverifyPkt
(
pkt
,
connid
,
msg
.
NEO
MsgCode
(),
data
)
}
}
// delay a bit
// delay a bit
...
@@ -625,7 +628,7 @@ func TestNodeLink(t *testing.T) {
...
@@ -625,7 +628,7 @@ func TestNodeLink(t *testing.T) {
gox
(
wg
,
func
()
{
gox
(
wg
,
func
()
{
pkt
:=
xrecvPkt
(
c
)
pkt
:=
xrecvPkt
(
c
)
n
:=
n
toh16
(
pkt
.
Header
()
.
MsgCode
)
n
:=
packed
.
N
toh16
(
pkt
.
Header
()
.
MsgCode
)
x
:=
replyOrder
[
n
]
x
:=
replyOrder
[
n
]
// wait before it is our turn & echo pkt back
// wait before it is our turn & echo pkt back
...
@@ -743,12 +746,12 @@ func TestHandshake(t *testing.T) {
...
@@ -743,12 +746,12 @@ func TestHandshake(t *testing.T) {
// ---- recv1 mode ----
// ---- recv1 mode ----
func
xSend
(
c
*
Conn
,
msg
Msg
)
{
func
xSend
(
c
*
Conn
,
msg
proto
.
Msg
)
{
err
:=
c
.
Send
(
msg
)
err
:=
c
.
Send
(
msg
)
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
}
}
func
xRecv
(
c
*
Conn
)
Msg
{
func
xRecv
(
c
*
Conn
)
proto
.
Msg
{
msg
,
err
:=
c
.
Recv
()
msg
,
err
:=
c
.
Recv
()
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
return
msg
return
msg
...
@@ -760,12 +763,12 @@ func xRecv1(l *NodeLink) Request {
...
@@ -760,12 +763,12 @@ func xRecv1(l *NodeLink) Request {
return
req
return
req
}
}
func
xSend1
(
l
*
NodeLink
,
msg
Msg
)
{
func
xSend1
(
l
*
NodeLink
,
msg
proto
.
Msg
)
{
err
:=
l
.
Send1
(
msg
)
err
:=
l
.
Send1
(
msg
)
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
}
}
func
xverifyMsg
(
msg1
,
msg2
Msg
)
{
func
xverifyMsg
(
msg1
,
msg2
proto
.
Msg
)
{
if
!
reflect
.
DeepEqual
(
msg1
,
msg2
)
{
if
!
reflect
.
DeepEqual
(
msg1
,
msg2
)
{
exc
.
Raisef
(
"messages differ:
\n
%s"
,
pretty
.
Compare
(
msg1
,
msg2
))
exc
.
Raisef
(
"messages differ:
\n
%s"
,
pretty
.
Compare
(
msg1
,
msg2
))
}
}
...
@@ -789,8 +792,8 @@ func TestRecv1Mode(t *testing.T) {
...
@@ -789,8 +792,8 @@ func TestRecv1Mode(t *testing.T) {
//println("X aaa + 1")
//println("X aaa + 1")
msg
:=
xRecv
(
c
)
msg
:=
xRecv
(
c
)
//println("X aaa + 2")
//println("X aaa + 2")
xverifyMsg
(
msg
,
&
Ping
{})
xverifyMsg
(
msg
,
&
proto
.
Ping
{})
xSend
(
c
,
&
Pong
{})
xSend
(
c
,
&
proto
.
Pong
{})
//println("X aaa + 3")
//println("X aaa + 3")
msg
=
xRecv
(
c
)
msg
=
xRecv
(
c
)
//println("X aaa + 4")
//println("X aaa + 4")
...
@@ -803,8 +806,8 @@ func TestRecv1Mode(t *testing.T) {
...
@@ -803,8 +806,8 @@ func TestRecv1Mode(t *testing.T) {
c
=
xaccept
(
nl2
)
c
=
xaccept
(
nl2
)
msg
=
xRecv
(
c
)
msg
=
xRecv
(
c
)
//fmt.Println("X zzz + 1", c, msg)
//fmt.Println("X zzz + 1", c, msg)
xverifyMsg
(
msg
,
&
Error
{
ACK
,
"hello up there"
})
xverifyMsg
(
msg
,
&
proto
.
Error
{
proto
.
ACK
,
"hello up there"
})
xSend
(
c
,
&
Error
{
ACK
,
"hello to you too"
})
xSend
(
c
,
&
proto
.
Error
{
proto
.
ACK
,
"hello to you too"
})
msg
=
xRecv
(
c
)
msg
=
xRecv
(
c
)
//println("X zzz + 2")
//println("X zzz + 2")
xverifyMsg
(
msg
,
errConnClosed
)
xverifyMsg
(
msg
,
errConnClosed
)
...
@@ -813,14 +816,14 @@ func TestRecv1Mode(t *testing.T) {
...
@@ -813,14 +816,14 @@ func TestRecv1Mode(t *testing.T) {
})
})
//println("aaa")
//println("aaa")
xSend1
(
nl1
,
&
Ping
{})
xSend1
(
nl1
,
&
proto
.
Ping
{})
// before next Send1 wait till peer receives errConnClosed from us
// before next Send1 wait till peer receives errConnClosed from us
// otherwise peer could be already in accept while our errConnClosed is received
// otherwise peer could be already in accept while our errConnClosed is received
// and there is only one receiving thread there ^^^
// and there is only one receiving thread there ^^^
<-
sync
<-
sync
//println("bbb")
//println("bbb")
xSend1
(
nl1
,
&
Error
{
ACK
,
"hello up there"
})
xSend1
(
nl1
,
&
proto
.
Error
{
proto
.
ACK
,
"hello up there"
})
//println("ccc")
//println("ccc")
xwait
(
wg
)
xwait
(
wg
)
...
@@ -832,9 +835,9 @@ func TestRecv1Mode(t *testing.T) {
...
@@ -832,9 +835,9 @@ func TestRecv1Mode(t *testing.T) {
c
:=
xnewconn
(
nl2
)
c
:=
xnewconn
(
nl2
)
//println("aaa")
//println("aaa")
xSend
(
c
,
&
Ping
{})
xSend
(
c
,
&
proto
.
Ping
{})
//println("bbb")
//println("bbb")
xSend
(
c
,
&
Ping
{})
xSend
(
c
,
&
proto
.
Ping
{})
//println("ccc")
//println("ccc")
msg
:=
xRecv
(
c
)
msg
:=
xRecv
(
c
)
//println("ddd")
//println("ddd")
...
@@ -1158,8 +1161,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
...
@@ -1158,8 +1161,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
default
:
default
:
b
.
Fatalf
(
"read -> unexpected message %T"
,
msg
)
b
.
Fatalf
(
"read -> unexpected message %T"
,
msg
)
case
*
GetObject
:
case
*
proto
.
GetObject
:
err
=
req
.
Reply
(
&
AnswerObject
{
err
=
req
.
Reply
(
&
proto
.
AnswerObject
{
Oid
:
msg
.
Oid
,
Oid
:
msg
.
Oid
,
Serial
:
msg
.
Serial
,
Serial
:
msg
.
Serial
,
DataSerial
:
msg
.
Tid
,
DataSerial
:
msg
.
Tid
,
...
@@ -1175,8 +1178,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
...
@@ -1175,8 +1178,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
// NOTE keeping inside loop to simulate what happens in real Load
// NOTE keeping inside loop to simulate what happens in real Load
get
:=
&
GetObject
{}
get
:=
&
proto
.
GetObject
{}
obj
:=
&
AnswerObject
{}
obj
:=
&
proto
.
AnswerObject
{}
get
.
Oid
=
zodb
.
Oid
(
i
)
get
.
Oid
=
zodb
.
Oid
(
i
)
get
.
Serial
=
zodb
.
Tid
(
i
+
1
)
get
.
Serial
=
zodb
.
Tid
(
i
+
1
)
...
...
go/neo/neo.go
View file @
47f069a5
...
@@ -38,26 +38,15 @@ import (
...
@@ -38,26 +38,15 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
//"lab.nexedi.com/kirr/neo/go/xcommon/xio"
//"lab.nexedi.com/kirr/neo/go/xcommon/xio"
"lab.nexedi.com/kirr/neo/go/zodb"
)
const
(
//INVALID_UUID UUID = 0
// XXX -> zodb?
"lab.nexedi.com/kirr/neo/go/neo/proto"
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
// OID_LEN = 8
// TID_LEN = 8
)
)
// NodeApp is base for implementing NEO node applications.
// NodeApp is base for implementing NEO node applications.
//
//
// XXX -> internal?
// XXX -> internal?
type
NodeApp
struct
{
type
NodeApp
struct
{
MyInfo
NodeInfo
MyInfo
proto
.
NodeInfo
ClusterName
string
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
Net
xnet
.
Networker
// network AP we are sending/receiving on
...
@@ -66,22 +55,22 @@ type NodeApp struct {
...
@@ -66,22 +55,22 @@ type NodeApp struct {
StateMu
sync
.
RWMutex
// <- XXX just embed?
StateMu
sync
.
RWMutex
// <- XXX just embed?
NodeTab
*
NodeTable
// information about nodes in the cluster
NodeTab
*
NodeTable
// information about nodes in the cluster
PartTab
*
PartitionTable
// information about data distribution in the cluster
PartTab
*
PartitionTable
// information about data distribution in the cluster
ClusterState
ClusterState
// master idea about cluster state
ClusterState
proto
.
ClusterState
// master idea about cluster state
// should be set by user so NodeApp can notify when master tells this node to shutdown
// should be set by user so NodeApp can notify when master tells this node to shutdown
OnShutdown
func
()
OnShutdown
func
()
}
}
// NewNodeApp creates new node application
// NewNodeApp creates new node application
func
NewNodeApp
(
net
xnet
.
Networker
,
typ
NodeType
,
clusterName
,
masterAddr
,
serveAddr
string
)
*
NodeApp
{
func
NewNodeApp
(
net
xnet
.
Networker
,
typ
proto
.
NodeType
,
clusterName
,
masterAddr
,
serveAddr
string
)
*
NodeApp
{
// convert serveAddr into neo format
// convert serveAddr into neo format
addr
,
err
:=
AddrString
(
net
.
Network
(),
serveAddr
)
addr
,
err
:=
proto
.
AddrString
(
net
.
Network
(),
serveAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
// XXX
panic
(
err
)
// XXX
}
}
app
:=
&
NodeApp
{
app
:=
&
NodeApp
{
MyInfo
:
NodeInfo
{
Type
:
typ
,
Addr
:
addr
,
IdTime
:
IdTimeNone
},
MyInfo
:
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
addr
,
IdTime
:
proto
.
IdTimeNone
},
ClusterName
:
clusterName
,
ClusterName
:
clusterName
,
Net
:
net
,
Net
:
net
,
MasterAddr
:
masterAddr
,
MasterAddr
:
masterAddr
,
...
@@ -103,7 +92,7 @@ func NewNodeApp(net xnet.Networker, typ NodeType, clusterName, masterAddr, serve
...
@@ -103,7 +92,7 @@ func NewNodeApp(net xnet.Networker, typ NodeType, clusterName, masterAddr, serve
//
//
// Dial does not update .NodeTab or its node entries in any way.
// Dial does not update .NodeTab or its node entries in any way.
// For establishing links to peers present in .NodeTab use Node.Dial.
// For establishing links to peers present in .NodeTab use Node.Dial.
func
(
app
*
NodeApp
)
Dial
(
ctx
context
.
Context
,
peerType
NodeType
,
addr
string
)
(
_
*
NodeLink
,
_
*
AcceptIdentification
,
err
error
)
{
func
(
app
*
NodeApp
)
Dial
(
ctx
context
.
Context
,
peerType
proto
.
NodeType
,
addr
string
)
(
_
*
NodeLink
,
_
*
proto
.
AcceptIdentification
,
err
error
)
{
defer
task
.
Runningf
(
&
ctx
,
"dial %v (%v)"
,
addr
,
peerType
)(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"dial %v (%v)"
,
addr
,
peerType
)(
&
err
)
link
,
err
:=
DialLink
(
ctx
,
app
.
Net
,
addr
)
link
,
err
:=
DialLink
(
ctx
,
app
.
Net
,
addr
)
...
@@ -125,14 +114,14 @@ func (app *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_
...
@@ -125,14 +114,14 @@ func (app *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_
}
}
}()
}()
req
:=
&
RequestIdentification
{
req
:=
&
proto
.
RequestIdentification
{
NodeType
:
app
.
MyInfo
.
Type
,
NodeType
:
app
.
MyInfo
.
Type
,
UUID
:
app
.
MyInfo
.
UUID
,
UUID
:
app
.
MyInfo
.
UUID
,
Address
:
app
.
MyInfo
.
Addr
,
Address
:
app
.
MyInfo
.
Addr
,
ClusterName
:
app
.
ClusterName
,
ClusterName
:
app
.
ClusterName
,
IdTime
:
app
.
MyInfo
.
IdTime
,
// XXX ok?
IdTime
:
app
.
MyInfo
.
IdTime
,
// XXX ok?
}
}
accept
:=
&
AcceptIdentification
{}
accept
:=
&
proto
.
AcceptIdentification
{}
// FIXME error if peer sends us something with another connID
// FIXME error if peer sends us something with another connID
// (currently we ignore and serveRecv will deadlock)
// (currently we ignore and serveRecv will deadlock)
//
//
...
@@ -179,7 +168,7 @@ func (app *NodeApp) Listen() (Listener, error) {
...
@@ -179,7 +168,7 @@ func (app *NodeApp) Listen() (Listener, error) {
// NOTE listen("tcp", ":1234") gives l.Addr 0.0.0.0:1234 and
// NOTE listen("tcp", ":1234") gives l.Addr 0.0.0.0:1234 and
// listen("tcp6", ":1234") gives l.Addr [::]:1234
// listen("tcp6", ":1234") gives l.Addr [::]:1234
// -> host is never empty
// -> host is never empty
addr
,
err
:=
Addr
(
ll
.
Addr
())
addr
,
err
:=
proto
.
Addr
(
ll
.
Addr
())
if
err
!=
nil
{
if
err
!=
nil
{
// XXX -> panic here ?
// XXX -> panic here ?
ll
.
Close
()
ll
.
Close
()
...
@@ -216,7 +205,7 @@ type Listener interface {
...
@@ -216,7 +205,7 @@ type Listener interface {
// After successful accept it is the caller responsibility to reply the request.
// After successful accept it is the caller responsibility to reply the request.
//
//
// NOTE established link is Request.Link().
// NOTE established link is Request.Link().
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
RequestIdentification
,
error
)
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
proto
.
RequestIdentification
,
error
)
}
}
type
listener
struct
{
type
listener
struct
{
...
@@ -227,7 +216,7 @@ type listener struct {
...
@@ -227,7 +216,7 @@ type listener struct {
type
accepted
struct
{
type
accepted
struct
{
req
*
Request
req
*
Request
idReq
*
RequestIdentification
idReq
*
proto
.
RequestIdentification
err
error
err
error
}
}
...
@@ -284,7 +273,7 @@ func (l *listener) accept(link *NodeLink, err error) {
...
@@ -284,7 +273,7 @@ func (l *listener) accept(link *NodeLink, err error) {
}
}
}
}
func
(
l
*
listener
)
accept1
(
ctx
context
.
Context
,
link
*
NodeLink
,
err0
error
)
(
_
*
Request
,
_
*
RequestIdentification
,
err
error
)
{
func
(
l
*
listener
)
accept1
(
ctx
context
.
Context
,
link
*
NodeLink
,
err0
error
)
(
_
*
Request
,
_
*
proto
.
RequestIdentification
,
err
error
)
{
if
err0
!=
nil
{
if
err0
!=
nil
{
return
nil
,
nil
,
err0
return
nil
,
nil
,
err0
}
}
...
@@ -299,16 +288,16 @@ func (l *listener) accept1(ctx context.Context, link *NodeLink, err0 error) (_ *
...
@@ -299,16 +288,16 @@ func (l *listener) accept1(ctx context.Context, link *NodeLink, err0 error) (_ *
}
}
switch
msg
:=
req
.
Msg
.
(
type
)
{
switch
msg
:=
req
.
Msg
.
(
type
)
{
case
*
RequestIdentification
:
case
*
proto
.
RequestIdentification
:
return
&
req
,
msg
,
nil
return
&
req
,
msg
,
nil
}
}
emsg
:=
&
Error
{
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
.
Msg
)}
emsg
:=
&
proto
.
Error
{
proto
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
.
Msg
)}
req
.
Reply
(
emsg
)
// XXX err
req
.
Reply
(
emsg
)
// XXX err
return
nil
,
nil
,
emsg
return
nil
,
nil
,
emsg
}
}
func
(
l
*
listener
)
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
RequestIdentification
,
error
)
{
func
(
l
*
listener
)
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
proto
.
RequestIdentification
,
error
)
{
select
{
select
{
case
<-
l
.
closed
:
case
<-
l
.
closed
:
// we know raw listener is already closed - return proper error about it
// we know raw listener is already closed - return proper error about it
...
@@ -330,7 +319,7 @@ func (l *listener) Addr() net.Addr {
...
@@ -330,7 +319,7 @@ func (l *listener) Addr() net.Addr {
// ----------------------------------------
// ----------------------------------------
// UpdateNodeTab applies updates to .NodeTab from message and logs changes appropriately.
// UpdateNodeTab applies updates to .NodeTab from message and logs changes appropriately.
func
(
app
*
NodeApp
)
UpdateNodeTab
(
ctx
context
.
Context
,
msg
*
NotifyNodeInformation
)
{
func
(
app
*
NodeApp
)
UpdateNodeTab
(
ctx
context
.
Context
,
msg
*
proto
.
NotifyNodeInformation
)
{
// XXX msg.IdTime ?
// XXX msg.IdTime ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"node update: %v"
,
nodeInfo
)
log
.
Infof
(
ctx
,
"node update: %v"
,
nodeInfo
)
...
@@ -344,7 +333,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
...
@@ -344,7 +333,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
app
.
MyInfo
.
IdTime
=
nodeInfo
.
IdTime
app
.
MyInfo
.
IdTime
=
nodeInfo
.
IdTime
// FIXME hack - better it be separate command and handled cleanly
// FIXME hack - better it be separate command and handled cleanly
if
nodeInfo
.
State
==
DOWN
{
if
nodeInfo
.
State
==
proto
.
DOWN
{
log
.
Info
(
ctx
,
"master told us to shutdown"
)
log
.
Info
(
ctx
,
"master told us to shutdown"
)
log
.
Flush
()
log
.
Flush
()
app
.
OnShutdown
()
app
.
OnShutdown
()
...
@@ -359,7 +348,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
...
@@ -359,7 +348,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
}
}
// UpdatePartTab applies updates to .PartTab from message and logs changes appropriately.
// UpdatePartTab applies updates to .PartTab from message and logs changes appropriately.
func
(
app
*
NodeApp
)
UpdatePartTab
(
ctx
context
.
Context
,
msg
*
SendPartitionTable
)
{
func
(
app
*
NodeApp
)
UpdatePartTab
(
ctx
context
.
Context
,
msg
*
proto
.
SendPartitionTable
)
{
pt
:=
PartTabFromDump
(
msg
.
PTid
,
msg
.
RowList
)
pt
:=
PartTabFromDump
(
msg
.
PTid
,
msg
.
RowList
)
// XXX logging under lock
// XXX logging under lock
log
.
Infof
(
ctx
,
"parttab update: %v"
,
pt
)
log
.
Infof
(
ctx
,
"parttab update: %v"
,
pt
)
...
@@ -367,7 +356,7 @@ func (app *NodeApp) UpdatePartTab(ctx context.Context, msg *SendPartitionTable)
...
@@ -367,7 +356,7 @@ func (app *NodeApp) UpdatePartTab(ctx context.Context, msg *SendPartitionTable)
}
}
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
func
(
app
*
NodeApp
)
UpdateClusterState
(
ctx
context
.
Context
,
msg
*
NotifyClusterState
)
{
func
(
app
*
NodeApp
)
UpdateClusterState
(
ctx
context
.
Context
,
msg
*
proto
.
NotifyClusterState
)
{
// XXX loging under lock
// XXX loging under lock
log
.
Infof
(
ctx
,
"state update: %v"
,
msg
.
State
)
log
.
Infof
(
ctx
,
"state update: %v"
,
msg
.
State
)
app
.
ClusterState
.
Set
(
msg
.
State
)
app
.
ClusterState
.
Set
(
msg
.
State
)
...
...
go/neo/nodetab.go
View file @
47f069a5
...
@@ -27,6 +27,8 @@ import (
...
@@ -27,6 +27,8 @@ import (
"sync"
"sync"
"time"
"time"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
)
)
...
@@ -67,7 +69,7 @@ type NodeTable struct {
...
@@ -67,7 +69,7 @@ type NodeTable struct {
//storv []*Node // storages
//storv []*Node // storages
nodev
[]
*
Node
// all other nodes
nodev
[]
*
Node
// all other nodes
notifyv
[]
chan
NodeInfo
// subscribers
notifyv
[]
chan
proto
.
NodeInfo
// subscribers
}
}
//trace:event traceNodeChanged(nt *NodeTable, n *Node)
//trace:event traceNodeChanged(nt *NodeTable, n *Node)
...
@@ -78,7 +80,7 @@ type NodeTable struct {
...
@@ -78,7 +80,7 @@ type NodeTable struct {
type
Node
struct
{
type
Node
struct
{
nodeTab
*
NodeTable
// this node is part of
nodeTab
*
NodeTable
// this node is part of
NodeInfo
// .type, .addr, .uuid, ... XXX also protect by mu?
proto
.
NodeInfo
// .type, .addr, .uuid, ... XXX also protect by mu?
linkMu
sync
.
Mutex
linkMu
sync
.
Mutex
link
*
NodeLink
// link to this peer; nil if not connected
link
*
NodeLink
// link to this peer; nil if not connected
...
@@ -115,7 +117,7 @@ func (nt *NodeTable) All() []*Node {
...
@@ -115,7 +117,7 @@ func (nt *NodeTable) All() []*Node {
}
}
// Get finds node by uuid.
// Get finds node by uuid.
func
(
nt
*
NodeTable
)
Get
(
uuid
NodeUUID
)
*
Node
{
func
(
nt
*
NodeTable
)
Get
(
uuid
proto
.
NodeUUID
)
*
Node
{
// FIXME linear scan
// FIXME linear scan
for
_
,
node
:=
range
nt
.
nodev
{
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
UUID
==
uuid
{
if
node
.
UUID
==
uuid
{
...
@@ -130,7 +132,7 @@ func (nt *NodeTable) Get(uuid NodeUUID) *Node {
...
@@ -130,7 +132,7 @@ func (nt *NodeTable) Get(uuid NodeUUID) *Node {
// Update updates information about a node.
// Update updates information about a node.
//
//
// it returns corresponding node entry for convenience.
// it returns corresponding node entry for convenience.
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
NodeInfo
)
*
Node
{
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
proto
.
NodeInfo
)
*
Node
{
node
:=
nt
.
Get
(
nodeInfo
.
UUID
)
node
:=
nt
.
Get
(
nodeInfo
.
UUID
)
if
node
==
nil
{
if
node
==
nil
{
node
=
&
Node
{
nodeTab
:
nt
}
node
=
&
Node
{
nodeTab
:
nt
}
...
@@ -156,7 +158,7 @@ func (nt *NodeTable) StorageList() []*Node {
...
@@ -156,7 +158,7 @@ func (nt *NodeTable) StorageList() []*Node {
// FIXME linear scan
// FIXME linear scan
sl
:=
[]
*
Node
{}
sl
:=
[]
*
Node
{}
for
_
,
node
:=
range
nt
.
nodev
{
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
Type
==
STORAGE
{
if
node
.
Type
==
proto
.
STORAGE
{
sl
=
append
(
sl
,
node
)
sl
=
append
(
sl
,
node
)
}
}
}
}
...
@@ -165,7 +167,7 @@ func (nt *NodeTable) StorageList() []*Node {
...
@@ -165,7 +167,7 @@ func (nt *NodeTable) StorageList() []*Node {
// XXX doc
// XXX doc
func
(
n
*
Node
)
SetState
(
state
NodeState
)
{
func
(
n
*
Node
)
SetState
(
state
proto
.
NodeState
)
{
n
.
State
=
state
n
.
State
=
state
traceNodeChanged
(
n
.
nodeTab
,
n
)
traceNodeChanged
(
n
.
nodeTab
,
n
)
n
.
nodeTab
.
notify
(
n
.
NodeInfo
)
n
.
nodeTab
.
notify
(
n
.
NodeInfo
)
...
@@ -188,7 +190,7 @@ func (nt *NodeTable) String() string {
...
@@ -188,7 +190,7 @@ func (nt *NodeTable) String() string {
// ---- subscription to nodetab updates ----
// ---- subscription to nodetab updates ----
// notify notifies NodeTable subscribers that nodeInfo was updated
// notify notifies NodeTable subscribers that nodeInfo was updated
func
(
nt
*
NodeTable
)
notify
(
nodeInfo
NodeInfo
)
{
func
(
nt
*
NodeTable
)
notify
(
nodeInfo
proto
.
NodeInfo
)
{
// XXX rlock for .notifyv ?
// XXX rlock for .notifyv ?
for
_
,
notify
:=
range
nt
.
notifyv
{
for
_
,
notify
:=
range
nt
.
notifyv
{
notify
<-
nodeInfo
notify
<-
nodeInfo
...
@@ -200,8 +202,8 @@ func (nt *NodeTable) notify(nodeInfo NodeInfo) {
...
@@ -200,8 +202,8 @@ func (nt *NodeTable) notify(nodeInfo NodeInfo) {
// It returns a channel via which updates will be delivered and function to unsubscribe.
// It returns a channel via which updates will be delivered and function to unsubscribe.
//
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
// XXX locking: client for subscribe/unsubscribe XXX ok?
func
(
nt
*
NodeTable
)
Subscribe
()
(
ch
chan
NodeInfo
,
unsubscribe
func
())
{
func
(
nt
*
NodeTable
)
Subscribe
()
(
ch
chan
proto
.
NodeInfo
,
unsubscribe
func
())
{
ch
=
make
(
chan
NodeInfo
)
// XXX how to specify ch buf size if needed ?
ch
=
make
(
chan
proto
.
NodeInfo
)
// XXX how to specify ch buf size if needed ?
nt
.
notifyv
=
append
(
nt
.
notifyv
,
ch
)
nt
.
notifyv
=
append
(
nt
.
notifyv
,
ch
)
unsubscribe
=
func
()
{
unsubscribe
=
func
()
{
...
@@ -227,12 +229,12 @@ func (nt *NodeTable) Subscribe() (ch chan NodeInfo, unsubscribe func()) {
...
@@ -227,12 +229,12 @@ func (nt *NodeTable) Subscribe() (ch chan NodeInfo, unsubscribe func()) {
// to infinity - via e.g. detecting stuck connections and unsubscribing on shutdown.
// to infinity - via e.g. detecting stuck connections and unsubscribing on shutdown.
//
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
// XXX locking: client for subscribe/unsubscribe XXX ok?
func
(
nt
*
NodeTable
)
SubscribeBuffered
()
(
ch
chan
[]
NodeInfo
,
unsubscribe
func
())
{
func
(
nt
*
NodeTable
)
SubscribeBuffered
()
(
ch
chan
[]
proto
.
NodeInfo
,
unsubscribe
func
())
{
in
,
unsubscribe
:=
nt
.
Subscribe
()
in
,
unsubscribe
:=
nt
.
Subscribe
()
ch
=
make
(
chan
[]
NodeInfo
)
ch
=
make
(
chan
[]
proto
.
NodeInfo
)
go
func
()
{
go
func
()
{
var
updatev
[]
NodeInfo
var
updatev
[]
proto
.
NodeInfo
shutdown
:=
false
shutdown
:=
false
for
{
for
{
...
...
go/neo/parttab.go
View file @
47f069a5
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"fmt"
"fmt"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
)
// PartitionTable represents object space partitioning in a cluster
// PartitionTable represents object space partitioning in a cluster
...
@@ -118,12 +119,12 @@ type PartitionTable struct {
...
@@ -118,12 +119,12 @@ type PartitionTable struct {
tab
[][]
Cell
// [#Np] pid -> []Cell
tab
[][]
Cell
// [#Np] pid -> []Cell
PTid
PTid
// ↑ for versioning XXX -> ver ? XXX move out of here?
PTid
proto
.
PTid
// ↑ for versioning XXX -> ver ? XXX move out of here?
}
}
// Cell describes one storage in a pid entry in partition table
// Cell describes one storage in a pid entry in partition table
type
Cell
struct
{
type
Cell
struct
{
CellInfo
// .uuid + .state
proto
.
CellInfo
// .uuid + .state
// XXX ? + .haveUpToTid associated node has data up to such tid
// XXX ? + .haveUpToTid associated node has data up to such tid
// = uptodate if haveUpToTid == lastTid
// = uptodate if haveUpToTid == lastTid
...
@@ -149,7 +150,7 @@ func (pt *PartitionTable) Get(oid zodb.Oid) []Cell {
...
@@ -149,7 +150,7 @@ func (pt *PartitionTable) Get(oid zodb.Oid) []Cell {
// Readable reports whether it is ok to read data from a cell
// Readable reports whether it is ok to read data from a cell
func
(
c
*
Cell
)
Readable
()
bool
{
func
(
c
*
Cell
)
Readable
()
bool
{
switch
c
.
State
{
switch
c
.
State
{
case
UP_TO_DATE
,
FEEDING
:
case
proto
.
UP_TO_DATE
,
proto
.
FEEDING
:
return
true
return
true
}
}
return
false
return
false
...
@@ -165,7 +166,7 @@ func MakePartTab(np int, nodev []*Node) *PartitionTable {
...
@@ -165,7 +166,7 @@ func MakePartTab(np int, nodev []*Node) *PartitionTable {
node
:=
nodev
[
j
]
node
:=
nodev
[
j
]
// XXX assert node.State > DOWN
// XXX assert node.State > DOWN
//fmt.Printf("tab[%d] <- %v\n", i, node.UUID)
//fmt.Printf("tab[%d] <- %v\n", i, node.UUID)
tab
[
i
]
=
[]
Cell
{{
CellInfo
:
CellInfo
{
node
.
UUID
,
UP_TO_DATE
/*XXX ok?*/
}}}
tab
[
i
]
=
[]
Cell
{{
CellInfo
:
proto
.
CellInfo
{
node
.
UUID
,
proto
.
UP_TO_DATE
/*XXX ok?*/
}}}
}
}
return
&
PartitionTable
{
tab
:
tab
}
return
&
PartitionTable
{
tab
:
tab
}
...
@@ -203,7 +204,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
...
@@ -203,7 +204,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
//
//
// We leave it as is for now.
// We leave it as is for now.
node
:=
nt
.
Get
(
cell
.
UUID
)
node
:=
nt
.
Get
(
cell
.
UUID
)
if
node
==
nil
||
node
.
State
!=
RUNNING
{
// XXX PENDING is also ok ?
if
node
==
nil
||
node
.
State
!=
proto
.
RUNNING
{
// XXX PENDING is also ok ?
continue
continue
}
}
...
@@ -245,20 +246,20 @@ func (pt *PartitionTable) String() string {
...
@@ -245,20 +246,20 @@ func (pt *PartitionTable) String() string {
}
}
// XXX -> RowList() ?
// XXX -> RowList() ?
func
(
pt
*
PartitionTable
)
Dump
()
[]
RowInfo
{
// XXX also include .ptid? -> struct ?
func
(
pt
*
PartitionTable
)
Dump
()
[]
proto
.
RowInfo
{
// XXX also include .ptid? -> struct ?
rowv
:=
make
([]
RowInfo
,
len
(
pt
.
tab
))
rowv
:=
make
([]
proto
.
RowInfo
,
len
(
pt
.
tab
))
for
i
,
row
:=
range
pt
.
tab
{
for
i
,
row
:=
range
pt
.
tab
{
cellv
:=
make
([]
CellInfo
,
len
(
row
))
cellv
:=
make
([]
proto
.
CellInfo
,
len
(
row
))
for
j
,
cell
:=
range
row
{
for
j
,
cell
:=
range
row
{
cellv
[
j
]
=
cell
.
CellInfo
cellv
[
j
]
=
cell
.
CellInfo
}
}
rowv
[
i
]
=
RowInfo
{
Offset
:
uint32
(
i
),
CellList
:
cellv
}
// XXX cast?
rowv
[
i
]
=
proto
.
RowInfo
{
Offset
:
uint32
(
i
),
CellList
:
cellv
}
// XXX cast?
}
}
return
rowv
return
rowv
}
}
func
PartTabFromDump
(
ptid
PTid
,
rowv
[]
RowInfo
)
*
PartitionTable
{
func
PartTabFromDump
(
ptid
proto
.
PTid
,
rowv
[]
proto
.
RowInfo
)
*
PartitionTable
{
// reconstruct partition table from response
// reconstruct partition table from response
pt
:=
&
PartitionTable
{}
pt
:=
&
PartitionTable
{}
pt
.
PTid
=
ptid
pt
.
PTid
=
ptid
...
...
go/neo/parttab_test.go
View file @
47f069a5
...
@@ -21,19 +21,21 @@ package neo
...
@@ -21,19 +21,21 @@ package neo
import
(
import
(
"testing"
"testing"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
)
func
TestPartTabOperational
(
t
*
testing
.
T
)
{
func
TestPartTabOperational
(
t
*
testing
.
T
)
{
s1
:=
UUID
(
STORAGE
,
1
)
s1
:=
proto
.
UUID
(
proto
.
STORAGE
,
1
)
s2
:=
UUID
(
STORAGE
,
2
)
s2
:=
proto
.
UUID
(
proto
.
STORAGE
,
2
)
// create nodeinfo for uuid/state
// create nodeinfo for uuid/state
n
:=
func
(
uuid
NodeUUID
,
state
NodeState
)
NodeInfo
{
n
:=
func
(
uuid
proto
.
NodeUUID
,
state
proto
.
NodeState
)
proto
.
NodeInfo
{
return
NodeInfo
{
UUID
:
uuid
,
State
:
state
}
// XXX .Type?
return
proto
.
NodeInfo
{
UUID
:
uuid
,
State
:
state
}
// XXX .Type?
}
}
// create nodetab with [](uuid, state)
// create nodetab with [](uuid, state)
N
:=
func
(
nodeiv
...
NodeInfo
)
*
NodeTable
{
N
:=
func
(
nodeiv
...
proto
.
NodeInfo
)
*
NodeTable
{
nt
:=
&
NodeTable
{}
nt
:=
&
NodeTable
{}
for
_
,
nodei
:=
range
nodeiv
{
for
_
,
nodei
:=
range
nodeiv
{
nt
.
Update
(
nodei
)
nt
.
Update
(
nodei
)
...
@@ -42,8 +44,8 @@ func TestPartTabOperational(t *testing.T) {
...
@@ -42,8 +44,8 @@ func TestPartTabOperational(t *testing.T) {
}
}
// create cell with uuid/state
// create cell with uuid/state
C
:=
func
(
uuid
NodeUUID
,
state
CellState
)
Cell
{
C
:=
func
(
uuid
proto
.
NodeUUID
,
state
proto
.
CellState
)
Cell
{
return
Cell
{
CellInfo
{
UUID
:
uuid
,
State
:
state
}}
return
Cell
{
proto
.
CellInfo
{
UUID
:
uuid
,
State
:
state
}}
}
}
// shortcut to create []Cell
// shortcut to create []Cell
...
@@ -57,14 +59,14 @@ func TestPartTabOperational(t *testing.T) {
...
@@ -57,14 +59,14 @@ func TestPartTabOperational(t *testing.T) {
var
testv
=
[]
struct
{
pt
*
PartitionTable
;
nt
*
NodeTable
;
operational
bool
}{
var
testv
=
[]
struct
{
pt
*
PartitionTable
;
nt
*
NodeTable
;
operational
bool
}{
// empty parttab is non-operational
// empty parttab is non-operational
{
P
(),
N
(),
false
},
{
P
(),
N
(),
false
},
{
P
(),
N
(
n
(
s1
,
RUNNING
)),
false
},
{
P
(),
N
(
n
(
s1
,
proto
.
RUNNING
)),
false
},
// parttab with 1 storage
// parttab with 1 storage
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(),
false
},
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(
n
(
s2
,
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(
n
(
s2
,
proto
.
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
OUT_OF_DATE
))),
N
(
n
(
s1
,
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
OUT_OF_DATE
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(
n
(
s1
,
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
FEEDING
))),
N
(
n
(
s1
,
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
proto
.
FEEDING
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
true
},
// TODO more tests
// TODO more tests
}
}
...
...
go/neo/pkt.go
View file @
47f069a5
...
@@ -27,26 +27,29 @@ import (
...
@@ -27,26 +27,29 @@ import (
"unsafe"
"unsafe"
"lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
)
)
// PktBuf is a buffer with full raw packet (header + data).
// PktBuf is a buffer with full raw packet (header + data).
//
//
// variables of type PktBuf are usually named "pkb" (packet buffer), similar to "skb" in Linux.
// variables of type PktBuf are usually named "pkb" (packet buffer), similar to "skb" in Linux.
//
//
// Allocate PktBuf via
allocPkt
() and free via PktBuf.Free().
// Allocate PktBuf via
pktAlloc
() and free via PktBuf.Free().
type
PktBuf
struct
{
type
PktBuf
struct
{
Data
[]
byte
// whole packet data including all headers
Data
[]
byte
// whole packet data including all headers
}
}
// Header returns pointer to packet header.
// Header returns pointer to packet header.
func
(
pkt
*
PktBuf
)
Header
()
*
PktHeader
{
func
(
pkt
*
PktBuf
)
Header
()
*
proto
.
PktHeader
{
// XXX check len(Data) < PktHeader ? -> no, Data has to be allocated with cap >=
p
ktHeaderLen
// XXX check len(Data) < PktHeader ? -> no, Data has to be allocated with cap >=
P
ktHeaderLen
return
(
*
PktHeader
)(
unsafe
.
Pointer
(
&
pkt
.
Data
[
0
]))
return
(
*
proto
.
PktHeader
)(
unsafe
.
Pointer
(
&
pkt
.
Data
[
0
]))
}
}
// Payload returns []byte representing packet payload.
// Payload returns []byte representing packet payload.
func
(
pkt
*
PktBuf
)
Payload
()
[]
byte
{
func
(
pkt
*
PktBuf
)
Payload
()
[]
byte
{
return
pkt
.
Data
[
pktHeaderLen
:
]
return
pkt
.
Data
[
p
roto
.
P
ktHeaderLen
:
]
}
}
// ---- PktBuf freelist ----
// ---- PktBuf freelist ----
...
@@ -73,25 +76,25 @@ func (pkt *PktBuf) Free() {
...
@@ -73,25 +76,25 @@ func (pkt *PktBuf) Free() {
// Strings dumps a packet in human-readable form
// Strings dumps a packet in human-readable form
func
(
pkt
*
PktBuf
)
String
()
string
{
func
(
pkt
*
PktBuf
)
String
()
string
{
if
len
(
pkt
.
Data
)
<
pktHeaderLen
{
if
len
(
pkt
.
Data
)
<
p
roto
.
P
ktHeaderLen
{
return
fmt
.
Sprintf
(
"(! <
p
ktHeaderLen) % x"
,
pkt
.
Data
)
return
fmt
.
Sprintf
(
"(! <
P
ktHeaderLen) % x"
,
pkt
.
Data
)
}
}
h
:=
pkt
.
Header
()
h
:=
pkt
.
Header
()
s
:=
fmt
.
Sprintf
(
".%d"
,
n
toh32
(
h
.
ConnId
))
s
:=
fmt
.
Sprintf
(
".%d"
,
packed
.
N
toh32
(
h
.
ConnId
))
msgCode
:=
n
toh16
(
h
.
MsgCode
)
msgCode
:=
packed
.
N
toh16
(
h
.
MsgCode
)
msgLen
:=
n
toh32
(
h
.
MsgLen
)
msgLen
:=
packed
.
N
toh32
(
h
.
MsgLen
)
data
:=
pkt
.
Payload
()
data
:=
pkt
.
Payload
()
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
if
msgType
==
nil
{
s
+=
fmt
.
Sprintf
(
" ? (%d) #%d [%d]: % x"
,
msgCode
,
msgLen
,
len
(
data
),
data
)
s
+=
fmt
.
Sprintf
(
" ? (%d) #%d [%d]: % x"
,
msgCode
,
msgLen
,
len
(
data
),
data
)
return
s
return
s
}
}
// XXX dup wrt Conn.Recv
// XXX dup wrt Conn.Recv
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
Msg
)
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
proto
.
Msg
)
n
,
err
:=
msg
.
neo
MsgDecode
(
data
)
n
,
err
:=
msg
.
NEO
MsgDecode
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
s
+=
fmt
.
Sprintf
(
" (%s) %v; #%d [%d]: % x"
,
msgType
,
err
,
msgLen
,
len
(
data
),
data
)
s
+=
fmt
.
Sprintf
(
" (%s) %v; #%d [%d]: % x"
,
msgType
,
err
,
msgLen
,
len
(
data
),
data
)
}
}
...
@@ -108,12 +111,12 @@ func (pkt *PktBuf) String() string {
...
@@ -108,12 +111,12 @@ func (pkt *PktBuf) String() string {
// Dump dumps a packet in raw form
// Dump dumps a packet in raw form
func
(
pkt
*
PktBuf
)
Dump
()
string
{
func
(
pkt
*
PktBuf
)
Dump
()
string
{
if
len
(
pkt
.
Data
)
<
pktHeaderLen
{
if
len
(
pkt
.
Data
)
<
p
roto
.
P
ktHeaderLen
{
return
fmt
.
Sprintf
(
"(! < pktHeaderLen) % x"
,
pkt
.
Data
)
return
fmt
.
Sprintf
(
"(! < pktHeaderLen) % x"
,
pkt
.
Data
)
}
}
h
:=
pkt
.
Header
()
h
:=
pkt
.
Header
()
data
:=
pkt
.
Payload
()
data
:=
pkt
.
Payload
()
return
fmt
.
Sprintf
(
".%d (%d) #%d [%d]: % x"
,
return
fmt
.
Sprintf
(
".%d (%d) #%d [%d]: % x"
,
ntoh32
(
h
.
ConnId
),
ntoh16
(
h
.
MsgCode
),
n
toh32
(
h
.
MsgLen
),
len
(
data
),
data
)
packed
.
Ntoh32
(
h
.
ConnId
),
packed
.
Ntoh16
(
h
.
MsgCode
),
packed
.
N
toh32
(
h
.
MsgLen
),
len
(
data
),
data
)
}
}
go/neo/error.go
→
go/neo/
proto/
error.go
View file @
47f069a5
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
package
prot
o
// error related utilities
// error related utilities
import
(
import
(
...
@@ -27,7 +27,8 @@ import (
...
@@ -27,7 +27,8 @@ import (
)
)
// XXX place=? -> methods of Error
// XXX name -> zodbErrEncode, zodbErrDecode ?
// XXX should be not in proto/ ?
// ErrEncode translates an error into Error packet.
// ErrEncode translates an error into Error packet.
// XXX more text describing relation with zodb errors
// XXX more text describing relation with zodb errors
...
...
go/neo/proto-misc.go
→
go/neo/proto
/proto
-misc.go
View file @
47f069a5
...
@@ -17,20 +17,29 @@
...
@@ -17,20 +17,29 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go
packed.go
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go
package
ne
o
package
prot
o
// supporting code for types defined in proto.go
// supporting code for types defined in proto.go
import
(
import
(
"fmt"
"fmt"
"math"
"math"
"net"
"net"
"reflect"
"strconv"
"strconv"
"strings"
"strings"
"time"
"time"
)
)
// MsgType looks up message type by message code.
//
// Nil is returned if message code is not valid.
func
MsgType
(
msgCode
uint16
)
reflect
.
Type
{
return
msgTypeRegistry
[
msgCode
]
}
// XXX or better translate to some other errors ?
// XXX or better translate to some other errors ?
// XXX here - not in proto.go - because else stringer will be confused
// XXX here - not in proto.go - because else stringer will be confused
func
(
e
*
Error
)
Error
()
string
{
func
(
e
*
Error
)
Error
()
string
{
...
@@ -44,6 +53,8 @@ func (e *Error) Error() string {
...
@@ -44,6 +53,8 @@ func (e *Error) Error() string {
// Set sets cluster state value to v.
// Set sets cluster state value to v.
// Use Set instead of direct assignment for ClusterState tracing to work.
// Use Set instead of direct assignment for ClusterState tracing to work.
//
// XXX move this to neo.clusterState wrapping proto.ClusterState?
func
(
cs
*
ClusterState
)
Set
(
v
ClusterState
)
{
func
(
cs
*
ClusterState
)
Set
(
v
ClusterState
)
{
*
cs
=
v
*
cs
=
v
traceClusterStateChanged
(
cs
)
traceClusterStateChanged
(
cs
)
...
...
go/neo/proto.go
→
go/neo/proto
/proto
.go
View file @
47f069a5
// Copyright (C) 2006-201
7
Nexedi SA and Contributors.
// Copyright (C) 2006-201
8
Nexedi SA and Contributors.
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// it under the terms of the GNU General Public License version 3, or (at your
...
@@ -16,8 +16,24 @@
...
@@ -16,8 +16,24 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
neo
// Package proto provides definition of NEO messages and their marshalling
// protocol definition
// to/from wire format.
//
// Two NEO nodes can exchange messages over underlying network link after
// performing NEO-specific handshake. A message is sent as a packet specifying
// ID of subconnection multiplexed on top of the underlying link, carried
// message code and message data.
//
// PktHeader describes packet header structure.
//
// Messages are represented by corresponding types that all implement Msg interface.
//
// A message type can be looked up by message code with MsgType.
//
// The proto packages provides only message definitions and low-level
// primitives for their marshalling. Package lab.nexedi.com/kirr/neo/go/neo/net
// (XXX) provides actual service for message exchange over network.
package
proto
// This file defines everything that relates to messages on the wire.
// This file defines everything that relates to messages on the wire.
// In particular every type that is included in a message is defined here as well.
// In particular every type that is included in a message is defined here as well.
...
@@ -39,6 +55,7 @@ package neo
...
@@ -39,6 +55,7 @@ package neo
// The code to marshal/unmarshal messages is generated by protogen.go .
// The code to marshal/unmarshal messages is generated by protogen.go .
//go:generate sh -c "go run protogen.go >zproto-marshal.go"
//go:generate sh -c "go run protogen.go >zproto-marshal.go"
//go:generate gotrace gen .
// TODO regroup messages definitions to stay more close to 1 communication topic
// TODO regroup messages definitions to stay more close to 1 communication topic
...
@@ -53,6 +70,8 @@ import (
...
@@ -53,6 +70,8 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
"encoding/binary"
"encoding/binary"
"errors"
"errors"
"math"
"math"
...
@@ -62,17 +81,24 @@ const (
...
@@ -62,17 +81,24 @@ const (
// The protocol version must be increased whenever upgrading a node may require
// The protocol version must be increased whenever upgrading a node may require
// to upgrade other nodes. It is encoded as a 4-bytes big-endian integer and
// to upgrade other nodes. It is encoded as a 4-bytes big-endian integer and
// the high order byte 0 is different from TLS Handshake (0x16).
// the high order byte 0 is different from TLS Handshake (0x16).
Protocol
Version
=
1
Version
=
1
// length of packet header
// length of packet header
p
ktHeaderLen
=
10
// = unsafe.Sizeof(PktHeader{}), but latter gives typed constant (uintptr)
P
ktHeaderLen
=
10
// = unsafe.Sizeof(PktHeader{}), but latter gives typed constant (uintptr)
//
we are not accepting packets larger than pktMaxSize
.
//
packets larger than PktMaxSize are not allowed
.
//
in particular this avoids
out-of-memory error on packets with corrupt message len.
//
this helps to avoid
out-of-memory error on packets with corrupt message len.
p
ktMaxSize
=
0x4000000
P
ktMaxSize
=
0x4000000
// answerBit is set in message code in answer messages for compatibility with neo/py
// answerBit is set in message code in answer messages for compatibility with neo/py
answerBit
=
0x8000
answerBit
=
0x8000
//INVALID_UUID UUID = 0
// XXX -> zodb?
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
)
)
// PktHeader represents header of a raw packet.
// PktHeader represents header of a raw packet.
...
@@ -81,29 +107,29 @@ const (
...
@@ -81,29 +107,29 @@ const (
//
//
//neo:proto typeonly
//neo:proto typeonly
type
PktHeader
struct
{
type
PktHeader
struct
{
ConnId
be
32
// NOTE is .msgid in py
ConnId
packed
.
BE
32
// NOTE is .msgid in py
MsgCode
be
16
// payload message code
MsgCode
packed
.
BE
16
// payload message code
MsgLen
be
32
// payload message length (excluding packet header)
MsgLen
packed
.
BE
32
// payload message length (excluding packet header)
}
}
// Msg is the interface implemented by all NEO messages.
// Msg is the interface implemented by all NEO messages.
type
Msg
interface
{
type
Msg
interface
{
// marshal/unmarshal into/from wire format:
// marshal/unmarshal into/from wire format:
//
neo
MsgCode returns message code needed to be used for particular message type
//
NEO
MsgCode returns message code needed to be used for particular message type
// on the wire.
// on the wire.
neo
MsgCode
()
uint16
NEO
MsgCode
()
uint16
//
neo
MsgEncodedLen returns how much space is needed to encode current message payload.
//
NEO
MsgEncodedLen returns how much space is needed to encode current message payload.
neo
MsgEncodedLen
()
int
NEO
MsgEncodedLen
()
int
//
neo
MsgEncode encodes current message state into buf.
//
NEO
MsgEncode encodes current message state into buf.
//
//
// len(buf) must be >= neoMsgEncodedLen().
// len(buf) must be >= neoMsgEncodedLen().
neo
MsgEncode
(
buf
[]
byte
)
NEO
MsgEncode
(
buf
[]
byte
)
//
neo
MsgDecode decodes data into message in-place.
//
NEO
MsgDecode decodes data into message in-place.
neo
MsgDecode
(
data
[]
byte
)
(
nread
int
,
err
error
)
NEO
MsgDecode
(
data
[]
byte
)
(
nread
int
,
err
error
)
}
}
// ErrDecodeOverflow is the error returned by neoMsgDecode when decoding hits buffer overflow
// ErrDecodeOverflow is the error returned by neoMsgDecode when decoding hits buffer overflow
...
@@ -127,6 +153,7 @@ const (
...
@@ -127,6 +153,7 @@ const (
INCOMPLETE_TRANSACTION
INCOMPLETE_TRANSACTION
)
)
// XXX move this to neo.clusterState wrapping proto.ClusterState?
//trace:event traceClusterStateChanged(cs *ClusterState)
//trace:event traceClusterStateChanged(cs *ClusterState)
type
ClusterState
int32
type
ClusterState
int32
...
@@ -584,7 +611,7 @@ type AnswerRebaseObject struct {
...
@@ -584,7 +611,7 @@ type AnswerRebaseObject struct {
// FIXME POption('data')
// FIXME POption('data')
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// XXX was string
Data
*
mem
.
Buf
}
}
...
@@ -596,7 +623,7 @@ type StoreObject struct {
...
@@ -596,7 +623,7 @@ type StoreObject struct {
Serial
zodb
.
Tid
Serial
zodb
.
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// TODO encode ->
separately (for writev)
Data
[]
byte
// TODO -> msg.Buf,
separately (for writev)
DataSerial
zodb
.
Tid
DataSerial
zodb
.
Tid
Tid
zodb
.
Tid
Tid
zodb
.
Tid
}
}
...
@@ -1036,7 +1063,7 @@ type AddObject struct {
...
@@ -1036,7 +1063,7 @@ type AddObject struct {
Serial
zodb
.
Tid
Serial
zodb
.
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// TODO from pool, separately (?)
Data
*
mem
.
Buf
DataSerial
zodb
.
Tid
DataSerial
zodb
.
Tid
}
}
...
...
go/neo/proto_test.go
→
go/neo/proto
/proto
_test.go
View file @
47f069a5
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
package
prot
o
//
protocol
tests
//
NEO. protocol encoding
tests
import
(
import
(
hexpkg
"encoding/hex"
hexpkg
"encoding/hex"
...
@@ -64,12 +64,12 @@ func u64(v uint64) string {
...
@@ -64,12 +64,12 @@ func u64(v uint64) string {
}
}
func
TestPktHeader
(
t
*
testing
.
T
)
{
func
TestPktHeader
(
t
*
testing
.
T
)
{
// make sure PktHeader is really packed and its size matches
p
ktHeaderLen
// make sure PktHeader is really packed and its size matches
P
ktHeaderLen
if
unsafe
.
Sizeof
(
PktHeader
{})
!=
10
{
if
unsafe
.
Sizeof
(
PktHeader
{})
!=
10
{
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want 10"
,
unsafe
.
Sizeof
(
PktHeader
{}))
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want 10"
,
unsafe
.
Sizeof
(
PktHeader
{}))
}
}
if
unsafe
.
Sizeof
(
PktHeader
{})
!=
p
ktHeaderLen
{
if
unsafe
.
Sizeof
(
PktHeader
{})
!=
P
ktHeaderLen
{
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want %v"
,
unsafe
.
Sizeof
(
PktHeader
{}),
p
ktHeaderLen
)
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want %v"
,
unsafe
.
Sizeof
(
PktHeader
{}),
P
ktHeaderLen
)
}
}
}
}
...
@@ -85,9 +85,9 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
...
@@ -85,9 +85,9 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
}()
}()
// msg.encode() == expected
// msg.encode() == expected
msgCode
:=
msg
.
neo
MsgCode
()
msgCode
:=
msg
.
NEO
MsgCode
()
n
:=
msg
.
neo
MsgEncodedLen
()
n
:=
msg
.
NEO
MsgEncodedLen
()
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
MsgType
(
msgCode
)
if
msgType
!=
typ
{
if
msgType
!=
typ
{
t
.
Errorf
(
"%v: msgCode = %v which corresponds to %v"
,
typ
,
msgCode
,
msgType
)
t
.
Errorf
(
"%v: msgCode = %v which corresponds to %v"
,
typ
,
msgCode
,
msgType
)
}
}
...
@@ -96,7 +96,7 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
...
@@ -96,7 +96,7 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
}
}
buf
:=
make
([]
byte
,
n
)
buf
:=
make
([]
byte
,
n
)
msg
.
neo
MsgEncode
(
buf
)
msg
.
NEO
MsgEncode
(
buf
)
if
string
(
buf
)
!=
encoded
{
if
string
(
buf
)
!=
encoded
{
t
.
Errorf
(
"%v: encode result unexpected:"
,
typ
)
t
.
Errorf
(
"%v: encode result unexpected:"
,
typ
)
t
.
Errorf
(
"
\t
have: %s"
,
hexpkg
.
EncodeToString
(
buf
))
t
.
Errorf
(
"
\t
have: %s"
,
hexpkg
.
EncodeToString
(
buf
))
...
@@ -126,13 +126,13 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
...
@@ -126,13 +126,13 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
}
}
}()
}()
msg
.
neo
MsgEncode
(
buf
[
:
l
])
msg
.
NEO
MsgEncode
(
buf
[
:
l
])
}()
}()
}
}
// msg.decode() == expected
// msg.decode() == expected
data
:=
[]
byte
(
encoded
+
"noise"
)
data
:=
[]
byte
(
encoded
+
"noise"
)
n
,
err
:=
msg2
.
neo
MsgDecode
(
data
)
n
,
err
:=
msg2
.
NEO
MsgDecode
(
data
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"%v: decode error %v"
,
typ
,
err
)
t
.
Errorf
(
"%v: decode error %v"
,
typ
,
err
)
}
}
...
@@ -146,7 +146,7 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
...
@@ -146,7 +146,7 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
// decode must detect buffer overflow
// decode must detect buffer overflow
for
l
:=
len
(
encoded
)
-
1
;
l
>=
0
;
l
--
{
for
l
:=
len
(
encoded
)
-
1
;
l
>=
0
;
l
--
{
n
,
err
=
msg2
.
neo
MsgDecode
(
data
[
:
l
])
n
,
err
=
msg2
.
NEO
MsgDecode
(
data
[
:
l
])
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
t
.
Errorf
(
"%v: decode overflow not detected on [:%v]"
,
typ
,
l
)
t
.
Errorf
(
"%v: decode overflow not detected on [:%v]"
,
typ
,
l
)
}
}
...
@@ -281,11 +281,11 @@ func TestMsgMarshalAllOverflowLightly(t *testing.T) {
...
@@ -281,11 +281,11 @@ func TestMsgMarshalAllOverflowLightly(t *testing.T) {
for
_
,
typ
:=
range
msgTypeRegistry
{
for
_
,
typ
:=
range
msgTypeRegistry
{
// zero-value for a type
// zero-value for a type
msg
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
Msg
)
msg
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
Msg
)
l
:=
msg
.
neo
MsgEncodedLen
()
l
:=
msg
.
NEO
MsgEncodedLen
()
zerol
:=
make
([]
byte
,
l
)
zerol
:=
make
([]
byte
,
l
)
// decoding will turn nil slice & map into empty allocated ones.
// decoding will turn nil slice & map into empty allocated ones.
// we need it so that reflect.DeepEqual works for msg encode/decode comparison
// we need it so that reflect.DeepEqual works for msg encode/decode comparison
n
,
err
:=
msg
.
neo
MsgDecode
(
zerol
)
n
,
err
:=
msg
.
NEO
MsgDecode
(
zerol
)
if
!
(
n
==
l
&&
err
==
nil
)
{
if
!
(
n
==
l
&&
err
==
nil
)
{
t
.
Errorf
(
"%v: zero-decode unexpected: %v, %v ; want %v, nil"
,
typ
,
n
,
err
,
l
)
t
.
Errorf
(
"%v: zero-decode unexpected: %v, %v ; want %v, nil"
,
typ
,
n
,
err
,
l
)
}
}
...
@@ -316,7 +316,7 @@ func TestMsgDecodeLenOverflow(t *testing.T) {
...
@@ -316,7 +316,7 @@ func TestMsgDecodeLenOverflow(t *testing.T) {
}
}
}()
}()
n
,
err
:=
tt
.
msg
.
neo
MsgDecode
(
data
)
n
,
err
:=
tt
.
msg
.
NEO
MsgDecode
(
data
)
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
t
.
Errorf
(
"%T: decode %x
\n
have: %d, %v
\n
want: %d, %v"
,
tt
.
msg
,
data
,
t
.
Errorf
(
"%T: decode %x
\n
have: %d, %v
\n
want: %d, %v"
,
tt
.
msg
,
data
,
n
,
err
,
0
,
ErrDecodeOverflow
)
n
,
err
,
0
,
ErrDecodeOverflow
)
...
...
go/neo/proto_vs_py_test.go
→
go/neo/proto
/proto
_vs_py_test.go
View file @
47f069a5
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
package
prot
o
// test wire protocol compatibility with python
//
NEO.
test wire protocol compatibility with python
//go:generate ./py/pyneo-gen-testdata
//go:generate ./py/pyneo-gen-testdata
...
...
go/neo/protogen.go
→
go/neo/proto
/proto
gen.go
View file @
47f069a5
// Copyright (C) 2016-201
7
Nexedi SA and Contributors.
// Copyright (C) 2016-201
8
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -25,10 +25,10 @@ NEO. Protocol module. Code generator
...
@@ -25,10 +25,10 @@ NEO. Protocol module. Code generator
This program generates marshalling code for message types defined in proto.go .
This program generates marshalling code for message types defined in proto.go .
For every type 4 methods are generated in accordance with neo.Msg interface:
For every type 4 methods are generated in accordance with neo.Msg interface:
neo
MsgCode() uint16
NEO
MsgCode() uint16
neo
MsgEncodedLen() int
NEO
MsgEncodedLen() int
neo
MsgEncode(buf []byte)
NEO
MsgEncode(buf []byte)
neo
MsgDecode(data []byte) (nread int, err error)
NEO
MsgDecode(data []byte) (nread int, err error)
List of message types is obtained via searching through proto.go AST - looking
List of message types is obtained via searching through proto.go AST - looking
for appropriate struct declarations there.
for appropriate struct declarations there.
...
@@ -94,12 +94,12 @@ func pos(x interface { Pos() token.Pos }) token.Position {
...
@@ -94,12 +94,12 @@ func pos(x interface { Pos() token.Pos }) token.Position {
}
}
// get type name in context of neo package
// get type name in context of neo package
var
zodbPkg
*
types
.
Package
var
zodbPkg
*
types
.
Package
var
neoPkg
*
types
.
Package
var
protoPkg
*
types
.
Package
func
typeName
(
typ
types
.
Type
)
string
{
func
typeName
(
typ
types
.
Type
)
string
{
qf
:=
func
(
pkg
*
types
.
Package
)
string
{
qf
:=
func
(
pkg
*
types
.
Package
)
string
{
switch
pkg
{
switch
pkg
{
case
ne
oPkg
:
case
prot
oPkg
:
// same package - unqualified
// same package - unqualified
return
""
return
""
...
@@ -247,11 +247,11 @@ func main() {
...
@@ -247,11 +247,11 @@ func main() {
log
.
SetFlags
(
0
)
log
.
SetFlags
(
0
)
// go through proto.go and AST'ify & typecheck it
// go through proto.go and AST'ify & typecheck it
zodbPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/zodb"
,
"
../zodb/zodb.go"
)
zodbPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/zodb"
,
"../
../zodb/zodb.go"
)
neoPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/neo"
,
"proto.go"
,
"packed
.go"
)
protoPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/neo/proto"
,
"proto
.go"
)
// extract neo.customCodec
// extract neo.customCodec
cc
:=
ne
oPkg
.
Scope
()
.
Lookup
(
"customCodec"
)
cc
:=
prot
oPkg
.
Scope
()
.
Lookup
(
"customCodec"
)
if
cc
==
nil
{
if
cc
==
nil
{
log
.
Fatal
(
"cannot find `customCodec`"
)
log
.
Fatal
(
"cannot find `customCodec`"
)
}
}
...
@@ -285,8 +285,8 @@ func main() {
...
@@ -285,8 +285,8 @@ func main() {
buf
:=
Buffer
{}
buf
:=
Buffer
{}
buf
.
emit
(
`// Code generated by protogen.go; DO NOT EDIT.
buf
.
emit
(
`// Code generated by protogen.go; DO NOT EDIT.
package
ne
o
package
prot
o
// protocol messages to/from wire marshalling.
//
NEO.
protocol messages to/from wire marshalling.
import (
import (
"encoding/binary"
"encoding/binary"
...
@@ -350,7 +350,7 @@ import (
...
@@ -350,7 +350,7 @@ import (
fmt
.
Fprintf
(
&
buf
,
"// %s. %s
\n\n
"
,
msgCode
,
typename
)
fmt
.
Fprintf
(
&
buf
,
"// %s. %s
\n\n
"
,
msgCode
,
typename
)
buf
.
emit
(
"func (*%s)
neo
MsgCode() uint16 {"
,
typename
)
buf
.
emit
(
"func (*%s)
NEO
MsgCode() uint16 {"
,
typename
)
buf
.
emit
(
"return %s"
,
msgCode
)
buf
.
emit
(
"return %s"
,
msgCode
)
buf
.
emit
(
"}
\n
"
)
buf
.
emit
(
"}
\n
"
)
...
@@ -629,7 +629,7 @@ type sizer struct {
...
@@ -629,7 +629,7 @@ type sizer struct {
//
//
// when type is recursively walked, for every case code to update `data[n:]` is generated.
// when type is recursively walked, for every case code to update `data[n:]` is generated.
// no overflow checks are generated as by neo.Msg interface provided data
// no overflow checks are generated as by neo.Msg interface provided data
// buffer should have at least payloadLen length returned by
neoMsgEncodedInfo
()
// buffer should have at least payloadLen length returned by
NEOMsgEncodedLen
()
// (the size computed by sizer).
// (the size computed by sizer).
//
//
// the code emitted looks like:
// the code emitted looks like:
...
@@ -638,7 +638,7 @@ type sizer struct {
...
@@ -638,7 +638,7 @@ type sizer struct {
// encode<typ2>(data[n2:], path2)
// encode<typ2>(data[n2:], path2)
// ...
// ...
//
//
// TODO encode have to care in
neo
MsgEncode to emit preamble such that bound
// TODO encode have to care in
NEO
MsgEncode to emit preamble such that bound
// checking is performed only once (currently compiler emits many of them)
// checking is performed only once (currently compiler emits many of them)
type
encoder
struct
{
type
encoder
struct
{
commonCodeGen
commonCodeGen
...
@@ -686,7 +686,7 @@ var _ CodeGenerator = (*decoder)(nil)
...
@@ -686,7 +686,7 @@ var _ CodeGenerator = (*decoder)(nil)
func
(
s
*
sizer
)
generatedCode
()
string
{
func
(
s
*
sizer
)
generatedCode
()
string
{
code
:=
Buffer
{}
code
:=
Buffer
{}
// prologue
// prologue
code
.
emit
(
"func (%s *%s)
neo
MsgEncodedLen() int {"
,
s
.
recvName
,
s
.
typeName
)
code
.
emit
(
"func (%s *%s)
NEO
MsgEncodedLen() int {"
,
s
.
recvName
,
s
.
typeName
)
if
s
.
varUsed
[
"size"
]
{
if
s
.
varUsed
[
"size"
]
{
code
.
emit
(
"var %s int"
,
s
.
var_
(
"size"
))
code
.
emit
(
"var %s int"
,
s
.
var_
(
"size"
))
}
}
...
@@ -707,7 +707,7 @@ func (s *sizer) generatedCode() string {
...
@@ -707,7 +707,7 @@ func (s *sizer) generatedCode() string {
func
(
e
*
encoder
)
generatedCode
()
string
{
func
(
e
*
encoder
)
generatedCode
()
string
{
code
:=
Buffer
{}
code
:=
Buffer
{}
// prologue
// prologue
code
.
emit
(
"func (%s *%s)
neo
MsgEncode(data []byte) {"
,
e
.
recvName
,
e
.
typeName
)
code
.
emit
(
"func (%s *%s)
NEO
MsgEncode(data []byte) {"
,
e
.
recvName
,
e
.
typeName
)
code
.
Write
(
e
.
buf
.
Bytes
())
code
.
Write
(
e
.
buf
.
Bytes
())
...
@@ -819,7 +819,7 @@ func (d *decoder) generatedCode() string {
...
@@ -819,7 +819,7 @@ func (d *decoder) generatedCode() string {
code
:=
Buffer
{}
code
:=
Buffer
{}
// prologue
// prologue
code
.
emit
(
"func (%s *%s)
neo
MsgDecode(data []byte) (int, error) {"
,
d
.
recvName
,
d
.
typeName
)
code
.
emit
(
"func (%s *%s)
NEO
MsgDecode(data []byte) (int, error) {"
,
d
.
recvName
,
d
.
typeName
)
if
d
.
varUsed
[
"nread"
]
{
if
d
.
varUsed
[
"nread"
]
{
code
.
emit
(
"var %v uint64"
,
d
.
var_
(
"nread"
))
code
.
emit
(
"var %v uint64"
,
d
.
var_
(
"nread"
))
}
}
...
...
go/neo/py/pyneo-gen-testdata
→
go/neo/p
roto/p
y/pyneo-gen-testdata
View file @
47f069a5
...
@@ -65,7 +65,7 @@ _['NotifyClusterInformation'] = 'NotifyClusterState'
...
@@ -65,7 +65,7 @@ _['NotifyClusterInformation'] = 'NotifyClusterState'
def
main
():
def
main
():
pyprotog
=
{}
pyprotog
=
{}
execfile
(
'../../neo/lib/protocol.py'
,
pyprotog
)
execfile
(
'../../
../
neo/lib/protocol.py'
,
pyprotog
)
pypacket
=
pyprotog
[
'Packet'
]
pypacket
=
pyprotog
[
'Packet'
]
pypackets
=
pyprotog
[
'Packets'
]
pypackets
=
pyprotog
[
'Packets'
]
...
@@ -74,7 +74,7 @@ def main():
...
@@ -74,7 +74,7 @@ def main():
def
emit
(
v
):
def
emit
(
v
):
print
>>
f
,
v
print
>>
f
,
v
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"package
ne
o"
)
emit
(
"package
prot
o"
)
emit
(
"
\
n
var pyMsgRegistry = map[uint16]string{"
)
emit
(
"
\
n
var pyMsgRegistry = map[uint16]string{"
)
...
...
go/neo/zproto-marshal.go
→
go/neo/
proto/
zproto-marshal.go
View file @
47f069a5
// Code generated by protogen.go; DO NOT EDIT.
// Code generated by protogen.go; DO NOT EDIT.
package
ne
o
package
prot
o
// protocol messages to/from wire marshalling.
//
NEO.
protocol messages to/from wire marshalling.
import
(
import
(
"encoding/binary"
"encoding/binary"
...
@@ -17,15 +17,15 @@ import (
...
@@ -17,15 +17,15 @@ import (
// 0 | answerBit. Error
// 0 | answerBit. Error
func
(
*
Error
)
neo
MsgCode
()
uint16
{
func
(
*
Error
)
NEO
MsgCode
()
uint16
{
return
0
|
answerBit
return
0
|
answerBit
}
}
func
(
p
*
Error
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Error
)
NEO
MsgEncodedLen
()
int
{
return
8
+
len
(
p
.
Message
)
return
8
+
len
(
p
.
Message
)
}
}
func
(
p
*
Error
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Error
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
p
.
Code
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
p
.
Code
))
{
{
l
:=
uint32
(
len
(
p
.
Message
))
l
:=
uint32
(
len
(
p
.
Message
))
...
@@ -36,7 +36,7 @@ func (p *Error) neoMsgEncode(data []byte) {
...
@@ -36,7 +36,7 @@ func (p *Error) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
Error
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Error
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
...
@@ -60,15 +60,15 @@ overflow:
...
@@ -60,15 +60,15 @@ overflow:
// 1. RequestIdentification
// 1. RequestIdentification
func
(
*
RequestIdentification
)
neo
MsgCode
()
uint16
{
func
(
*
RequestIdentification
)
NEO
MsgCode
()
uint16
{
return
1
return
1
}
}
func
(
p
*
RequestIdentification
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RequestIdentification
)
NEO
MsgEncodedLen
()
int
{
return
12
+
p
.
Address
.
neoEncodedLen
()
+
len
(
p
.
ClusterName
)
+
p
.
IdTime
.
neoEncodedLen
()
return
12
+
p
.
Address
.
neoEncodedLen
()
+
len
(
p
.
ClusterName
)
+
p
.
IdTime
.
neoEncodedLen
()
}
}
func
(
p
*
RequestIdentification
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
RequestIdentification
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
UUID
)))
{
{
...
@@ -88,7 +88,7 @@ func (p *RequestIdentification) neoMsgEncode(data []byte) {
...
@@ -88,7 +88,7 @@ func (p *RequestIdentification) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
RequestIdentification
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
RequestIdentification
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
...
@@ -133,15 +133,15 @@ overflow:
...
@@ -133,15 +133,15 @@ overflow:
// 1 | answerBit. AcceptIdentification
// 1 | answerBit. AcceptIdentification
func
(
*
AcceptIdentification
)
neo
MsgCode
()
uint16
{
func
(
*
AcceptIdentification
)
NEO
MsgCode
()
uint16
{
return
1
|
answerBit
return
1
|
answerBit
}
}
func
(
p
*
AcceptIdentification
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AcceptIdentification
)
NEO
MsgEncodedLen
()
int
{
return
20
return
20
}
}
func
(
p
*
AcceptIdentification
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AcceptIdentification
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
MyUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
MyUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
p
.
NumPartitions
)
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
p
.
NumPartitions
)
...
@@ -149,7 +149,7 @@ func (p *AcceptIdentification) neoMsgEncode(data []byte) {
...
@@ -149,7 +149,7 @@ func (p *AcceptIdentification) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
uint32
(
int32
(
p
.
YourUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
uint32
(
int32
(
p
.
YourUUID
)))
}
}
func
(
p
*
AcceptIdentification
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AcceptIdentification
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
20
{
if
len
(
data
)
<
20
{
goto
overflow
goto
overflow
}
}
...
@@ -166,87 +166,87 @@ overflow:
...
@@ -166,87 +166,87 @@ overflow:
// 3. Ping
// 3. Ping
func
(
*
Ping
)
neo
MsgCode
()
uint16
{
func
(
*
Ping
)
NEO
MsgCode
()
uint16
{
return
3
return
3
}
}
func
(
p
*
Ping
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Ping
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
Ping
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Ping
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
Ping
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Ping
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 3 | answerBit. Pong
// 3 | answerBit. Pong
func
(
*
Pong
)
neo
MsgCode
()
uint16
{
func
(
*
Pong
)
NEO
MsgCode
()
uint16
{
return
3
|
answerBit
return
3
|
answerBit
}
}
func
(
p
*
Pong
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Pong
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
Pong
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Pong
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
Pong
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Pong
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 5. CloseClient
// 5. CloseClient
func
(
*
CloseClient
)
neo
MsgCode
()
uint16
{
func
(
*
CloseClient
)
NEO
MsgCode
()
uint16
{
return
5
return
5
}
}
func
(
p
*
CloseClient
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CloseClient
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
CloseClient
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CloseClient
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
CloseClient
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CloseClient
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 6. PrimaryMaster
// 6. PrimaryMaster
func
(
*
PrimaryMaster
)
neo
MsgCode
()
uint16
{
func
(
*
PrimaryMaster
)
NEO
MsgCode
()
uint16
{
return
6
return
6
}
}
func
(
p
*
PrimaryMaster
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PrimaryMaster
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
PrimaryMaster
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
PrimaryMaster
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
PrimaryMaster
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
PrimaryMaster
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 6 | answerBit. AnswerPrimary
// 6 | answerBit. AnswerPrimary
func
(
*
AnswerPrimary
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPrimary
)
NEO
MsgCode
()
uint16
{
return
6
|
answerBit
return
6
|
answerBit
}
}
func
(
p
*
AnswerPrimary
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPrimary
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
AnswerPrimary
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerPrimary
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
PrimaryNodeUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
PrimaryNodeUUID
)))
}
}
func
(
p
*
AnswerPrimary
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerPrimary
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -259,11 +259,11 @@ overflow:
...
@@ -259,11 +259,11 @@ overflow:
// 8. NotPrimaryMaster
// 8. NotPrimaryMaster
func
(
*
NotPrimaryMaster
)
neo
MsgCode
()
uint16
{
func
(
*
NotPrimaryMaster
)
NEO
MsgCode
()
uint16
{
return
8
return
8
}
}
func
(
p
*
NotPrimaryMaster
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotPrimaryMaster
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
a
:=
&
p
.
KnownMasterList
[
i
]
a
:=
&
p
.
KnownMasterList
[
i
]
...
@@ -272,7 +272,7 @@ func (p *NotPrimaryMaster) neoMsgEncodedLen() int {
...
@@ -272,7 +272,7 @@ func (p *NotPrimaryMaster) neoMsgEncodedLen() int {
return
8
+
size
return
8
+
size
}
}
func
(
p
*
NotPrimaryMaster
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotPrimaryMaster
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
Primary
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
Primary
)))
{
{
l
:=
uint32
(
len
(
p
.
KnownMasterList
))
l
:=
uint32
(
len
(
p
.
KnownMasterList
))
...
@@ -289,7 +289,7 @@ func (p *NotPrimaryMaster) neoMsgEncode(data []byte) {
...
@@ -289,7 +289,7 @@ func (p *NotPrimaryMaster) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
NotPrimaryMaster
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotPrimaryMaster
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
...
@@ -319,11 +319,11 @@ overflow:
...
@@ -319,11 +319,11 @@ overflow:
// 9. NotifyNodeInformation
// 9. NotifyNodeInformation
func
(
*
NotifyNodeInformation
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyNodeInformation
)
NEO
MsgCode
()
uint16
{
return
9
return
9
}
}
func
(
p
*
NotifyNodeInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyNodeInformation
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
...
@@ -332,7 +332,7 @@ func (p *NotifyNodeInformation) neoMsgEncodedLen() int {
...
@@ -332,7 +332,7 @@ func (p *NotifyNodeInformation) neoMsgEncodedLen() int {
return
4
+
p
.
IdTime
.
neoEncodedLen
()
+
len
(
p
.
NodeList
)
*
12
+
size
return
4
+
p
.
IdTime
.
neoEncodedLen
()
+
len
(
p
.
NodeList
)
*
12
+
size
}
}
func
(
p
*
NotifyNodeInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyNodeInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
n
:=
p
.
IdTime
.
neoEncode
(
data
[
0
:
])
n
:=
p
.
IdTime
.
neoEncode
(
data
[
0
:
])
data
=
data
[
0
+
n
:
]
data
=
data
[
0
+
n
:
]
...
@@ -359,7 +359,7 @@ func (p *NotifyNodeInformation) neoMsgEncode(data []byte) {
...
@@ -359,7 +359,7 @@ func (p *NotifyNodeInformation) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
NotifyNodeInformation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyNodeInformation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
{
{
n
,
ok
:=
p
.
IdTime
.
neoDecode
(
data
)
n
,
ok
:=
p
.
IdTime
.
neoDecode
(
data
)
...
@@ -416,38 +416,38 @@ overflow:
...
@@ -416,38 +416,38 @@ overflow:
// 10. Recovery
// 10. Recovery
func
(
*
Recovery
)
neo
MsgCode
()
uint16
{
func
(
*
Recovery
)
NEO
MsgCode
()
uint16
{
return
10
return
10
}
}
func
(
p
*
Recovery
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Recovery
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
Recovery
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Recovery
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
Recovery
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Recovery
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 10 | answerBit. AnswerRecovery
// 10 | answerBit. AnswerRecovery
func
(
*
AnswerRecovery
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRecovery
)
NEO
MsgCode
()
uint16
{
return
10
|
answerBit
return
10
|
answerBit
}
}
func
(
p
*
AnswerRecovery
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerRecovery
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
AnswerRecovery
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerRecovery
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
BackupTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
BackupTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
TruncateTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
TruncateTid
))
}
}
func
(
p
*
AnswerRecovery
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerRecovery
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -462,37 +462,37 @@ overflow:
...
@@ -462,37 +462,37 @@ overflow:
// 12. LastIDs
// 12. LastIDs
func
(
*
LastIDs
)
neo
MsgCode
()
uint16
{
func
(
*
LastIDs
)
NEO
MsgCode
()
uint16
{
return
12
return
12
}
}
func
(
p
*
LastIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LastIDs
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
LastIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
LastIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
LastIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
LastIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 12 | answerBit. AnswerLastIDs
// 12 | answerBit. AnswerLastIDs
func
(
*
AnswerLastIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLastIDs
)
NEO
MsgCode
()
uint16
{
return
12
|
answerBit
return
12
|
answerBit
}
}
func
(
p
*
AnswerLastIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLastIDs
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
AnswerLastIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLastIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
LastOid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
LastOid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LastTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LastTid
))
}
}
func
(
p
*
AnswerLastIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerLastIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -506,28 +506,28 @@ overflow:
...
@@ -506,28 +506,28 @@ overflow:
// 14. AskPartitionTable
// 14. AskPartitionTable
func
(
*
AskPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
AskPartitionTable
)
NEO
MsgCode
()
uint16
{
return
14
return
14
}
}
func
(
p
*
AskPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskPartitionTable
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
AskPartitionTable
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskPartitionTable
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
AskPartitionTable
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AskPartitionTable
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 14 | answerBit. AnswerPartitionTable
// 14 | answerBit. AnswerPartitionTable
func
(
*
AnswerPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPartitionTable
)
NEO
MsgCode
()
uint16
{
return
14
|
answerBit
return
14
|
answerBit
}
}
func
(
p
*
AnswerPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPartitionTable
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -536,7 +536,7 @@ func (p *AnswerPartitionTable) neoMsgEncodedLen() int {
...
@@ -536,7 +536,7 @@ func (p *AnswerPartitionTable) neoMsgEncodedLen() int {
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
12
+
len
(
p
.
RowList
)
*
8
+
size
}
}
func
(
p
*
AnswerPartitionTable
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerPartitionTable
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
{
{
l
:=
uint32
(
len
(
p
.
RowList
))
l
:=
uint32
(
len
(
p
.
RowList
))
...
@@ -561,7 +561,7 @@ func (p *AnswerPartitionTable) neoMsgEncode(data []byte) {
...
@@ -561,7 +561,7 @@ func (p *AnswerPartitionTable) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerPartitionTable
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerPartitionTable
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -603,11 +603,11 @@ overflow:
...
@@ -603,11 +603,11 @@ overflow:
// 16. SendPartitionTable
// 16. SendPartitionTable
func
(
*
SendPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
SendPartitionTable
)
NEO
MsgCode
()
uint16
{
return
16
return
16
}
}
func
(
p
*
SendPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SendPartitionTable
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -616,7 +616,7 @@ func (p *SendPartitionTable) neoMsgEncodedLen() int {
...
@@ -616,7 +616,7 @@ func (p *SendPartitionTable) neoMsgEncodedLen() int {
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
12
+
len
(
p
.
RowList
)
*
8
+
size
}
}
func
(
p
*
SendPartitionTable
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
SendPartitionTable
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
{
{
l
:=
uint32
(
len
(
p
.
RowList
))
l
:=
uint32
(
len
(
p
.
RowList
))
...
@@ -641,7 +641,7 @@ func (p *SendPartitionTable) neoMsgEncode(data []byte) {
...
@@ -641,7 +641,7 @@ func (p *SendPartitionTable) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
SendPartitionTable
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
SendPartitionTable
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -683,15 +683,15 @@ overflow:
...
@@ -683,15 +683,15 @@ overflow:
// 17. NotifyPartitionChanges
// 17. NotifyPartitionChanges
func
(
*
NotifyPartitionChanges
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyPartitionChanges
)
NEO
MsgCode
()
uint16
{
return
17
return
17
}
}
func
(
p
*
NotifyPartitionChanges
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyPartitionChanges
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
CellList
)
*
12
return
12
+
len
(
p
.
CellList
)
*
12
}
}
func
(
p
*
NotifyPartitionChanges
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyPartitionChanges
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
{
{
l
:=
uint32
(
len
(
p
.
CellList
))
l
:=
uint32
(
len
(
p
.
CellList
))
...
@@ -707,7 +707,7 @@ func (p *NotifyPartitionChanges) neoMsgEncode(data []byte) {
...
@@ -707,7 +707,7 @@ func (p *NotifyPartitionChanges) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
NotifyPartitionChanges
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyPartitionChanges
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -740,19 +740,19 @@ overflow:
...
@@ -740,19 +740,19 @@ overflow:
// 18. StartOperation
// 18. StartOperation
func
(
*
StartOperation
)
neo
MsgCode
()
uint16
{
func
(
*
StartOperation
)
NEO
MsgCode
()
uint16
{
return
18
return
18
}
}
func
(
p
*
StartOperation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StartOperation
)
NEO
MsgEncodedLen
()
int
{
return
1
return
1
}
}
func
(
p
*
StartOperation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StartOperation
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
Backup
)
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
Backup
)
}
}
func
(
p
*
StartOperation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
StartOperation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
1
{
if
len
(
data
)
<
1
{
goto
overflow
goto
overflow
}
}
...
@@ -765,32 +765,32 @@ overflow:
...
@@ -765,32 +765,32 @@ overflow:
// 19. StopOperation
// 19. StopOperation
func
(
*
StopOperation
)
neo
MsgCode
()
uint16
{
func
(
*
StopOperation
)
NEO
MsgCode
()
uint16
{
return
19
return
19
}
}
func
(
p
*
StopOperation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StopOperation
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
StopOperation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StopOperation
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
StopOperation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
StopOperation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 20. UnfinishedTransactions
// 20. UnfinishedTransactions
func
(
*
UnfinishedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
UnfinishedTransactions
)
NEO
MsgCode
()
uint16
{
return
20
return
20
}
}
func
(
p
*
UnfinishedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
UnfinishedTransactions
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
RowList
)
*
4
return
4
+
len
(
p
.
RowList
)
*
4
}
}
func
(
p
*
UnfinishedTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
UnfinishedTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
RowList
))
l
:=
uint32
(
len
(
p
.
RowList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -803,7 +803,7 @@ func (p *UnfinishedTransactions) neoMsgEncode(data []byte) {
...
@@ -803,7 +803,7 @@ func (p *UnfinishedTransactions) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
UnfinishedTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
UnfinishedTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -830,15 +830,15 @@ overflow:
...
@@ -830,15 +830,15 @@ overflow:
// 20 | answerBit. AnswerUnfinishedTransactions
// 20 | answerBit. AnswerUnfinishedTransactions
func
(
*
AnswerUnfinishedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerUnfinishedTransactions
)
NEO
MsgCode
()
uint16
{
return
20
|
answerBit
return
20
|
answerBit
}
}
func
(
p
*
AnswerUnfinishedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerUnfinishedTransactions
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
TidList
)
*
8
return
12
+
len
(
p
.
TidList
)
*
8
}
}
func
(
p
*
AnswerUnfinishedTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerUnfinishedTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MaxTID
))
{
{
l
:=
uint32
(
len
(
p
.
TidList
))
l
:=
uint32
(
len
(
p
.
TidList
))
...
@@ -852,7 +852,7 @@ func (p *AnswerUnfinishedTransactions) neoMsgEncode(data []byte) {
...
@@ -852,7 +852,7 @@ func (p *AnswerUnfinishedTransactions) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerUnfinishedTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerUnfinishedTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -880,32 +880,32 @@ overflow:
...
@@ -880,32 +880,32 @@ overflow:
// 22. LockedTransactions
// 22. LockedTransactions
func
(
*
LockedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
LockedTransactions
)
NEO
MsgCode
()
uint16
{
return
22
return
22
}
}
func
(
p
*
LockedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LockedTransactions
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
LockedTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
LockedTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
LockedTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
LockedTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 22 | answerBit. AnswerLockedTransactions
// 22 | answerBit. AnswerLockedTransactions
func
(
*
AnswerLockedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLockedTransactions
)
NEO
MsgCode
()
uint16
{
return
22
|
answerBit
return
22
|
answerBit
}
}
func
(
p
*
AnswerLockedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLockedTransactions
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
TidDict
)
*
16
return
4
+
len
(
p
.
TidDict
)
*
16
}
}
func
(
p
*
AnswerLockedTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLockedTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
TidDict
))
l
:=
uint32
(
len
(
p
.
TidDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -923,7 +923,7 @@ func (p *AnswerLockedTransactions) neoMsgEncode(data []byte) {
...
@@ -923,7 +923,7 @@ func (p *AnswerLockedTransactions) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerLockedTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerLockedTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -951,19 +951,19 @@ overflow:
...
@@ -951,19 +951,19 @@ overflow:
// 24. FinalTID
// 24. FinalTID
func
(
*
FinalTID
)
neo
MsgCode
()
uint16
{
func
(
*
FinalTID
)
NEO
MsgCode
()
uint16
{
return
24
return
24
}
}
func
(
p
*
FinalTID
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FinalTID
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
FinalTID
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FinalTID
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
}
}
func
(
p
*
FinalTID
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
FinalTID
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -976,19 +976,19 @@ overflow:
...
@@ -976,19 +976,19 @@ overflow:
// 24 | answerBit. AnswerFinalTID
// 24 | answerBit. AnswerFinalTID
func
(
*
AnswerFinalTID
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFinalTID
)
NEO
MsgCode
()
uint16
{
return
24
|
answerBit
return
24
|
answerBit
}
}
func
(
p
*
AnswerFinalTID
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFinalTID
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerFinalTID
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerFinalTID
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
AnswerFinalTID
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerFinalTID
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1001,20 +1001,20 @@ overflow:
...
@@ -1001,20 +1001,20 @@ overflow:
// 26. ValidateTransaction
// 26. ValidateTransaction
func
(
*
ValidateTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
ValidateTransaction
)
NEO
MsgCode
()
uint16
{
return
26
return
26
}
}
func
(
p
*
ValidateTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ValidateTransaction
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
ValidateTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
ValidateTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
ValidateTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
ValidateTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1028,19 +1028,19 @@ overflow:
...
@@ -1028,19 +1028,19 @@ overflow:
// 27. BeginTransaction
// 27. BeginTransaction
func
(
*
BeginTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
BeginTransaction
)
NEO
MsgCode
()
uint16
{
return
27
return
27
}
}
func
(
p
*
BeginTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
BeginTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
BeginTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
BeginTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
BeginTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
BeginTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1053,19 +1053,19 @@ overflow:
...
@@ -1053,19 +1053,19 @@ overflow:
// 27 | answerBit. AnswerBeginTransaction
// 27 | answerBit. AnswerBeginTransaction
func
(
*
AnswerBeginTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerBeginTransaction
)
NEO
MsgCode
()
uint16
{
return
27
|
answerBit
return
27
|
answerBit
}
}
func
(
p
*
AnswerBeginTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerBeginTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerBeginTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerBeginTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
AnswerBeginTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerBeginTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1078,15 +1078,15 @@ overflow:
...
@@ -1078,15 +1078,15 @@ overflow:
// 29. FailedVote
// 29. FailedVote
func
(
*
FailedVote
)
neo
MsgCode
()
uint16
{
func
(
*
FailedVote
)
NEO
MsgCode
()
uint16
{
return
29
return
29
}
}
func
(
p
*
FailedVote
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FailedVote
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
NodeList
)
*
4
return
12
+
len
(
p
.
NodeList
)
*
4
}
}
func
(
p
*
FailedVote
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FailedVote
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
...
@@ -1100,7 +1100,7 @@ func (p *FailedVote) neoMsgEncode(data []byte) {
...
@@ -1100,7 +1100,7 @@ func (p *FailedVote) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
FailedVote
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
FailedVote
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -1128,15 +1128,15 @@ overflow:
...
@@ -1128,15 +1128,15 @@ overflow:
// 30. FinishTransaction
// 30. FinishTransaction
func
(
*
FinishTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
FinishTransaction
)
NEO
MsgCode
()
uint16
{
return
30
return
30
}
}
func
(
p
*
FinishTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FinishTransaction
)
NEO
MsgEncodedLen
()
int
{
return
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
return
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
}
}
func
(
p
*
FinishTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FinishTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
OIDList
))
l
:=
uint32
(
len
(
p
.
OIDList
))
...
@@ -1160,7 +1160,7 @@ func (p *FinishTransaction) neoMsgEncode(data []byte) {
...
@@ -1160,7 +1160,7 @@ func (p *FinishTransaction) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
FinishTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
FinishTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -1202,20 +1202,20 @@ overflow:
...
@@ -1202,20 +1202,20 @@ overflow:
// 30 | answerBit. AnswerTransactionFinished
// 30 | answerBit. AnswerTransactionFinished
func
(
*
AnswerTransactionFinished
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTransactionFinished
)
NEO
MsgCode
()
uint16
{
return
30
|
answerBit
return
30
|
answerBit
}
}
func
(
p
*
AnswerTransactionFinished
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTransactionFinished
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
AnswerTransactionFinished
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerTransactionFinished
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
AnswerTransactionFinished
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerTransactionFinished
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1229,20 +1229,20 @@ overflow:
...
@@ -1229,20 +1229,20 @@ overflow:
// 32. LockInformation
// 32. LockInformation
func
(
*
LockInformation
)
neo
MsgCode
()
uint16
{
func
(
*
LockInformation
)
NEO
MsgCode
()
uint16
{
return
32
return
32
}
}
func
(
p
*
LockInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LockInformation
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
LockInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
LockInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Ttid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Ttid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
LockInformation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
LockInformation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1256,19 +1256,19 @@ overflow:
...
@@ -1256,19 +1256,19 @@ overflow:
// 32 | answerBit. AnswerInformationLocked
// 32 | answerBit. AnswerInformationLocked
func
(
*
AnswerInformationLocked
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerInformationLocked
)
NEO
MsgCode
()
uint16
{
return
32
|
answerBit
return
32
|
answerBit
}
}
func
(
p
*
AnswerInformationLocked
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerInformationLocked
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerInformationLocked
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerInformationLocked
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Ttid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Ttid
))
}
}
func
(
p
*
AnswerInformationLocked
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerInformationLocked
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1281,15 +1281,15 @@ overflow:
...
@@ -1281,15 +1281,15 @@ overflow:
// 34. InvalidateObjects
// 34. InvalidateObjects
func
(
*
InvalidateObjects
)
neo
MsgCode
()
uint16
{
func
(
*
InvalidateObjects
)
NEO
MsgCode
()
uint16
{
return
34
return
34
}
}
func
(
p
*
InvalidateObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
InvalidateObjects
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
OidList
)
*
8
return
12
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
InvalidateObjects
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
InvalidateObjects
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
OidList
))
l
:=
uint32
(
len
(
p
.
OidList
))
...
@@ -1303,7 +1303,7 @@ func (p *InvalidateObjects) neoMsgEncode(data []byte) {
...
@@ -1303,7 +1303,7 @@ func (p *InvalidateObjects) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
InvalidateObjects
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
InvalidateObjects
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -1331,19 +1331,19 @@ overflow:
...
@@ -1331,19 +1331,19 @@ overflow:
// 35. NotifyUnlockInformation
// 35. NotifyUnlockInformation
func
(
*
NotifyUnlockInformation
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyUnlockInformation
)
NEO
MsgCode
()
uint16
{
return
35
return
35
}
}
func
(
p
*
NotifyUnlockInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyUnlockInformation
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
NotifyUnlockInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyUnlockInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
}
}
func
(
p
*
NotifyUnlockInformation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyUnlockInformation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1356,19 +1356,19 @@ overflow:
...
@@ -1356,19 +1356,19 @@ overflow:
// 36. AskNewOIDs
// 36. AskNewOIDs
func
(
*
AskNewOIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AskNewOIDs
)
NEO
MsgCode
()
uint16
{
return
36
return
36
}
}
func
(
p
*
AskNewOIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskNewOIDs
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
AskNewOIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskNewOIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
NumOIDs
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
NumOIDs
)
}
}
func
(
p
*
AskNewOIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AskNewOIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -1381,15 +1381,15 @@ overflow:
...
@@ -1381,15 +1381,15 @@ overflow:
// 36 | answerBit. AnswerNewOIDs
// 36 | answerBit. AnswerNewOIDs
func
(
*
AnswerNewOIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerNewOIDs
)
NEO
MsgCode
()
uint16
{
return
36
|
answerBit
return
36
|
answerBit
}
}
func
(
p
*
AnswerNewOIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerNewOIDs
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
OidList
)
*
8
return
4
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
AnswerNewOIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerNewOIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
OidList
))
l
:=
uint32
(
len
(
p
.
OidList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -1402,7 +1402,7 @@ func (p *AnswerNewOIDs) neoMsgEncode(data []byte) {
...
@@ -1402,7 +1402,7 @@ func (p *AnswerNewOIDs) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerNewOIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerNewOIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -1429,20 +1429,20 @@ overflow:
...
@@ -1429,20 +1429,20 @@ overflow:
// 38. NotifyDeadlock
// 38. NotifyDeadlock
func
(
*
NotifyDeadlock
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyDeadlock
)
NEO
MsgCode
()
uint16
{
return
38
return
38
}
}
func
(
p
*
NotifyDeadlock
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyDeadlock
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
NotifyDeadlock
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyDeadlock
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LockingTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LockingTid
))
}
}
func
(
p
*
NotifyDeadlock
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyDeadlock
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1456,20 +1456,20 @@ overflow:
...
@@ -1456,20 +1456,20 @@ overflow:
// 39. RebaseTransaction
// 39. RebaseTransaction
func
(
*
RebaseTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
RebaseTransaction
)
NEO
MsgCode
()
uint16
{
return
39
return
39
}
}
func
(
p
*
RebaseTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RebaseTransaction
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
RebaseTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
RebaseTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LockingTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LockingTid
))
}
}
func
(
p
*
RebaseTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
RebaseTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1483,15 +1483,15 @@ overflow:
...
@@ -1483,15 +1483,15 @@ overflow:
// 39 | answerBit. AnswerRebaseTransaction
// 39 | answerBit. AnswerRebaseTransaction
func
(
*
AnswerRebaseTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRebaseTransaction
)
NEO
MsgCode
()
uint16
{
return
39
|
answerBit
return
39
|
answerBit
}
}
func
(
p
*
AnswerRebaseTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerRebaseTransaction
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
OidList
)
*
8
return
4
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
AnswerRebaseTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerRebaseTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
OidList
))
l
:=
uint32
(
len
(
p
.
OidList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -1504,7 +1504,7 @@ func (p *AnswerRebaseTransaction) neoMsgEncode(data []byte) {
...
@@ -1504,7 +1504,7 @@ func (p *AnswerRebaseTransaction) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerRebaseTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerRebaseTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -1531,20 +1531,20 @@ overflow:
...
@@ -1531,20 +1531,20 @@ overflow:
// 41. RebaseObject
// 41. RebaseObject
func
(
*
RebaseObject
)
neo
MsgCode
()
uint16
{
func
(
*
RebaseObject
)
NEO
MsgCode
()
uint16
{
return
41
return
41
}
}
func
(
p
*
RebaseObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RebaseObject
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
RebaseObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
RebaseObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Oid
))
}
}
func
(
p
*
RebaseObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
RebaseObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -1558,29 +1558,29 @@ overflow:
...
@@ -1558,29 +1558,29 @@ overflow:
// 41 | answerBit. AnswerRebaseObject
// 41 | answerBit. AnswerRebaseObject
func
(
*
AnswerRebaseObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRebaseObject
)
NEO
MsgCode
()
uint16
{
return
41
|
answerBit
return
41
|
answerBit
}
}
func
(
p
*
AnswerRebaseObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerRebaseObject
)
NEO
MsgEncodedLen
()
int
{
return
41
+
len
(
p
.
Data
)
return
41
+
len
(
p
.
Data
.
XData
()
)
}
}
func
(
p
*
AnswerRebaseObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerRebaseObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
ConflictSerial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
ConflictSerial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
{
{
l
:=
uint32
(
len
(
p
.
Data
))
l
:=
uint32
(
len
(
p
.
Data
.
XData
()
))
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
data
=
data
[
41
:
]
data
=
data
[
41
:
]
copy
(
data
,
p
.
Data
)
copy
(
data
,
p
.
Data
.
XData
()
)
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
}
}
func
(
p
*
AnswerRebaseObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerRebaseObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
41
{
if
len
(
data
)
<
41
{
goto
overflow
goto
overflow
...
@@ -1596,8 +1596,8 @@ func (p *AnswerRebaseObject) neoMsgDecode(data []byte) (int, error) {
...
@@ -1596,8 +1596,8 @@ func (p *AnswerRebaseObject) neoMsgDecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
uint64
(
l
)
nread
+=
uint64
(
l
)
p
.
Data
=
m
ake
([]
byte
,
l
)
p
.
Data
=
m
em
.
BufAlloc
(
int
(
l
)
)
copy
(
p
.
Data
,
data
[
:
l
])
copy
(
p
.
Data
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
return
41
+
int
(
nread
),
nil
return
41
+
int
(
nread
),
nil
...
@@ -1608,15 +1608,15 @@ overflow:
...
@@ -1608,15 +1608,15 @@ overflow:
// 43. StoreObject
// 43. StoreObject
func
(
*
StoreObject
)
neo
MsgCode
()
uint16
{
func
(
*
StoreObject
)
NEO
MsgCode
()
uint16
{
return
43
return
43
}
}
func
(
p
*
StoreObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StoreObject
)
NEO
MsgEncodedLen
()
int
{
return
57
+
len
(
p
.
Data
)
return
57
+
len
(
p
.
Data
)
}
}
func
(
p
*
StoreObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StoreObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
...
@@ -1632,7 +1632,7 @@ func (p *StoreObject) neoMsgEncode(data []byte) {
...
@@ -1632,7 +1632,7 @@ func (p *StoreObject) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
StoreObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
StoreObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
41
{
if
len
(
data
)
<
41
{
goto
overflow
goto
overflow
...
@@ -1662,19 +1662,19 @@ overflow:
...
@@ -1662,19 +1662,19 @@ overflow:
// 43 | answerBit. AnswerStoreObject
// 43 | answerBit. AnswerStoreObject
func
(
*
AnswerStoreObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerStoreObject
)
NEO
MsgCode
()
uint16
{
return
43
|
answerBit
return
43
|
answerBit
}
}
func
(
p
*
AnswerStoreObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerStoreObject
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerStoreObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerStoreObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Conflict
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Conflict
))
}
}
func
(
p
*
AnswerStoreObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerStoreObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1687,15 +1687,15 @@ overflow:
...
@@ -1687,15 +1687,15 @@ overflow:
// 45. AbortTransaction
// 45. AbortTransaction
func
(
*
AbortTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AbortTransaction
)
NEO
MsgCode
()
uint16
{
return
45
return
45
}
}
func
(
p
*
AbortTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AbortTransaction
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
NodeList
)
*
4
return
12
+
len
(
p
.
NodeList
)
*
4
}
}
func
(
p
*
AbortTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AbortTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
...
@@ -1709,7 +1709,7 @@ func (p *AbortTransaction) neoMsgEncode(data []byte) {
...
@@ -1709,7 +1709,7 @@ func (p *AbortTransaction) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AbortTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AbortTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -1737,15 +1737,15 @@ overflow:
...
@@ -1737,15 +1737,15 @@ overflow:
// 46. StoreTransaction
// 46. StoreTransaction
func
(
*
StoreTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
StoreTransaction
)
NEO
MsgCode
()
uint16
{
return
46
return
46
}
}
func
(
p
*
StoreTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StoreTransaction
)
NEO
MsgEncodedLen
()
int
{
return
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
return
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
StoreTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StoreTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
User
))
l
:=
uint32
(
len
(
p
.
User
))
...
@@ -1780,7 +1780,7 @@ func (p *StoreTransaction) neoMsgEncode(data []byte) {
...
@@ -1780,7 +1780,7 @@ func (p *StoreTransaction) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
StoreTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
StoreTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -1838,36 +1838,36 @@ overflow:
...
@@ -1838,36 +1838,36 @@ overflow:
// 46 | answerBit. AnswerStoreTransaction
// 46 | answerBit. AnswerStoreTransaction
func
(
*
AnswerStoreTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerStoreTransaction
)
NEO
MsgCode
()
uint16
{
return
46
|
answerBit
return
46
|
answerBit
}
}
func
(
p
*
AnswerStoreTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerStoreTransaction
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
AnswerStoreTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerStoreTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
AnswerStoreTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerStoreTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 48. VoteTransaction
// 48. VoteTransaction
func
(
*
VoteTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
VoteTransaction
)
NEO
MsgCode
()
uint16
{
return
48
return
48
}
}
func
(
p
*
VoteTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
VoteTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
VoteTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
VoteTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
VoteTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
VoteTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -1880,38 +1880,38 @@ overflow:
...
@@ -1880,38 +1880,38 @@ overflow:
// 48 | answerBit. AnswerVoteTransaction
// 48 | answerBit. AnswerVoteTransaction
func
(
*
AnswerVoteTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerVoteTransaction
)
NEO
MsgCode
()
uint16
{
return
48
|
answerBit
return
48
|
answerBit
}
}
func
(
p
*
AnswerVoteTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerVoteTransaction
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
AnswerVoteTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerVoteTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
AnswerVoteTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerVoteTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 50. GetObject
// 50. GetObject
func
(
*
GetObject
)
neo
MsgCode
()
uint16
{
func
(
*
GetObject
)
NEO
MsgCode
()
uint16
{
return
50
return
50
}
}
func
(
p
*
GetObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
GetObject
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
GetObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
GetObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
GetObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
GetObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -1926,15 +1926,15 @@ overflow:
...
@@ -1926,15 +1926,15 @@ overflow:
// 50 | answerBit. AnswerObject
// 50 | answerBit. AnswerObject
func
(
*
AnswerObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObject
)
NEO
MsgCode
()
uint16
{
return
50
|
answerBit
return
50
|
answerBit
}
}
func
(
p
*
AnswerObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObject
)
NEO
MsgEncodedLen
()
int
{
return
57
+
len
(
p
.
Data
.
XData
())
return
57
+
len
(
p
.
Data
.
XData
())
}
}
func
(
p
*
AnswerObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextSerial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextSerial
))
...
@@ -1950,7 +1950,7 @@ func (p *AnswerObject) neoMsgEncode(data []byte) {
...
@@ -1950,7 +1950,7 @@ func (p *AnswerObject) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
DataSerial
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
DataSerial
))
}
}
func
(
p
*
AnswerObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
49
{
if
len
(
data
)
<
49
{
goto
overflow
goto
overflow
...
@@ -1980,21 +1980,21 @@ overflow:
...
@@ -1980,21 +1980,21 @@ overflow:
// 52. AskTIDs
// 52. AskTIDs
func
(
*
AskTIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AskTIDs
)
NEO
MsgCode
()
uint16
{
return
52
return
52
}
}
func
(
p
*
AskTIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskTIDs
)
NEO
MsgEncodedLen
()
int
{
return
20
return
20
}
}
func
(
p
*
AskTIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskTIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
p
.
First
)
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
p
.
First
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
p
.
Last
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
p
.
Last
)
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
p
.
Partition
)
}
}
func
(
p
*
AskTIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AskTIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
20
{
if
len
(
data
)
<
20
{
goto
overflow
goto
overflow
}
}
...
@@ -2009,15 +2009,15 @@ overflow:
...
@@ -2009,15 +2009,15 @@ overflow:
// 52 | answerBit. AnswerTIDs
// 52 | answerBit. AnswerTIDs
func
(
*
AnswerTIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTIDs
)
NEO
MsgCode
()
uint16
{
return
52
|
answerBit
return
52
|
answerBit
}
}
func
(
p
*
AnswerTIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTIDs
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
TIDList
)
*
8
return
4
+
len
(
p
.
TIDList
)
*
8
}
}
func
(
p
*
AnswerTIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerTIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
TIDList
))
l
:=
uint32
(
len
(
p
.
TIDList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2030,7 +2030,7 @@ func (p *AnswerTIDs) neoMsgEncode(data []byte) {
...
@@ -2030,7 +2030,7 @@ func (p *AnswerTIDs) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerTIDs
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerTIDs
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2057,19 +2057,19 @@ overflow:
...
@@ -2057,19 +2057,19 @@ overflow:
// 54. TransactionInformation
// 54. TransactionInformation
func
(
*
TransactionInformation
)
neo
MsgCode
()
uint16
{
func
(
*
TransactionInformation
)
NEO
MsgCode
()
uint16
{
return
54
return
54
}
}
func
(
p
*
TransactionInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
TransactionInformation
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
TransactionInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
TransactionInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
TransactionInformation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
TransactionInformation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -2082,15 +2082,15 @@ overflow:
...
@@ -2082,15 +2082,15 @@ overflow:
// 54 | answerBit. AnswerTransactionInformation
// 54 | answerBit. AnswerTransactionInformation
func
(
*
AnswerTransactionInformation
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTransactionInformation
)
NEO
MsgCode
()
uint16
{
return
54
|
answerBit
return
54
|
answerBit
}
}
func
(
p
*
AnswerTransactionInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTransactionInformation
)
NEO
MsgEncodedLen
()
int
{
return
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
return
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
AnswerTransactionInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerTransactionInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
User
))
l
:=
uint32
(
len
(
p
.
User
))
...
@@ -2126,7 +2126,7 @@ func (p *AnswerTransactionInformation) neoMsgEncode(data []byte) {
...
@@ -2126,7 +2126,7 @@ func (p *AnswerTransactionInformation) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerTransactionInformation
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerTransactionInformation
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -2185,21 +2185,21 @@ overflow:
...
@@ -2185,21 +2185,21 @@ overflow:
// 56. ObjectHistory
// 56. ObjectHistory
func
(
*
ObjectHistory
)
neo
MsgCode
()
uint16
{
func
(
*
ObjectHistory
)
NEO
MsgCode
()
uint16
{
return
56
return
56
}
}
func
(
p
*
ObjectHistory
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ObjectHistory
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
ObjectHistory
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
ObjectHistory
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
p
.
First
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
p
.
First
)
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
p
.
Last
)
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
p
.
Last
)
}
}
func
(
p
*
ObjectHistory
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
ObjectHistory
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -2214,15 +2214,15 @@ overflow:
...
@@ -2214,15 +2214,15 @@ overflow:
// 56 | answerBit. AnswerObjectHistory
// 56 | answerBit. AnswerObjectHistory
func
(
*
AnswerObjectHistory
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObjectHistory
)
NEO
MsgCode
()
uint16
{
return
56
|
answerBit
return
56
|
answerBit
}
}
func
(
p
*
AnswerObjectHistory
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObjectHistory
)
NEO
MsgEncodedLen
()
int
{
return
12
+
len
(
p
.
HistoryList
)
*
12
return
12
+
len
(
p
.
HistoryList
)
*
12
}
}
func
(
p
*
AnswerObjectHistory
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerObjectHistory
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
{
{
l
:=
uint32
(
len
(
p
.
HistoryList
))
l
:=
uint32
(
len
(
p
.
HistoryList
))
...
@@ -2237,7 +2237,7 @@ func (p *AnswerObjectHistory) neoMsgEncode(data []byte) {
...
@@ -2237,7 +2237,7 @@ func (p *AnswerObjectHistory) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerObjectHistory
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerObjectHistory
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -2269,21 +2269,21 @@ overflow:
...
@@ -2269,21 +2269,21 @@ overflow:
// 58. PartitionList
// 58. PartitionList
func
(
*
PartitionList
)
neo
MsgCode
()
uint16
{
func
(
*
PartitionList
)
NEO
MsgCode
()
uint16
{
return
58
return
58
}
}
func
(
p
*
PartitionList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PartitionList
)
NEO
MsgEncodedLen
()
int
{
return
12
return
12
}
}
func
(
p
*
PartitionList
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
PartitionList
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
MinOffset
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
MinOffset
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
MaxOffset
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
MaxOffset
)
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
uint32
(
int32
(
p
.
NodeUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
uint32
(
int32
(
p
.
NodeUUID
)))
}
}
func
(
p
*
PartitionList
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
PartitionList
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
}
}
...
@@ -2298,11 +2298,11 @@ overflow:
...
@@ -2298,11 +2298,11 @@ overflow:
// 58 | answerBit. AnswerPartitionList
// 58 | answerBit. AnswerPartitionList
func
(
*
AnswerPartitionList
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPartitionList
)
NEO
MsgCode
()
uint16
{
return
58
|
answerBit
return
58
|
answerBit
}
}
func
(
p
*
AnswerPartitionList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPartitionList
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
a
:=
&
p
.
RowList
[
i
]
...
@@ -2311,7 +2311,7 @@ func (p *AnswerPartitionList) neoMsgEncodedLen() int {
...
@@ -2311,7 +2311,7 @@ func (p *AnswerPartitionList) neoMsgEncodedLen() int {
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
12
+
len
(
p
.
RowList
)
*
8
+
size
}
}
func
(
p
*
AnswerPartitionList
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerPartitionList
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PTid
))
{
{
l
:=
uint32
(
len
(
p
.
RowList
))
l
:=
uint32
(
len
(
p
.
RowList
))
...
@@ -2336,7 +2336,7 @@ func (p *AnswerPartitionList) neoMsgEncode(data []byte) {
...
@@ -2336,7 +2336,7 @@ func (p *AnswerPartitionList) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerPartitionList
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerPartitionList
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -2378,19 +2378,19 @@ overflow:
...
@@ -2378,19 +2378,19 @@ overflow:
// 60. NodeList
// 60. NodeList
func
(
*
NodeList
)
neo
MsgCode
()
uint16
{
func
(
*
NodeList
)
NEO
MsgCode
()
uint16
{
return
60
return
60
}
}
func
(
p
*
NodeList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NodeList
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
NodeList
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NodeList
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeType
)))
}
}
func
(
p
*
NodeList
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NodeList
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -2403,11 +2403,11 @@ overflow:
...
@@ -2403,11 +2403,11 @@ overflow:
// 60 | answerBit. AnswerNodeList
// 60 | answerBit. AnswerNodeList
func
(
*
AnswerNodeList
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerNodeList
)
NEO
MsgCode
()
uint16
{
return
60
|
answerBit
return
60
|
answerBit
}
}
func
(
p
*
AnswerNodeList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerNodeList
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
...
@@ -2416,7 +2416,7 @@ func (p *AnswerNodeList) neoMsgEncodedLen() int {
...
@@ -2416,7 +2416,7 @@ func (p *AnswerNodeList) neoMsgEncodedLen() int {
return
4
+
len
(
p
.
NodeList
)
*
12
+
size
return
4
+
len
(
p
.
NodeList
)
*
12
+
size
}
}
func
(
p
*
AnswerNodeList
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerNodeList
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2439,7 +2439,7 @@ func (p *AnswerNodeList) neoMsgEncode(data []byte) {
...
@@ -2439,7 +2439,7 @@ func (p *AnswerNodeList) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerNodeList
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerNodeList
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2488,20 +2488,20 @@ overflow:
...
@@ -2488,20 +2488,20 @@ overflow:
// 62. SetNodeState
// 62. SetNodeState
func
(
*
SetNodeState
)
neo
MsgCode
()
uint16
{
func
(
*
SetNodeState
)
NEO
MsgCode
()
uint16
{
return
62
return
62
}
}
func
(
p
*
SetNodeState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SetNodeState
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
SetNodeState
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
SetNodeState
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
NodeUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
NodeState
)))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
uint32
(
int32
(
p
.
NodeState
)))
}
}
func
(
p
*
SetNodeState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
SetNodeState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -2515,15 +2515,15 @@ overflow:
...
@@ -2515,15 +2515,15 @@ overflow:
// 63. AddPendingNodes
// 63. AddPendingNodes
func
(
*
AddPendingNodes
)
neo
MsgCode
()
uint16
{
func
(
*
AddPendingNodes
)
NEO
MsgCode
()
uint16
{
return
63
return
63
}
}
func
(
p
*
AddPendingNodes
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AddPendingNodes
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
NodeList
)
*
4
return
4
+
len
(
p
.
NodeList
)
*
4
}
}
func
(
p
*
AddPendingNodes
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AddPendingNodes
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2536,7 +2536,7 @@ func (p *AddPendingNodes) neoMsgEncode(data []byte) {
...
@@ -2536,7 +2536,7 @@ func (p *AddPendingNodes) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AddPendingNodes
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AddPendingNodes
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2563,15 +2563,15 @@ overflow:
...
@@ -2563,15 +2563,15 @@ overflow:
// 64. TweakPartitionTable
// 64. TweakPartitionTable
func
(
*
TweakPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
TweakPartitionTable
)
NEO
MsgCode
()
uint16
{
return
64
return
64
}
}
func
(
p
*
TweakPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
TweakPartitionTable
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
NodeList
)
*
4
return
4
+
len
(
p
.
NodeList
)
*
4
}
}
func
(
p
*
TweakPartitionTable
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
TweakPartitionTable
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2584,7 +2584,7 @@ func (p *TweakPartitionTable) neoMsgEncode(data []byte) {
...
@@ -2584,7 +2584,7 @@ func (p *TweakPartitionTable) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
TweakPartitionTable
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
TweakPartitionTable
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2611,19 +2611,19 @@ overflow:
...
@@ -2611,19 +2611,19 @@ overflow:
// 65. SetClusterState
// 65. SetClusterState
func
(
*
SetClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
SetClusterState
)
NEO
MsgCode
()
uint16
{
return
65
return
65
}
}
func
(
p
*
SetClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SetClusterState
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
SetClusterState
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
SetClusterState
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
}
}
func
(
p
*
SetClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
SetClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -2636,15 +2636,15 @@ overflow:
...
@@ -2636,15 +2636,15 @@ overflow:
// 66. Repair
// 66. Repair
func
(
*
Repair
)
neo
MsgCode
()
uint16
{
func
(
*
Repair
)
NEO
MsgCode
()
uint16
{
return
66
return
66
}
}
func
(
p
*
Repair
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Repair
)
NEO
MsgEncodedLen
()
int
{
return
5
+
len
(
p
.
NodeList
)
*
4
return
5
+
len
(
p
.
NodeList
)
*
4
}
}
func
(
p
*
Repair
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Repair
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
NodeList
))
l
:=
uint32
(
len
(
p
.
NodeList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2658,7 +2658,7 @@ func (p *Repair) neoMsgEncode(data []byte) {
...
@@ -2658,7 +2658,7 @@ func (p *Repair) neoMsgEncode(data []byte) {
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
repairFlags
.
DryRun
)
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
repairFlags
.
DryRun
)
}
}
func
(
p
*
Repair
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Repair
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2686,19 +2686,19 @@ overflow:
...
@@ -2686,19 +2686,19 @@ overflow:
// 67. RepairOne
// 67. RepairOne
func
(
*
RepairOne
)
neo
MsgCode
()
uint16
{
func
(
*
RepairOne
)
NEO
MsgCode
()
uint16
{
return
67
return
67
}
}
func
(
p
*
RepairOne
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RepairOne
)
NEO
MsgEncodedLen
()
int
{
return
1
return
1
}
}
func
(
p
*
RepairOne
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
RepairOne
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
repairFlags
.
DryRun
)
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
repairFlags
.
DryRun
)
}
}
func
(
p
*
RepairOne
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
RepairOne
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
1
{
if
len
(
data
)
<
1
{
goto
overflow
goto
overflow
}
}
...
@@ -2711,19 +2711,19 @@ overflow:
...
@@ -2711,19 +2711,19 @@ overflow:
// 68. NotifyClusterState
// 68. NotifyClusterState
func
(
*
NotifyClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyClusterState
)
NEO
MsgCode
()
uint16
{
return
68
return
68
}
}
func
(
p
*
NotifyClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyClusterState
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
NotifyClusterState
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyClusterState
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
}
}
func
(
p
*
NotifyClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -2736,36 +2736,36 @@ overflow:
...
@@ -2736,36 +2736,36 @@ overflow:
// 69. AskClusterState
// 69. AskClusterState
func
(
*
AskClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
AskClusterState
)
NEO
MsgCode
()
uint16
{
return
69
return
69
}
}
func
(
p
*
AskClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskClusterState
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
AskClusterState
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskClusterState
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
AskClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AskClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 69 | answerBit. AnswerClusterState
// 69 | answerBit. AnswerClusterState
func
(
*
AnswerClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerClusterState
)
NEO
MsgCode
()
uint16
{
return
69
|
answerBit
return
69
|
answerBit
}
}
func
(
p
*
AnswerClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerClusterState
)
NEO
MsgEncodedLen
()
int
{
return
4
return
4
}
}
func
(
p
*
AnswerClusterState
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerClusterState
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
State
)))
}
}
func
(
p
*
AnswerClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
}
}
...
@@ -2778,15 +2778,15 @@ overflow:
...
@@ -2778,15 +2778,15 @@ overflow:
// 71. ObjectUndoSerial
// 71. ObjectUndoSerial
func
(
*
ObjectUndoSerial
)
neo
MsgCode
()
uint16
{
func
(
*
ObjectUndoSerial
)
NEO
MsgCode
()
uint16
{
return
71
return
71
}
}
func
(
p
*
ObjectUndoSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ObjectUndoSerial
)
NEO
MsgEncodedLen
()
int
{
return
28
+
len
(
p
.
OidList
)
*
8
return
28
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
ObjectUndoSerial
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
ObjectUndoSerial
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
LTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
UndoneTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
UndoneTID
))
...
@@ -2802,7 +2802,7 @@ func (p *ObjectUndoSerial) neoMsgEncode(data []byte) {
...
@@ -2802,7 +2802,7 @@ func (p *ObjectUndoSerial) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
ObjectUndoSerial
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
ObjectUndoSerial
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
28
{
if
len
(
data
)
<
28
{
goto
overflow
goto
overflow
...
@@ -2832,15 +2832,15 @@ overflow:
...
@@ -2832,15 +2832,15 @@ overflow:
// 71 | answerBit. AnswerObjectUndoSerial
// 71 | answerBit. AnswerObjectUndoSerial
func
(
*
AnswerObjectUndoSerial
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObjectUndoSerial
)
NEO
MsgCode
()
uint16
{
return
71
|
answerBit
return
71
|
answerBit
}
}
func
(
p
*
AnswerObjectUndoSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObjectUndoSerial
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
}
}
func
(
p
*
AnswerObjectUndoSerial
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerObjectUndoSerial
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2860,7 +2860,7 @@ func (p *AnswerObjectUndoSerial) neoMsgEncode(data []byte) {
...
@@ -2860,7 +2860,7 @@ func (p *AnswerObjectUndoSerial) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerObjectUndoSerial
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerObjectUndoSerial
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2900,22 +2900,22 @@ overflow:
...
@@ -2900,22 +2900,22 @@ overflow:
// 73. AskTIDsFrom
// 73. AskTIDsFrom
func
(
*
AskTIDsFrom
)
neo
MsgCode
()
uint16
{
func
(
*
AskTIDsFrom
)
NEO
MsgCode
()
uint16
{
return
73
return
73
}
}
func
(
p
*
AskTIDsFrom
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskTIDsFrom
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
AskTIDsFrom
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskTIDsFrom
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
20
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
20
:
],
p
.
Partition
)
}
}
func
(
p
*
AskTIDsFrom
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AskTIDsFrom
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -2931,15 +2931,15 @@ overflow:
...
@@ -2931,15 +2931,15 @@ overflow:
// 73 | answerBit. AnswerTIDsFrom
// 73 | answerBit. AnswerTIDsFrom
func
(
*
AnswerTIDsFrom
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTIDsFrom
)
NEO
MsgCode
()
uint16
{
return
73
|
answerBit
return
73
|
answerBit
}
}
func
(
p
*
AnswerTIDsFrom
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTIDsFrom
)
NEO
MsgEncodedLen
()
int
{
return
4
+
len
(
p
.
TidList
)
*
8
return
4
+
len
(
p
.
TidList
)
*
8
}
}
func
(
p
*
AnswerTIDsFrom
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerTIDsFrom
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
TidList
))
l
:=
uint32
(
len
(
p
.
TidList
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -2952,7 +2952,7 @@ func (p *AnswerTIDsFrom) neoMsgEncode(data []byte) {
...
@@ -2952,7 +2952,7 @@ func (p *AnswerTIDsFrom) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerTIDsFrom
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerTIDsFrom
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -2979,19 +2979,19 @@ overflow:
...
@@ -2979,19 +2979,19 @@ overflow:
// 75. Pack
// 75. Pack
func
(
*
Pack
)
neo
MsgCode
()
uint16
{
func
(
*
Pack
)
NEO
MsgCode
()
uint16
{
return
75
return
75
}
}
func
(
p
*
Pack
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Pack
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
Pack
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Pack
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
Pack
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Pack
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -3004,19 +3004,19 @@ overflow:
...
@@ -3004,19 +3004,19 @@ overflow:
// 75 | answerBit. AnswerPack
// 75 | answerBit. AnswerPack
func
(
*
AnswerPack
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPack
)
NEO
MsgCode
()
uint16
{
return
75
|
answerBit
return
75
|
answerBit
}
}
func
(
p
*
AnswerPack
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPack
)
NEO
MsgEncodedLen
()
int
{
return
1
return
1
}
}
func
(
p
*
AnswerPack
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerPack
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
Status
)
(
data
[
0
:
])[
0
]
=
bool2byte
(
p
.
Status
)
}
}
func
(
p
*
AnswerPack
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerPack
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
1
{
if
len
(
data
)
<
1
{
goto
overflow
goto
overflow
}
}
...
@@ -3029,15 +3029,15 @@ overflow:
...
@@ -3029,15 +3029,15 @@ overflow:
// 77. CheckReplicas
// 77. CheckReplicas
func
(
*
CheckReplicas
)
neo
MsgCode
()
uint16
{
func
(
*
CheckReplicas
)
NEO
MsgCode
()
uint16
{
return
77
return
77
}
}
func
(
p
*
CheckReplicas
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckReplicas
)
NEO
MsgEncodedLen
()
int
{
return
20
+
len
(
p
.
PartitionDict
)
*
8
return
20
+
len
(
p
.
PartitionDict
)
*
8
}
}
func
(
p
*
CheckReplicas
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CheckReplicas
)
NEO
MsgEncode
(
data
[]
byte
)
{
{
{
l
:=
uint32
(
len
(
p
.
PartitionDict
))
l
:=
uint32
(
len
(
p
.
PartitionDict
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
@@ -3057,7 +3057,7 @@ func (p *CheckReplicas) neoMsgEncode(data []byte) {
...
@@ -3057,7 +3057,7 @@ func (p *CheckReplicas) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
}
}
func
(
p
*
CheckReplicas
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CheckReplicas
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
goto
overflow
goto
overflow
...
@@ -3087,15 +3087,15 @@ overflow:
...
@@ -3087,15 +3087,15 @@ overflow:
// 78. CheckPartition
// 78. CheckPartition
func
(
*
CheckPartition
)
neo
MsgCode
()
uint16
{
func
(
*
CheckPartition
)
NEO
MsgCode
()
uint16
{
return
78
return
78
}
}
func
(
p
*
CheckPartition
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckPartition
)
NEO
MsgEncodedLen
()
int
{
return
24
+
len
(
p
.
Source
.
UpstreamName
)
+
p
.
Source
.
Address
.
neoEncodedLen
()
return
24
+
len
(
p
.
Source
.
UpstreamName
)
+
p
.
Source
.
Address
.
neoEncodedLen
()
}
}
func
(
p
*
CheckPartition
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CheckPartition
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
{
{
l
:=
uint32
(
len
(
p
.
Source
.
UpstreamName
))
l
:=
uint32
(
len
(
p
.
Source
.
UpstreamName
))
...
@@ -3112,7 +3112,7 @@ func (p *CheckPartition) neoMsgEncode(data []byte) {
...
@@ -3112,7 +3112,7 @@ func (p *CheckPartition) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
}
}
func
(
p
*
CheckPartition
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CheckPartition
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
...
@@ -3149,22 +3149,22 @@ overflow:
...
@@ -3149,22 +3149,22 @@ overflow:
// 79. CheckTIDRange
// 79. CheckTIDRange
func
(
*
CheckTIDRange
)
neo
MsgCode
()
uint16
{
func
(
*
CheckTIDRange
)
NEO
MsgCode
()
uint16
{
return
79
return
79
}
}
func
(
p
*
CheckTIDRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckTIDRange
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
CheckTIDRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CheckTIDRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
MaxTID
))
}
}
func
(
p
*
CheckTIDRange
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CheckTIDRange
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -3180,21 +3180,21 @@ overflow:
...
@@ -3180,21 +3180,21 @@ overflow:
// 79 | answerBit. AnswerCheckTIDRange
// 79 | answerBit. AnswerCheckTIDRange
func
(
*
AnswerCheckTIDRange
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckTIDRange
)
NEO
MsgCode
()
uint16
{
return
79
|
answerBit
return
79
|
answerBit
}
}
func
(
p
*
AnswerCheckTIDRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckTIDRange
)
NEO
MsgEncodedLen
()
int
{
return
32
return
32
}
}
func
(
p
*
AnswerCheckTIDRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerCheckTIDRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
copy
(
data
[
4
:
],
p
.
Checksum
[
:
])
copy
(
data
[
4
:
],
p
.
Checksum
[
:
])
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MaxTID
))
}
}
func
(
p
*
AnswerCheckTIDRange
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerCheckTIDRange
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
32
{
if
len
(
data
)
<
32
{
goto
overflow
goto
overflow
}
}
...
@@ -3209,15 +3209,15 @@ overflow:
...
@@ -3209,15 +3209,15 @@ overflow:
// 81. CheckSerialRange
// 81. CheckSerialRange
func
(
*
CheckSerialRange
)
neo
MsgCode
()
uint16
{
func
(
*
CheckSerialRange
)
NEO
MsgCode
()
uint16
{
return
81
return
81
}
}
func
(
p
*
CheckSerialRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckSerialRange
)
NEO
MsgEncodedLen
()
int
{
return
32
return
32
}
}
func
(
p
*
CheckSerialRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CheckSerialRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
...
@@ -3225,7 +3225,7 @@ func (p *CheckSerialRange) neoMsgEncode(data []byte) {
...
@@ -3225,7 +3225,7 @@ func (p *CheckSerialRange) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MinOID
))
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MinOID
))
}
}
func
(
p
*
CheckSerialRange
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CheckSerialRange
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
32
{
if
len
(
data
)
<
32
{
goto
overflow
goto
overflow
}
}
...
@@ -3242,15 +3242,15 @@ overflow:
...
@@ -3242,15 +3242,15 @@ overflow:
// 81 | answerBit. AnswerCheckSerialRange
// 81 | answerBit. AnswerCheckSerialRange
func
(
*
AnswerCheckSerialRange
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckSerialRange
)
NEO
MsgCode
()
uint16
{
return
81
|
answerBit
return
81
|
answerBit
}
}
func
(
p
*
AnswerCheckSerialRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckSerialRange
)
NEO
MsgEncodedLen
()
int
{
return
60
return
60
}
}
func
(
p
*
AnswerCheckSerialRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerCheckSerialRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
copy
(
data
[
4
:
],
p
.
TidChecksum
[
:
])
copy
(
data
[
4
:
],
p
.
TidChecksum
[
:
])
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MaxTID
))
...
@@ -3258,7 +3258,7 @@ func (p *AnswerCheckSerialRange) neoMsgEncode(data []byte) {
...
@@ -3258,7 +3258,7 @@ func (p *AnswerCheckSerialRange) neoMsgEncode(data []byte) {
binary
.
BigEndian
.
PutUint64
(
data
[
52
:
],
uint64
(
p
.
MaxOID
))
binary
.
BigEndian
.
PutUint64
(
data
[
52
:
],
uint64
(
p
.
MaxOID
))
}
}
func
(
p
*
AnswerCheckSerialRange
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerCheckSerialRange
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
60
{
if
len
(
data
)
<
60
{
goto
overflow
goto
overflow
}
}
...
@@ -3275,15 +3275,15 @@ overflow:
...
@@ -3275,15 +3275,15 @@ overflow:
// 83. PartitionCorrupted
// 83. PartitionCorrupted
func
(
*
PartitionCorrupted
)
neo
MsgCode
()
uint16
{
func
(
*
PartitionCorrupted
)
NEO
MsgCode
()
uint16
{
return
83
return
83
}
}
func
(
p
*
PartitionCorrupted
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PartitionCorrupted
)
NEO
MsgEncodedLen
()
int
{
return
8
+
len
(
p
.
CellList
)
*
4
return
8
+
len
(
p
.
CellList
)
*
4
}
}
func
(
p
*
PartitionCorrupted
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
PartitionCorrupted
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
{
{
l
:=
uint32
(
len
(
p
.
CellList
))
l
:=
uint32
(
len
(
p
.
CellList
))
...
@@ -3297,7 +3297,7 @@ func (p *PartitionCorrupted) neoMsgEncode(data []byte) {
...
@@ -3297,7 +3297,7 @@ func (p *PartitionCorrupted) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
PartitionCorrupted
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
PartitionCorrupted
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
...
@@ -3325,53 +3325,53 @@ overflow:
...
@@ -3325,53 +3325,53 @@ overflow:
// 84. NotifyReady
// 84. NotifyReady
func
(
*
NotifyReady
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyReady
)
NEO
MsgCode
()
uint16
{
return
84
return
84
}
}
func
(
p
*
NotifyReady
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyReady
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
NotifyReady
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyReady
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
NotifyReady
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyReady
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 85. LastTransaction
// 85. LastTransaction
func
(
*
LastTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
LastTransaction
)
NEO
MsgCode
()
uint16
{
return
85
return
85
}
}
func
(
p
*
LastTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LastTransaction
)
NEO
MsgEncodedLen
()
int
{
return
0
return
0
}
}
func
(
p
*
LastTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
LastTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
}
}
func
(
p
*
LastTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
LastTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
}
}
// 85 | answerBit. AnswerLastTransaction
// 85 | answerBit. AnswerLastTransaction
func
(
*
AnswerLastTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLastTransaction
)
NEO
MsgCode
()
uint16
{
return
85
|
answerBit
return
85
|
answerBit
}
}
func
(
p
*
AnswerLastTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLastTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerLastTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLastTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
AnswerLastTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerLastTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -3384,21 +3384,21 @@ overflow:
...
@@ -3384,21 +3384,21 @@ overflow:
// 87. CheckCurrentSerial
// 87. CheckCurrentSerial
func
(
*
CheckCurrentSerial
)
neo
MsgCode
()
uint16
{
func
(
*
CheckCurrentSerial
)
NEO
MsgCode
()
uint16
{
return
87
return
87
}
}
func
(
p
*
CheckCurrentSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckCurrentSerial
)
NEO
MsgEncodedLen
()
int
{
return
24
return
24
}
}
func
(
p
*
CheckCurrentSerial
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
CheckCurrentSerial
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
Serial
))
}
}
func
(
p
*
CheckCurrentSerial
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
CheckCurrentSerial
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
24
{
if
len
(
data
)
<
24
{
goto
overflow
goto
overflow
}
}
...
@@ -3413,19 +3413,19 @@ overflow:
...
@@ -3413,19 +3413,19 @@ overflow:
// 87 | answerBit. AnswerCheckCurrentSerial
// 87 | answerBit. AnswerCheckCurrentSerial
func
(
*
AnswerCheckCurrentSerial
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckCurrentSerial
)
NEO
MsgCode
()
uint16
{
return
87
|
answerBit
return
87
|
answerBit
}
}
func
(
p
*
AnswerCheckCurrentSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
AnswerCheckCurrentSerial
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
AnswerStoreObject
.
Conflict
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
AnswerStoreObject
.
Conflict
))
}
}
func
(
p
*
AnswerCheckCurrentSerial
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
@@ -3438,20 +3438,20 @@ overflow:
...
@@ -3438,20 +3438,20 @@ overflow:
// 89. NotifyTransactionFinished
// 89. NotifyTransactionFinished
func
(
*
NotifyTransactionFinished
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyTransactionFinished
)
NEO
MsgCode
()
uint16
{
return
89
return
89
}
}
func
(
p
*
NotifyTransactionFinished
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyTransactionFinished
)
NEO
MsgEncodedLen
()
int
{
return
16
return
16
}
}
func
(
p
*
NotifyTransactionFinished
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyTransactionFinished
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
TTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MaxTID
))
}
}
func
(
p
*
NotifyTransactionFinished
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyTransactionFinished
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
16
{
if
len
(
data
)
<
16
{
goto
overflow
goto
overflow
}
}
...
@@ -3465,11 +3465,11 @@ overflow:
...
@@ -3465,11 +3465,11 @@ overflow:
// 90. Replicate
// 90. Replicate
func
(
*
Replicate
)
neo
MsgCode
()
uint16
{
func
(
*
Replicate
)
NEO
MsgCode
()
uint16
{
return
90
return
90
}
}
func
(
p
*
Replicate
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Replicate
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
key
:=
range
p
.
SourceDict
{
for
key
:=
range
p
.
SourceDict
{
size
+=
len
(
p
.
SourceDict
[
key
])
size
+=
len
(
p
.
SourceDict
[
key
])
...
@@ -3477,7 +3477,7 @@ func (p *Replicate) neoMsgEncodedLen() int {
...
@@ -3477,7 +3477,7 @@ func (p *Replicate) neoMsgEncodedLen() int {
return
16
+
len
(
p
.
UpstreamName
)
+
len
(
p
.
SourceDict
)
*
8
+
size
return
16
+
len
(
p
.
UpstreamName
)
+
len
(
p
.
SourceDict
)
*
8
+
size
}
}
func
(
p
*
Replicate
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Replicate
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
UpstreamName
))
l
:=
uint32
(
len
(
p
.
UpstreamName
))
...
@@ -3509,7 +3509,7 @@ func (p *Replicate) neoMsgEncode(data []byte) {
...
@@ -3509,7 +3509,7 @@ func (p *Replicate) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
Replicate
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Replicate
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -3556,20 +3556,20 @@ overflow:
...
@@ -3556,20 +3556,20 @@ overflow:
// 91. ReplicationDone
// 91. ReplicationDone
func
(
*
ReplicationDone
)
neo
MsgCode
()
uint16
{
func
(
*
ReplicationDone
)
NEO
MsgCode
()
uint16
{
return
91
return
91
}
}
func
(
p
*
ReplicationDone
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ReplicationDone
)
NEO
MsgEncodedLen
()
int
{
return
12
return
12
}
}
func
(
p
*
ReplicationDone
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
ReplicationDone
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Offset
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Offset
)
binary
.
BigEndian
.
PutUint64
(
data
[
4
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
4
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
ReplicationDone
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
ReplicationDone
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
}
}
...
@@ -3583,15 +3583,15 @@ overflow:
...
@@ -3583,15 +3583,15 @@ overflow:
// 92. FetchTransactions
// 92. FetchTransactions
func
(
*
FetchTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
FetchTransactions
)
NEO
MsgCode
()
uint16
{
return
92
return
92
}
}
func
(
p
*
FetchTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FetchTransactions
)
NEO
MsgEncodedLen
()
int
{
return
28
+
len
(
p
.
TxnKnownList
)
*
8
return
28
+
len
(
p
.
TxnKnownList
)
*
8
}
}
func
(
p
*
FetchTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FetchTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
...
@@ -3608,7 +3608,7 @@ func (p *FetchTransactions) neoMsgEncode(data []byte) {
...
@@ -3608,7 +3608,7 @@ func (p *FetchTransactions) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
FetchTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
FetchTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
28
{
if
len
(
data
)
<
28
{
goto
overflow
goto
overflow
...
@@ -3639,15 +3639,15 @@ overflow:
...
@@ -3639,15 +3639,15 @@ overflow:
// 92 | answerBit. AnswerFetchTransactions
// 92 | answerBit. AnswerFetchTransactions
func
(
*
AnswerFetchTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFetchTransactions
)
NEO
MsgCode
()
uint16
{
return
92
|
answerBit
return
92
|
answerBit
}
}
func
(
p
*
AnswerFetchTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFetchTransactions
)
NEO
MsgEncodedLen
()
int
{
return
20
+
len
(
p
.
TxnDeleteList
)
*
8
return
20
+
len
(
p
.
TxnDeleteList
)
*
8
}
}
func
(
p
*
AnswerFetchTransactions
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerFetchTransactions
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
{
{
...
@@ -3662,7 +3662,7 @@ func (p *AnswerFetchTransactions) neoMsgEncode(data []byte) {
...
@@ -3662,7 +3662,7 @@ func (p *AnswerFetchTransactions) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerFetchTransactions
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerFetchTransactions
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
20
{
if
len
(
data
)
<
20
{
goto
overflow
goto
overflow
...
@@ -3691,11 +3691,11 @@ overflow:
...
@@ -3691,11 +3691,11 @@ overflow:
// 94. FetchObjects
// 94. FetchObjects
func
(
*
FetchObjects
)
neo
MsgCode
()
uint16
{
func
(
*
FetchObjects
)
NEO
MsgCode
()
uint16
{
return
94
return
94
}
}
func
(
p
*
FetchObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FetchObjects
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
key
:=
range
p
.
ObjKnownDict
{
for
key
:=
range
p
.
ObjKnownDict
{
size
+=
len
(
p
.
ObjKnownDict
[
key
])
*
8
size
+=
len
(
p
.
ObjKnownDict
[
key
])
*
8
...
@@ -3703,7 +3703,7 @@ func (p *FetchObjects) neoMsgEncodedLen() int {
...
@@ -3703,7 +3703,7 @@ func (p *FetchObjects) neoMsgEncodedLen() int {
return
36
+
len
(
p
.
ObjKnownDict
)
*
12
+
size
return
36
+
len
(
p
.
ObjKnownDict
)
*
12
+
size
}
}
func
(
p
*
FetchObjects
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FetchObjects
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Partition
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
...
@@ -3735,7 +3735,7 @@ func (p *FetchObjects) neoMsgEncode(data []byte) {
...
@@ -3735,7 +3735,7 @@ func (p *FetchObjects) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
FetchObjects
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
FetchObjects
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
36
{
if
len
(
data
)
<
36
{
goto
overflow
goto
overflow
...
@@ -3782,11 +3782,11 @@ overflow:
...
@@ -3782,11 +3782,11 @@ overflow:
// 94 | answerBit. AnswerFetchObjects
// 94 | answerBit. AnswerFetchObjects
func
(
*
AnswerFetchObjects
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFetchObjects
)
NEO
MsgCode
()
uint16
{
return
94
|
answerBit
return
94
|
answerBit
}
}
func
(
p
*
AnswerFetchObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFetchObjects
)
NEO
MsgEncodedLen
()
int
{
var
size
int
var
size
int
for
key
:=
range
p
.
ObjDeleteDict
{
for
key
:=
range
p
.
ObjDeleteDict
{
size
+=
len
(
p
.
ObjDeleteDict
[
key
])
*
8
size
+=
len
(
p
.
ObjDeleteDict
[
key
])
*
8
...
@@ -3794,7 +3794,7 @@ func (p *AnswerFetchObjects) neoMsgEncodedLen() int {
...
@@ -3794,7 +3794,7 @@ func (p *AnswerFetchObjects) neoMsgEncodedLen() int {
return
28
+
len
(
p
.
ObjDeleteDict
)
*
12
+
size
return
28
+
len
(
p
.
ObjDeleteDict
)
*
12
+
size
}
}
func
(
p
*
AnswerFetchObjects
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerFetchObjects
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
PackTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
NextTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextOid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextOid
))
...
@@ -3824,7 +3824,7 @@ func (p *AnswerFetchObjects) neoMsgEncode(data []byte) {
...
@@ -3824,7 +3824,7 @@ func (p *AnswerFetchObjects) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AnswerFetchObjects
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerFetchObjects
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
28
{
if
len
(
data
)
<
28
{
goto
overflow
goto
overflow
...
@@ -3869,15 +3869,15 @@ overflow:
...
@@ -3869,15 +3869,15 @@ overflow:
// 96. AddTransaction
// 96. AddTransaction
func
(
*
AddTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AddTransaction
)
NEO
MsgCode
()
uint16
{
return
96
return
96
}
}
func
(
p
*
AddTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AddTransaction
)
NEO
MsgEncodedLen
()
int
{
return
33
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
return
33
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
}
}
func
(
p
*
AddTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AddTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
{
l
:=
uint32
(
len
(
p
.
User
))
l
:=
uint32
(
len
(
p
.
User
))
...
@@ -3914,7 +3914,7 @@ func (p *AddTransaction) neoMsgEncode(data []byte) {
...
@@ -3914,7 +3914,7 @@ func (p *AddTransaction) neoMsgEncode(data []byte) {
}
}
}
}
func
(
p
*
AddTransaction
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AddTransaction
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
12
{
if
len
(
data
)
<
12
{
goto
overflow
goto
overflow
...
@@ -3974,30 +3974,30 @@ overflow:
...
@@ -3974,30 +3974,30 @@ overflow:
// 97. AddObject
// 97. AddObject
func
(
*
AddObject
)
neo
MsgCode
()
uint16
{
func
(
*
AddObject
)
NEO
MsgCode
()
uint16
{
return
97
return
97
}
}
func
(
p
*
AddObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AddObject
)
NEO
MsgEncodedLen
()
int
{
return
49
+
len
(
p
.
Data
)
return
49
+
len
(
p
.
Data
.
XData
()
)
}
}
func
(
p
*
AddObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AddObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
{
{
l
:=
uint32
(
len
(
p
.
Data
))
l
:=
uint32
(
len
(
p
.
Data
.
XData
()
))
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
data
=
data
[
41
:
]
data
=
data
[
41
:
]
copy
(
data
,
p
.
Data
)
copy
(
data
,
p
.
Data
.
XData
()
)
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
DataSerial
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
DataSerial
))
}
}
func
(
p
*
AddObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AddObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
var
nread
uint64
if
len
(
data
)
<
41
{
if
len
(
data
)
<
41
{
goto
overflow
goto
overflow
...
@@ -4013,8 +4013,8 @@ func (p *AddObject) neoMsgDecode(data []byte) (int, error) {
...
@@ -4013,8 +4013,8 @@ func (p *AddObject) neoMsgDecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
8
+
uint64
(
l
)
nread
+=
8
+
uint64
(
l
)
p
.
Data
=
m
ake
([]
byte
,
l
)
p
.
Data
=
m
em
.
BufAlloc
(
int
(
l
)
)
copy
(
p
.
Data
,
data
[
:
l
])
copy
(
p
.
Data
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
p
.
DataSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
0
+
8
]))
p
.
DataSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
0
+
8
]))
...
@@ -4026,19 +4026,19 @@ overflow:
...
@@ -4026,19 +4026,19 @@ overflow:
// 98. Truncate
// 98. Truncate
func
(
*
Truncate
)
neo
MsgCode
()
uint16
{
func
(
*
Truncate
)
NEO
MsgCode
()
uint16
{
return
98
return
98
}
}
func
(
p
*
Truncate
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Truncate
)
NEO
MsgEncodedLen
()
int
{
return
8
return
8
}
}
func
(
p
*
Truncate
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Truncate
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
}
}
func
(
p
*
Truncate
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
Truncate
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
if
len
(
data
)
<
8
{
goto
overflow
goto
overflow
}
}
...
...
go/neo/zproto-str.go
→
go/neo/
proto/
zproto-str.go
View file @
47f069a5
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go
packed.go
"; DO NOT EDIT.
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go"; DO NOT EDIT.
package
ne
o
package
prot
o
import
"fmt"
import
"fmt"
...
...
go/neo/ztestdata_proto_py_test.go
→
go/neo/
proto/
ztestdata_proto_py_test.go
View file @
47f069a5
// Code generated by ./py/pyneo-gen-testdata; DO NOT EDIT.
// Code generated by ./py/pyneo-gen-testdata; DO NOT EDIT.
package
ne
o
package
prot
o
var
pyMsgRegistry
=
map
[
uint16
]
string
{
var
pyMsgRegistry
=
map
[
uint16
]
string
{
1
:
"RequestIdentification"
,
1
:
"RequestIdentification"
,
...
...
go/neo/proto/ztrace.go
0 → 100644
View file @
47f069a5
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
package
proto
// code generated for tracepoints
import
(
"lab.nexedi.com/kirr/go123/tracing"
"unsafe"
)
// traceevent: traceClusterStateChanged(cs *ClusterState)
type
_t_traceClusterStateChanged
struct
{
tracing
.
Probe
probefunc
func
(
cs
*
ClusterState
)
}
var
_traceClusterStateChanged
*
_t_traceClusterStateChanged
func
traceClusterStateChanged
(
cs
*
ClusterState
)
{
if
_traceClusterStateChanged
!=
nil
{
_traceClusterStateChanged_run
(
cs
)
}
}
func
_traceClusterStateChanged_run
(
cs
*
ClusterState
)
{
for
p
:=
_traceClusterStateChanged
;
p
!=
nil
;
p
=
(
*
_t_traceClusterStateChanged
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
cs
)
}
}
func
traceClusterStateChanged_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
cs
*
ClusterState
))
*
tracing
.
Probe
{
p
:=
_t_traceClusterStateChanged
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceClusterStateChanged
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// trace export signature
func
_trace_exporthash_20c3e52fbfabe08e304139ab4a6bbf7c569f0994
()
{}
go/neo/server/cluster_test.go
View file @
47f069a5
...
@@ -38,6 +38,7 @@ import (
...
@@ -38,6 +38,7 @@ import (
//"github.com/kylelemons/godebug/pretty"
//"github.com/kylelemons/godebug/pretty"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/client"
"lab.nexedi.com/kirr/neo/go/neo/client"
//"lab.nexedi.com/kirr/neo/go/neo/internal/common"
//"lab.nexedi.com/kirr/neo/go/neo/internal/common"
...
@@ -77,17 +78,17 @@ type eventNetListen struct {
...
@@ -77,17 +78,17 @@ type eventNetListen struct {
type
eventNeoSend
struct
{
type
eventNeoSend
struct
{
Src
,
Dst
string
Src
,
Dst
string
ConnID
uint32
ConnID
uint32
Msg
ne
o
.
Msg
Msg
prot
o
.
Msg
}
}
// event: cluster state changed
// event: cluster state changed
type
eventClusterState
struct
{
type
eventClusterState
struct
{
//Ptr *neo.ClusterState // pointer to variable which holds the state
//Ptr *neo.ClusterState // pointer to variable which holds the state
Where
string
Where
string
State
ne
o
.
ClusterState
State
prot
o
.
ClusterState
}
}
func
clusterState
(
where
string
,
v
ne
o
.
ClusterState
)
*
eventClusterState
{
func
clusterState
(
where
string
,
v
prot
o
.
ClusterState
)
*
eventClusterState
{
return
&
eventClusterState
{
where
,
v
}
return
&
eventClusterState
{
where
,
v
}
}
}
...
@@ -95,7 +96,7 @@ func clusterState(where string, v neo.ClusterState) *eventClusterState {
...
@@ -95,7 +96,7 @@ func clusterState(where string, v neo.ClusterState) *eventClusterState {
type
eventNodeTab
struct
{
type
eventNodeTab
struct
{
//NodeTab unsafe.Pointer // *neo.NodeTable XXX not to noise test diff
//NodeTab unsafe.Pointer // *neo.NodeTable XXX not to noise test diff
Where
string
// host of running node XXX ok? XXX -> TabName?
Where
string
// host of running node XXX ok? XXX -> TabName?
NodeInfo
ne
o
.
NodeInfo
NodeInfo
prot
o
.
NodeInfo
}
}
// event: master ready to start changed
// event: master ready to start changed
...
@@ -293,7 +294,7 @@ type TraceCollector struct {
...
@@ -293,7 +294,7 @@ type TraceCollector struct {
node2Name
map
[
*
neo
.
NodeApp
]
string
node2Name
map
[
*
neo
.
NodeApp
]
string
nodeTab2Owner
map
[
*
neo
.
NodeTable
]
string
nodeTab2Owner
map
[
*
neo
.
NodeTable
]
string
clusterState2Owner
map
[
*
ne
o
.
ClusterState
]
string
clusterState2Owner
map
[
*
prot
o
.
ClusterState
]
string
}
}
func
NewTraceCollector
(
dispatch
*
tsync
.
EventDispatcher
)
*
TraceCollector
{
func
NewTraceCollector
(
dispatch
*
tsync
.
EventDispatcher
)
*
TraceCollector
{
...
@@ -303,18 +304,19 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
...
@@ -303,18 +304,19 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
node2Name
:
make
(
map
[
*
neo
.
NodeApp
]
string
),
node2Name
:
make
(
map
[
*
neo
.
NodeApp
]
string
),
nodeTab2Owner
:
make
(
map
[
*
neo
.
NodeTable
]
string
),
nodeTab2Owner
:
make
(
map
[
*
neo
.
NodeTable
]
string
),
clusterState2Owner
:
make
(
map
[
*
ne
o
.
ClusterState
]
string
),
clusterState2Owner
:
make
(
map
[
*
prot
o
.
ClusterState
]
string
),
}
}
}
}
//trace:import "lab.nexedi.com/kirr/neo/go/neo"
//trace:import "lab.nexedi.com/kirr/neo/go/neo"
//trace:import "lab.nexedi.com/kirr/neo/go/neo/proto"
// Attach attaches the tracer to appropriate trace points.
// Attach attaches the tracer to appropriate trace points.
func
(
t
*
TraceCollector
)
Attach
()
{
func
(
t
*
TraceCollector
)
Attach
()
{
tracing
.
Lock
()
tracing
.
Lock
()
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
neo_traceMsgSendPre_Attach
(
t
.
pg
,
t
.
traceNeoMsgSendPre
)
neo_traceMsgSendPre_Attach
(
t
.
pg
,
t
.
traceNeoMsgSendPre
)
ne
o_traceClusterStateChanged_Attach
(
t
.
pg
,
t
.
traceClusterState
)
prot
o_traceClusterStateChanged_Attach
(
t
.
pg
,
t
.
traceClusterState
)
neo_traceNodeChanged_Attach
(
t
.
pg
,
t
.
traceNode
)
neo_traceNodeChanged_Attach
(
t
.
pg
,
t
.
traceNode
)
traceMasterStartReady_Attach
(
t
.
pg
,
t
.
traceMasterStartReady
)
traceMasterStartReady_Attach
(
t
.
pg
,
t
.
traceMasterStartReady
)
tracing
.
Unlock
()
tracing
.
Unlock
()
...
@@ -354,11 +356,11 @@ func (t *TraceCollector) TraceNetListen(ev *xnet.TraceListen) {
...
@@ -354,11 +356,11 @@ func (t *TraceCollector) TraceNetListen(ev *xnet.TraceListen) {
func
(
t
*
TraceCollector
)
TraceNetTx
(
ev
*
xnet
.
TraceTx
)
{}
// we use traceNeoMsgSend instead
func
(
t
*
TraceCollector
)
TraceNetTx
(
ev
*
xnet
.
TraceTx
)
{}
// we use traceNeoMsgSend instead
func
(
t
*
TraceCollector
)
traceNeoMsgSendPre
(
l
*
neo
.
NodeLink
,
connID
uint32
,
msg
ne
o
.
Msg
)
{
func
(
t
*
TraceCollector
)
traceNeoMsgSendPre
(
l
*
neo
.
NodeLink
,
connID
uint32
,
msg
prot
o
.
Msg
)
{
t
.
d
.
Dispatch
(
&
eventNeoSend
{
l
.
LocalAddr
()
.
String
(),
l
.
RemoteAddr
()
.
String
(),
connID
,
msg
})
t
.
d
.
Dispatch
(
&
eventNeoSend
{
l
.
LocalAddr
()
.
String
(),
l
.
RemoteAddr
()
.
String
(),
connID
,
msg
})
}
}
func
(
t
*
TraceCollector
)
traceClusterState
(
cs
*
ne
o
.
ClusterState
)
{
func
(
t
*
TraceCollector
)
traceClusterState
(
cs
*
prot
o
.
ClusterState
)
{
//t.d.Dispatch(&eventClusterState{cs, *cs})
//t.d.Dispatch(&eventClusterState{cs, *cs})
where
:=
t
.
clusterState2Owner
[
cs
]
where
:=
t
.
clusterState2Owner
[
cs
]
t
.
d
.
Dispatch
(
&
eventClusterState
{
where
,
*
cs
})
t
.
d
.
Dispatch
(
&
eventClusterState
{
where
,
*
cs
})
...
@@ -400,11 +402,11 @@ func TestMasterStorage(t *testing.T) {
...
@@ -400,11 +402,11 @@ func TestMasterStorage(t *testing.T) {
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
return
a
return
a
}
}
xnaddr
:=
func
(
addr
string
)
ne
o
.
Address
{
xnaddr
:=
func
(
addr
string
)
prot
o
.
Address
{
if
addr
==
""
{
if
addr
==
""
{
return
ne
o
.
Address
{}
return
prot
o
.
Address
{}
}
}
a
,
err
:=
ne
o
.
Addr
(
xaddr
(
addr
))
a
,
err
:=
prot
o
.
Addr
(
xaddr
(
addr
))
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
return
a
return
a
}
}
...
@@ -419,23 +421,23 @@ func TestMasterStorage(t *testing.T) {
...
@@ -419,23 +421,23 @@ func TestMasterStorage(t *testing.T) {
}
}
// shortcut for net tx event over nodelink connection
// shortcut for net tx event over nodelink connection
conntx
:=
func
(
src
,
dst
string
,
connid
uint32
,
msg
ne
o
.
Msg
)
*
eventNeoSend
{
conntx
:=
func
(
src
,
dst
string
,
connid
uint32
,
msg
prot
o
.
Msg
)
*
eventNeoSend
{
return
&
eventNeoSend
{
Src
:
src
,
Dst
:
dst
,
ConnID
:
connid
,
Msg
:
msg
}
return
&
eventNeoSend
{
Src
:
src
,
Dst
:
dst
,
ConnID
:
connid
,
Msg
:
msg
}
}
}
// shortcut for NodeInfo
// shortcut for NodeInfo
nodei
:=
func
(
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtime
neo
.
IdTime
)
ne
o
.
NodeInfo
{
nodei
:=
func
(
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
prot
o
.
NodeInfo
{
return
ne
o
.
NodeInfo
{
return
prot
o
.
NodeInfo
{
Type
:
typ
,
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
Addr
:
xnaddr
(
laddr
),
UUID
:
ne
o
.
UUID
(
typ
,
num
),
UUID
:
prot
o
.
UUID
(
typ
,
num
),
State
:
state
,
State
:
state
,
IdTime
:
idtime
,
IdTime
:
idtime
,
}
}
}
}
// shortcut for nodetab change
// shortcut for nodetab change
node
:=
func
(
where
string
,
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtime
ne
o
.
IdTime
)
*
eventNodeTab
{
node
:=
func
(
where
string
,
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
prot
o
.
IdTime
)
*
eventNodeTab
{
return
&
eventNodeTab
{
return
&
eventNodeTab
{
Where
:
where
,
Where
:
where
,
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtime
),
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtime
),
...
@@ -507,8 +509,8 @@ func TestMasterStorage(t *testing.T) {
...
@@ -507,8 +509,8 @@ func TestMasterStorage(t *testing.T) {
// M starts listening
// M starts listening
tM
.
Expect
(
netlisten
(
"m:1"
))
tM
.
Expect
(
netlisten
(
"m:1"
))
tM
.
Expect
(
node
(
"m"
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
ne
o
.
IdTimeNone
))
tM
.
Expect
(
node
(
"m"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
))
tM
.
Expect
(
clusterState
(
"m"
,
ne
o
.
ClusterRecovering
))
tM
.
Expect
(
clusterState
(
"m"
,
prot
o
.
ClusterRecovering
))
// TODO create C; C tries connect to master - rejected ("not yet operational")
// TODO create C; C tries connect to master - rejected ("not yet operational")
...
@@ -517,39 +519,39 @@ func TestMasterStorage(t *testing.T) {
...
@@ -517,39 +519,39 @@ func TestMasterStorage(t *testing.T) {
// S connects M
// S connects M
tSM
.
Expect
(
netconnect
(
"s:2"
,
"m:2"
,
"m:1"
))
tSM
.
Expect
(
netconnect
(
"s:2"
,
"m:2"
,
"m:1"
))
tSM
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
1
,
&
ne
o
.
RequestIdentification
{
tSM
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
1
,
&
prot
o
.
RequestIdentification
{
NodeType
:
ne
o
.
STORAGE
,
NodeType
:
prot
o
.
STORAGE
,
UUID
:
0
,
UUID
:
0
,
Address
:
xnaddr
(
"s:1"
),
Address
:
xnaddr
(
"s:1"
),
ClusterName
:
"abc1"
,
ClusterName
:
"abc1"
,
IdTime
:
ne
o
.
IdTimeNone
,
IdTime
:
prot
o
.
IdTimeNone
,
}))
}))
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
PENDING
,
0.01
))
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
PENDING
,
0.01
))
tSM
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
ne
o
.
AcceptIdentification
{
tSM
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
prot
o
.
AcceptIdentification
{
NodeType
:
ne
o
.
MASTER
,
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
neo
.
UUID
(
ne
o
.
MASTER
,
1
),
MyUUID
:
proto
.
UUID
(
prot
o
.
MASTER
,
1
),
NumPartitions
:
1
,
NumPartitions
:
1
,
NumReplicas
:
1
,
NumReplicas
:
1
,
YourUUID
:
neo
.
UUID
(
ne
o
.
STORAGE
,
1
),
YourUUID
:
proto
.
UUID
(
prot
o
.
STORAGE
,
1
),
}))
}))
// TODO test ID rejects (uuid already registered, ...)
// TODO test ID rejects (uuid already registered, ...)
// M starts recovery on S
// M starts recovery on S
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
0
,
&
ne
o
.
Recovery
{}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
0
,
&
prot
o
.
Recovery
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
0
,
&
ne
o
.
AnswerRecovery
{
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
0
,
&
prot
o
.
AnswerRecovery
{
// empty new node
// empty new node
PTid
:
0
,
PTid
:
0
,
BackupTid
:
ne
o
.
INVALID_TID
,
BackupTid
:
prot
o
.
INVALID_TID
,
TruncateTid
:
ne
o
.
INVALID_TID
,
TruncateTid
:
prot
o
.
INVALID_TID
,
}))
}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
2
,
&
ne
o
.
AskPartitionTable
{}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
2
,
&
prot
o
.
AskPartitionTable
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
2
,
&
ne
o
.
AnswerPartitionTable
{
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
2
,
&
prot
o
.
AnswerPartitionTable
{
PTid
:
0
,
PTid
:
0
,
RowList
:
[]
ne
o
.
RowInfo
{},
RowList
:
[]
prot
o
.
RowInfo
{},
}))
}))
// M ready to start: new cluster, no in-progress S recovery
// M ready to start: new cluster, no in-progress S recovery
...
@@ -567,31 +569,31 @@ func TestMasterStorage(t *testing.T) {
...
@@ -567,31 +569,31 @@ func TestMasterStorage(t *testing.T) {
// trace
// trace
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
RUNNING
,
0.01
))
tM
.
Expect
(
node
(
"m"
,
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
RUNNING
,
0.01
))
xwait
(
wg
)
xwait
(
wg
)
// XXX M.partTab <- S1
// XXX M.partTab <- S1
// M starts verification
// M starts verification
tM
.
Expect
(
clusterState
(
"m"
,
ne
o
.
ClusterVerifying
))
tM
.
Expect
(
clusterState
(
"m"
,
prot
o
.
ClusterVerifying
))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
4
,
&
ne
o
.
SendPartitionTable
{
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
4
,
&
prot
o
.
SendPartitionTable
{
PTid
:
1
,
PTid
:
1
,
RowList
:
[]
ne
o
.
RowInfo
{
RowList
:
[]
prot
o
.
RowInfo
{
{
0
,
[]
neo
.
CellInfo
{{
neo
.
UUID
(
neo
.
STORAGE
,
1
),
ne
o
.
UP_TO_DATE
}}},
{
0
,
[]
proto
.
CellInfo
{{
proto
.
UUID
(
proto
.
STORAGE
,
1
),
prot
o
.
UP_TO_DATE
}}},
},
},
}))
}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
6
,
&
ne
o
.
LockedTransactions
{}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
6
,
&
prot
o
.
LockedTransactions
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
6
,
&
ne
o
.
AnswerLockedTransactions
{
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
6
,
&
prot
o
.
AnswerLockedTransactions
{
TidDict
:
nil
,
// map[zodb.Tid]zodb.Tid{},
TidDict
:
nil
,
// map[zodb.Tid]zodb.Tid{},
}))
}))
lastOid
,
err1
:=
zstor
.
LastOid
(
bg
)
lastOid
,
err1
:=
zstor
.
LastOid
(
bg
)
lastTid
,
err2
:=
zstor
.
LastTid
(
bg
)
lastTid
,
err2
:=
zstor
.
LastTid
(
bg
)
exc
.
Raiseif
(
xerr
.
Merge
(
err1
,
err2
))
exc
.
Raiseif
(
xerr
.
Merge
(
err1
,
err2
))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
8
,
&
ne
o
.
LastIDs
{}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
8
,
&
prot
o
.
LastIDs
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
8
,
&
ne
o
.
AnswerLastIDs
{
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
8
,
&
prot
o
.
AnswerLastIDs
{
LastOid
:
lastOid
,
LastOid
:
lastOid
,
LastTid
:
lastTid
,
LastTid
:
lastTid
,
}))
}))
...
@@ -604,11 +606,11 @@ func TestMasterStorage(t *testing.T) {
...
@@ -604,11 +606,11 @@ func TestMasterStorage(t *testing.T) {
// TODO M.Stop() while verify
// TODO M.Stop() while verify
// verification ok; M start service
// verification ok; M start service
tM
.
Expect
(
clusterState
(
"m"
,
ne
o
.
ClusterRunning
))
tM
.
Expect
(
clusterState
(
"m"
,
prot
o
.
ClusterRunning
))
// TODO ^^^ should be sent to S
// TODO ^^^ should be sent to S
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
10
,
&
ne
o
.
StartOperation
{
Backup
:
false
}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
10
,
&
prot
o
.
StartOperation
{
Backup
:
false
}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
10
,
&
ne
o
.
NotifyReady
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
10
,
&
prot
o
.
NotifyReady
{}))
// TODO S leave while service
// TODO S leave while service
// TODO S join while service
// TODO S join while service
...
@@ -629,48 +631,48 @@ func TestMasterStorage(t *testing.T) {
...
@@ -629,48 +631,48 @@ func TestMasterStorage(t *testing.T) {
// C connects M
// C connects M
tCM
.
Expect
(
netconnect
(
"c:1"
,
"m:3"
,
"m:1"
))
tCM
.
Expect
(
netconnect
(
"c:1"
,
"m:3"
,
"m:1"
))
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
1
,
&
ne
o
.
RequestIdentification
{
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
1
,
&
prot
o
.
RequestIdentification
{
NodeType
:
ne
o
.
CLIENT
,
NodeType
:
prot
o
.
CLIENT
,
UUID
:
0
,
UUID
:
0
,
Address
:
xnaddr
(
""
),
Address
:
xnaddr
(
""
),
ClusterName
:
"abc1"
,
ClusterName
:
"abc1"
,
IdTime
:
ne
o
.
IdTimeNone
,
IdTime
:
prot
o
.
IdTimeNone
,
}))
}))
tM
.
Expect
(
node
(
"m"
,
""
,
neo
.
CLIENT
,
1
,
ne
o
.
RUNNING
,
0.02
))
tM
.
Expect
(
node
(
"m"
,
""
,
proto
.
CLIENT
,
1
,
prot
o
.
RUNNING
,
0.02
))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
ne
o
.
AcceptIdentification
{
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
prot
o
.
AcceptIdentification
{
NodeType
:
ne
o
.
MASTER
,
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
neo
.
UUID
(
ne
o
.
MASTER
,
1
),
MyUUID
:
proto
.
UUID
(
prot
o
.
MASTER
,
1
),
NumPartitions
:
1
,
NumPartitions
:
1
,
NumReplicas
:
1
,
NumReplicas
:
1
,
YourUUID
:
neo
.
UUID
(
ne
o
.
CLIENT
,
1
),
YourUUID
:
proto
.
UUID
(
prot
o
.
CLIENT
,
1
),
}))
}))
// C asks M about PT
// C asks M about PT
// FIXME this might come in parallel with vvv "C <- M NotifyNodeInformation C1,M1,S1"
// FIXME this might come in parallel with vvv "C <- M NotifyNodeInformation C1,M1,S1"
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
3
,
&
ne
o
.
AskPartitionTable
{}))
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
3
,
&
prot
o
.
AskPartitionTable
{}))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
3
,
&
ne
o
.
AnswerPartitionTable
{
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
3
,
&
prot
o
.
AnswerPartitionTable
{
PTid
:
1
,
PTid
:
1
,
RowList
:
[]
ne
o
.
RowInfo
{
RowList
:
[]
prot
o
.
RowInfo
{
{
0
,
[]
neo
.
CellInfo
{{
neo
.
UUID
(
neo
.
STORAGE
,
1
),
ne
o
.
UP_TO_DATE
}}},
{
0
,
[]
proto
.
CellInfo
{{
proto
.
UUID
(
proto
.
STORAGE
,
1
),
prot
o
.
UP_TO_DATE
}}},
},
},
}))
}))
// C <- M NotifyNodeInformation C1,M1,S1
// C <- M NotifyNodeInformation C1,M1,S1
// FIXME this might come in parallel with ^^^ "C asks M about PT"
// FIXME this might come in parallel with ^^^ "C asks M about PT"
tMC
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
ne
o
.
NotifyNodeInformation
{
tMC
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX ?
IdTime
:
prot
o
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
ne
o
.
NodeInfo
{
NodeList
:
[]
prot
o
.
NodeInfo
{
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
ne
o
.
IdTimeNone
),
nodei
(
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
RUNNING
,
0.01
),
nodei
(
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
RUNNING
,
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
ne
o
.
RUNNING
,
0.02
),
nodei
(
""
,
proto
.
CLIENT
,
1
,
prot
o
.
RUNNING
,
0.02
),
},
},
}))
}))
tMC
.
Expect
(
node
(
"c"
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
ne
o
.
IdTimeNone
))
tMC
.
Expect
(
node
(
"c"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
))
tMC
.
Expect
(
node
(
"c"
,
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
RUNNING
,
0.01
))
tMC
.
Expect
(
node
(
"c"
,
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
RUNNING
,
0.01
))
tMC
.
Expect
(
node
(
"c"
,
""
,
neo
.
CLIENT
,
1
,
ne
o
.
RUNNING
,
0.02
))
tMC
.
Expect
(
node
(
"c"
,
""
,
proto
.
CLIENT
,
1
,
prot
o
.
RUNNING
,
0.02
))
// C asks M about last tid XXX better master sends it itself on new client connected
// C asks M about last tid XXX better master sends it itself on new client connected
...
@@ -684,8 +686,8 @@ func TestMasterStorage(t *testing.T) {
...
@@ -684,8 +686,8 @@ func TestMasterStorage(t *testing.T) {
}
}
})
})
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
5
,
&
ne
o
.
LastTransaction
{}))
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
5
,
&
prot
o
.
LastTransaction
{}))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
5
,
&
ne
o
.
AnswerLastTransaction
{
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
5
,
&
prot
o
.
AnswerLastTransaction
{
Tid
:
lastTid
,
Tid
:
lastTid
,
}))
}))
...
...
go/neo/server/master.go
View file @
47f069a5
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
...
@@ -73,7 +74,7 @@ type Master struct {
...
@@ -73,7 +74,7 @@ type Master struct {
// Use Run to actually start running the node.
// Use Run to actually start running the node.
func
NewMaster
(
clusterName
,
serveAddr
string
,
net
xnet
.
Networker
)
*
Master
{
func
NewMaster
(
clusterName
,
serveAddr
string
,
net
xnet
.
Networker
)
*
Master
{
m
:=
&
Master
{
m
:=
&
Master
{
node
:
neo
.
NewNodeApp
(
net
,
ne
o
.
MASTER
,
clusterName
,
serveAddr
,
serveAddr
),
node
:
neo
.
NewNodeApp
(
net
,
prot
o
.
MASTER
,
clusterName
,
serveAddr
,
serveAddr
),
ctlStart
:
make
(
chan
chan
error
),
ctlStart
:
make
(
chan
chan
error
),
ctlStop
:
make
(
chan
chan
struct
{}),
ctlStop
:
make
(
chan
chan
struct
{}),
...
@@ -118,7 +119,7 @@ func (m *Master) Shutdown() error {
...
@@ -118,7 +119,7 @@ func (m *Master) Shutdown() error {
// setClusterState sets .clusterState and notifies subscribers.
// setClusterState sets .clusterState and notifies subscribers.
func
(
m
*
Master
)
setClusterState
(
state
ne
o
.
ClusterState
)
{
func
(
m
*
Master
)
setClusterState
(
state
prot
o
.
ClusterState
)
{
m
.
node
.
ClusterState
.
Set
(
state
)
m
.
node
.
ClusterState
.
Set
(
state
)
// TODO notify subscribers
// TODO notify subscribers
...
@@ -136,19 +137,19 @@ func (m *Master) Run(ctx context.Context) (err error) {
...
@@ -136,19 +137,19 @@ func (m *Master) Run(ctx context.Context) (err error) {
defer
task
.
Runningf
(
&
ctx
,
"master(%v)"
,
l
.
Addr
())(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"master(%v)"
,
l
.
Addr
())(
&
err
)
m
.
node
.
MasterAddr
=
l
.
Addr
()
.
String
()
m
.
node
.
MasterAddr
=
l
.
Addr
()
.
String
()
naddr
,
err
:=
ne
o
.
Addr
(
l
.
Addr
())
naddr
,
err
:=
prot
o
.
Addr
(
l
.
Addr
())
if
err
!=
nil
{
if
err
!=
nil
{
// must be ok since l.Addr() is valid since it is listening
// must be ok since l.Addr() is valid since it is listening
// XXX panic -> errors.Wrap?
// XXX panic -> errors.Wrap?
panic
(
err
)
panic
(
err
)
}
}
m
.
node
.
MyInfo
=
ne
o
.
NodeInfo
{
m
.
node
.
MyInfo
=
prot
o
.
NodeInfo
{
Type
:
ne
o
.
MASTER
,
Type
:
prot
o
.
MASTER
,
Addr
:
naddr
,
Addr
:
naddr
,
UUID
:
m
.
allocUUID
(
ne
o
.
MASTER
),
UUID
:
m
.
allocUUID
(
prot
o
.
MASTER
),
State
:
ne
o
.
RUNNING
,
State
:
prot
o
.
RUNNING
,
IdTime
:
ne
o
.
IdTimeNone
,
// XXX ok?
IdTime
:
prot
o
.
IdTimeNone
,
// XXX ok?
}
}
// update nodeTab with self
// update nodeTab with self
...
@@ -181,10 +182,10 @@ func (m *Master) Run(ctx context.Context) (err error) {
...
@@ -181,10 +182,10 @@ func (m *Master) Run(ctx context.Context) (err error) {
// and then master only drives it. So close accept as noone will be
// and then master only drives it. So close accept as noone will be
// listening for it on our side anymore.
// listening for it on our side anymore.
switch
idReq
.
NodeType
{
switch
idReq
.
NodeType
{
case
ne
o
.
CLIENT
:
case
prot
o
.
CLIENT
:
// ok
// ok
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
fallthrough
fallthrough
default
:
default
:
req
.
Link
()
.
CloseAccept
()
req
.
Link
()
.
CloseAccept
()
...
@@ -287,7 +288,7 @@ type storRecovery struct {
...
@@ -287,7 +288,7 @@ type storRecovery struct {
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"recovery"
)(
&
err
)
defer
task
.
Running
(
&
ctx
,
"recovery"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterRecovering
)
m
.
setClusterState
(
prot
o
.
ClusterRecovering
)
ctx
,
rcancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
rcancel
:=
context
.
WithCancel
(
ctx
)
defer
rcancel
()
defer
rcancel
()
...
@@ -301,7 +302,7 @@ func (m *Master) recovery(ctx context.Context) (err error) {
...
@@ -301,7 +302,7 @@ func (m *Master) recovery(ctx context.Context) (err error) {
// start recovery on all storages we are currently in touch with
// start recovery on all storages we are currently in touch with
// XXX close links to clients
// XXX close links to clients
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
if
stor
.
State
>
prot
o
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
inprogress
++
inprogress
++
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
...
@@ -352,7 +353,7 @@ loop:
...
@@ -352,7 +353,7 @@ loop:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
ne
o
.
DOWN
)
r
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
}
}
else
{
}
else
{
...
@@ -371,7 +372,7 @@ loop:
...
@@ -371,7 +372,7 @@ loop:
// recovery and there is no in-progress recovery running
// recovery and there is no in-progress recovery running
nup
:=
0
nup
:=
0
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
if
stor
.
State
>
prot
o
.
DOWN
{
nup
++
nup
++
}
}
}
}
...
@@ -436,7 +437,7 @@ loop2:
...
@@ -436,7 +437,7 @@ loop2:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
ne
o
.
DOWN
)
r
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
}
case
<-
done
:
case
<-
done
:
...
@@ -453,8 +454,8 @@ loop2:
...
@@ -453,8 +454,8 @@ loop2:
// S PENDING -> RUNNING
// S PENDING -> RUNNING
// XXX recheck logic is ok for when starting existing cluster
// XXX recheck logic is ok for when starting existing cluster
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
==
ne
o
.
PENDING
{
if
stor
.
State
==
prot
o
.
PENDING
{
stor
.
SetState
(
ne
o
.
RUNNING
)
stor
.
SetState
(
prot
o
.
RUNNING
)
}
}
}
}
...
@@ -463,7 +464,7 @@ loop2:
...
@@ -463,7 +464,7 @@ loop2:
// XXX -> m.nodeTab.StorageList(State > DOWN)
// XXX -> m.nodeTab.StorageList(State > DOWN)
storv
:=
[]
*
neo
.
Node
{}
storv
:=
[]
*
neo
.
Node
{}
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
if
stor
.
State
>
prot
o
.
DOWN
{
storv
=
append
(
storv
,
stor
)
storv
=
append
(
storv
,
stor
)
}
}
}
}
...
@@ -492,14 +493,14 @@ func storCtlRecovery(ctx context.Context, stor *neo.Node, res chan storRecovery)
...
@@ -492,14 +493,14 @@ func storCtlRecovery(ctx context.Context, stor *neo.Node, res chan storRecovery)
// XXX cancel on ctx
// XXX cancel on ctx
recovery
:=
ne
o
.
AnswerRecovery
{}
recovery
:=
prot
o
.
AnswerRecovery
{}
err
=
slink
.
Ask1
(
&
ne
o
.
Recovery
{},
&
recovery
)
err
=
slink
.
Ask1
(
&
prot
o
.
Recovery
{},
&
recovery
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
resp
:=
ne
o
.
AnswerPartitionTable
{}
resp
:=
prot
o
.
AnswerPartitionTable
{}
err
=
slink
.
Ask1
(
&
ne
o
.
AskPartitionTable
{},
&
resp
)
err
=
slink
.
Ask1
(
&
prot
o
.
AskPartitionTable
{},
&
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -536,7 +537,7 @@ var errClusterDegraded = stderrors.New("cluster became non-operatonal")
...
@@ -536,7 +537,7 @@ var errClusterDegraded = stderrors.New("cluster became non-operatonal")
func
(
m
*
Master
)
verify
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
m
*
Master
)
verify
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"verify"
)(
&
err
)
defer
task
.
Running
(
&
ctx
,
"verify"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterVerifying
)
m
.
setClusterState
(
prot
o
.
ClusterVerifying
)
ctx
,
vcancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
vcancel
:=
context
.
WithCancel
(
ctx
)
defer
vcancel
()
defer
vcancel
()
...
@@ -549,7 +550,7 @@ func (m *Master) verify(ctx context.Context) (err error) {
...
@@ -549,7 +550,7 @@ func (m *Master) verify(ctx context.Context) (err error) {
// start verification on all storages we are currently in touch with
// start verification on all storages we are currently in touch with
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
if
stor
.
State
>
prot
o
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
inprogress
++
inprogress
++
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
...
@@ -587,7 +588,7 @@ loop:
...
@@ -587,7 +588,7 @@ loop:
/*
/*
case n := <-m.nodeLeave:
case n := <-m.nodeLeave:
n.node.SetState(
ne
o.DOWN)
n.node.SetState(
prot
o.DOWN)
// if cluster became non-operational - we cancel verification
// if cluster became non-operational - we cancel verification
if !m.node.PartTab.OperationalWith(m.node.NodeTab) {
if !m.node.PartTab.OperationalWith(m.node.NodeTab) {
...
@@ -611,7 +612,7 @@ loop:
...
@@ -611,7 +612,7 @@ loop:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
ne
o
.
DOWN
)
v
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
}
// check partTab is still operational
// check partTab is still operational
...
@@ -660,7 +661,7 @@ loop2:
...
@@ -660,7 +661,7 @@ loop2:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
ne
o
.
DOWN
)
v
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
}
case
<-
done
:
case
<-
done
:
...
@@ -694,7 +695,7 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
...
@@ -694,7 +695,7 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
defer
task
.
Runningf
(
&
ctx
,
"%s: stor verify"
,
slink
)(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"%s: stor verify"
,
slink
)(
&
err
)
// send just recovered parttab so storage saves it
// send just recovered parttab so storage saves it
err
=
slink
.
Send1
(
&
ne
o
.
SendPartitionTable
{
err
=
slink
.
Send1
(
&
prot
o
.
SendPartitionTable
{
PTid
:
pt
.
PTid
,
PTid
:
pt
.
PTid
,
RowList
:
pt
.
Dump
(),
RowList
:
pt
.
Dump
(),
})
})
...
@@ -702,8 +703,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
...
@@ -702,8 +703,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
return
return
}
}
locked
:=
ne
o
.
AnswerLockedTransactions
{}
locked
:=
prot
o
.
AnswerLockedTransactions
{}
err
=
slink
.
Ask1
(
&
ne
o
.
LockedTransactions
{},
&
locked
)
err
=
slink
.
Ask1
(
&
prot
o
.
LockedTransactions
{},
&
locked
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -714,8 +715,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
...
@@ -714,8 +715,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
return
return
}
}
last
:=
ne
o
.
AnswerLastIDs
{}
last
:=
prot
o
.
AnswerLastIDs
{}
err
=
slink
.
Ask1
(
&
ne
o
.
LastIDs
{},
&
last
)
err
=
slink
.
Ask1
(
&
prot
o
.
LastIDs
{},
&
last
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -749,7 +750,7 @@ type serviceDone struct {
...
@@ -749,7 +750,7 @@ type serviceDone struct {
func
(
m
*
Master
)
service
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
m
*
Master
)
service
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"service"
)(
&
err
)
defer
task
.
Running
(
&
ctx
,
"service"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterRunning
)
m
.
setClusterState
(
prot
o
.
ClusterRunning
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
defer
cancel
()
...
@@ -758,7 +759,7 @@ func (m *Master) service(ctx context.Context) (err error) {
...
@@ -758,7 +759,7 @@ func (m *Master) service(ctx context.Context) (err error) {
// spawn per-storage service driver
// spawn per-storage service driver
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
==
ne
o
.
RUNNING
{
// XXX note PENDING - not adding to service; ok?
if
stor
.
State
==
prot
o
.
RUNNING
{
// XXX note PENDING - not adding to service; ok?
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
...
@@ -791,10 +792,10 @@ loop:
...
@@ -791,10 +792,10 @@ loop:
}
}
switch
node
.
Type
{
switch
node
.
Type
{
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
err
=
storCtlService
(
ctx
,
node
)
err
=
storCtlService
(
ctx
,
node
)
case
ne
o
.
CLIENT
:
case
prot
o
.
CLIENT
:
err
=
m
.
serveClient
(
ctx
,
node
)
err
=
m
.
serveClient
(
ctx
,
node
)
// XXX ADMIN
// XXX ADMIN
...
@@ -810,7 +811,7 @@ loop:
...
@@ -810,7 +811,7 @@ loop:
/*
/*
// XXX who sends here?
// XXX who sends here?
case n := <-m.nodeLeave:
case n := <-m.nodeLeave:
n.node.SetState(
ne
o.DOWN)
n.node.SetState(
prot
o.DOWN)
// if cluster became non-operational - cancel service
// if cluster became non-operational - cancel service
if !m.node.PartTab.OperationalWith(m.node.NodeTab) {
if !m.node.PartTab.OperationalWith(m.node.NodeTab) {
...
@@ -853,9 +854,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
...
@@ -853,9 +854,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
// XXX current neo/py does StartOperation / NotifyReady as separate
// XXX current neo/py does StartOperation / NotifyReady as separate
// sends, not exchange on the same conn. - fixed
// sends, not exchange on the same conn. - fixed
ready
:=
ne
o
.
NotifyReady
{}
ready
:=
prot
o
.
NotifyReady
{}
err
=
slink
.
Ask1
(
&
ne
o
.
StartOperation
{
Backup
:
false
},
&
ready
)
err
=
slink
.
Ask1
(
&
prot
o
.
StartOperation
{
Backup
:
false
},
&
ready
)
//err = slink.Send1(&
ne
o.StartOperation{Backup: false})
//err = slink.Send1(&
prot
o.StartOperation{Backup: false})
//if err != nil {
//if err != nil {
// return err
// return err
//}
//}
...
@@ -865,9 +866,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
...
@@ -865,9 +866,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
//}
//}
//req.Close() XXX must be after req handling
//req.Close() XXX must be after req handling
//switch msg := req.Msg.(type) {
//switch msg := req.Msg.(type) {
//case *
ne
o.NotifyReady:
//case *
prot
o.NotifyReady:
// // ok
// // ok
//case *
ne
o.Error:
//case *
prot
o.Error:
// return msg
// return msg
//default:
//default:
// return fmt.Errorf("unexpected message %T", msg)
// return fmt.Errorf("unexpected message %T", msg)
...
@@ -924,23 +925,23 @@ func (m *Master) serveClient(ctx context.Context, cli *neo.Node) (err error) {
...
@@ -924,23 +925,23 @@ func (m *Master) serveClient(ctx context.Context, cli *neo.Node) (err error) {
}
}
// serveClient1 prepares response for 1 request from client
// serveClient1 prepares response for 1 request from client
func
(
m
*
Master
)
serveClient1
(
ctx
context
.
Context
,
req
neo
.
Msg
)
(
resp
ne
o
.
Msg
)
{
func
(
m
*
Master
)
serveClient1
(
ctx
context
.
Context
,
req
proto
.
Msg
)
(
resp
prot
o
.
Msg
)
{
switch
req
:=
req
.
(
type
)
{
switch
req
:=
req
.
(
type
)
{
case
*
ne
o
.
AskPartitionTable
:
case
*
prot
o
.
AskPartitionTable
:
m
.
node
.
StateMu
.
RLock
()
m
.
node
.
StateMu
.
RLock
()
rpt
:=
&
ne
o
.
AnswerPartitionTable
{
rpt
:=
&
prot
o
.
AnswerPartitionTable
{
PTid
:
m
.
node
.
PartTab
.
PTid
,
PTid
:
m
.
node
.
PartTab
.
PTid
,
RowList
:
m
.
node
.
PartTab
.
Dump
(),
RowList
:
m
.
node
.
PartTab
.
Dump
(),
}
}
m
.
node
.
StateMu
.
RUnlock
()
m
.
node
.
StateMu
.
RUnlock
()
return
rpt
return
rpt
case
*
ne
o
.
LastTransaction
:
case
*
prot
o
.
LastTransaction
:
// XXX lock
// XXX lock
return
&
ne
o
.
AnswerLastTransaction
{
m
.
lastTid
}
return
&
prot
o
.
AnswerLastTransaction
{
m
.
lastTid
}
default
:
default
:
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
)}
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
)}
}
}
}
}
...
@@ -959,7 +960,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -959,7 +960,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX ^^^ + subscribe
// XXX ^^^ + subscribe
nodev
:=
m
.
node
.
NodeTab
.
All
()
nodev
:=
m
.
node
.
NodeTab
.
All
()
nodeiv
:=
make
([]
ne
o
.
NodeInfo
,
len
(
nodev
))
nodeiv
:=
make
([]
prot
o
.
NodeInfo
,
len
(
nodev
))
for
i
,
node
:=
range
nodev
{
for
i
,
node
:=
range
nodev
{
// NOTE .NodeInfo is data not pointers - so won't change after we copy it to nodeiv
// NOTE .NodeInfo is data not pointers - so won't change after we copy it to nodeiv
nodeiv
[
i
]
=
node
.
NodeInfo
nodeiv
[
i
]
=
node
.
NodeInfo
...
@@ -982,8 +983,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -982,8 +983,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// first send the snapshot.
// first send the snapshot.
// XXX +ClusterState
// XXX +ClusterState
err
=
link
.
Send1
(
&
ne
o
.
NotifyNodeInformation
{
err
=
link
.
Send1
(
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX what here?
IdTime
:
prot
o
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
NodeList
:
nodeiv
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -992,7 +993,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -992,7 +993,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// now proxy the updates until we are done
// now proxy the updates until we are done
for
{
for
{
var
msg
ne
o
.
Msg
var
msg
prot
o
.
Msg
select
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
...
@@ -1001,8 +1002,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -1001,8 +1002,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX ClusterState
// XXX ClusterState
case
nodeiv
=
<-
nodech
:
case
nodeiv
=
<-
nodech
:
msg
=
&
ne
o
.
NotifyNodeInformation
{
msg
=
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX what here?
IdTime
:
prot
o
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
NodeList
:
nodeiv
,
}
}
}
}
...
@@ -1024,7 +1025,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -1024,7 +1025,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// If node identification is accepted .nodeTab is updated and corresponding node entry is returned.
// If node identification is accepted .nodeTab is updated and corresponding node entry is returned.
// Response message is constructed but not send back not to block the caller - it is
// Response message is constructed but not send back not to block the caller - it is
// the caller responsibility to send the response to node which requested identification.
// the caller responsibility to send the response to node which requested identification.
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
neo
.
Node
,
resp
ne
o
.
Msg
)
{
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
neo
.
Node
,
resp
prot
o
.
Msg
)
{
// XXX also verify ? :
// XXX also verify ? :
// - NodeType valid
// - NodeType valid
// - IdTime ?
// - IdTime ?
...
@@ -1032,9 +1033,9 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1032,9 +1033,9 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
uuid
:=
n
.
idReq
.
UUID
uuid
:=
n
.
idReq
.
UUID
nodeType
:=
n
.
idReq
.
NodeType
nodeType
:=
n
.
idReq
.
NodeType
err
:=
func
()
*
ne
o
.
Error
{
err
:=
func
()
*
prot
o
.
Error
{
if
n
.
idReq
.
ClusterName
!=
m
.
node
.
ClusterName
{
if
n
.
idReq
.
ClusterName
!=
m
.
node
.
ClusterName
{
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
"cluster name mismatch"
}
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
"cluster name mismatch"
}
}
}
if
uuid
==
0
{
if
uuid
==
0
{
...
@@ -1048,23 +1049,23 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1048,23 +1049,23 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
if
node
!=
nil
{
if
node
!=
nil
{
// reject - uuid is already occupied by someone else
// reject - uuid is already occupied by someone else
// XXX check also for down state - it could be the same node reconnecting
// XXX check also for down state - it could be the same node reconnecting
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"uuid %v already used by another node"
,
uuid
)}
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"uuid %v already used by another node"
,
uuid
)}
}
}
// accept only certain kind of nodes depending on .clusterState, e.g.
// accept only certain kind of nodes depending on .clusterState, e.g.
// XXX ok to have this logic inside identify? (better provide from outside ?)
// XXX ok to have this logic inside identify? (better provide from outside ?)
switch
nodeType
{
switch
nodeType
{
case
ne
o
.
CLIENT
:
case
prot
o
.
CLIENT
:
if
m
.
node
.
ClusterState
!=
ne
o
.
ClusterRunning
{
if
m
.
node
.
ClusterState
!=
prot
o
.
ClusterRunning
{
return
&
neo
.
Error
{
ne
o
.
NOT_READY
,
"cluster not operational"
}
return
&
proto
.
Error
{
prot
o
.
NOT_READY
,
"cluster not operational"
}
}
}
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
// ok
// ok
// TODO +master, admin
// TODO +master, admin
default
:
default
:
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"not accepting node type %v"
,
nodeType
)}
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"not accepting node type %v"
,
nodeType
)}
}
}
return
nil
return
nil
...
@@ -1078,8 +1079,8 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1078,8 +1079,8 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
log
.
Infof
(
ctx
,
"%s: accepting as %s"
,
subj
,
uuid
)
log
.
Infof
(
ctx
,
"%s: accepting as %s"
,
subj
,
uuid
)
accept
:=
&
ne
o
.
AcceptIdentification
{
accept
:=
&
prot
o
.
AcceptIdentification
{
NodeType
:
ne
o
.
MASTER
,
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
m
.
node
.
MyInfo
.
UUID
,
MyUUID
:
m
.
node
.
MyInfo
.
UUID
,
NumPartitions
:
1
,
// FIXME hardcoded
NumPartitions
:
1
,
// FIXME hardcoded
NumReplicas
:
1
,
// FIXME hardcoded
NumReplicas
:
1
,
// FIXME hardcoded
...
@@ -1087,22 +1088,22 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1087,22 +1088,22 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
}
}
// update nodeTab
// update nodeTab
var
nodeState
ne
o
.
NodeState
var
nodeState
prot
o
.
NodeState
switch
nodeType
{
switch
nodeType
{
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
// FIXME py sets to RUNNING/PENDING depending on cluster state
// FIXME py sets to RUNNING/PENDING depending on cluster state
nodeState
=
ne
o
.
PENDING
nodeState
=
prot
o
.
PENDING
default
:
default
:
nodeState
=
ne
o
.
RUNNING
nodeState
=
prot
o
.
RUNNING
}
}
nodeInfo
:=
ne
o
.
NodeInfo
{
nodeInfo
:=
prot
o
.
NodeInfo
{
Type
:
nodeType
,
Type
:
nodeType
,
Addr
:
n
.
idReq
.
Address
,
Addr
:
n
.
idReq
.
Address
,
UUID
:
uuid
,
UUID
:
uuid
,
State
:
nodeState
,
State
:
nodeState
,
IdTime
:
ne
o
.
IdTime
(
m
.
monotime
()),
IdTime
:
prot
o
.
IdTime
(
m
.
monotime
()),
}
}
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
)
// NOTE this notifies all nodeTab subscribers
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
)
// NOTE this notifies all nodeTab subscribers
...
@@ -1113,9 +1114,9 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1113,9 +1114,9 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
// allocUUID allocates new node uuid for a node of kind nodeType
// allocUUID allocates new node uuid for a node of kind nodeType
// XXX it is bad idea for master to assign uuid to coming node
// XXX it is bad idea for master to assign uuid to coming node
// -> better nodes generate really unique UUID themselves and always show with them
// -> better nodes generate really unique UUID themselves and always show with them
func
(
m
*
Master
)
allocUUID
(
nodeType
neo
.
NodeType
)
ne
o
.
NodeUUID
{
func
(
m
*
Master
)
allocUUID
(
nodeType
proto
.
NodeType
)
prot
o
.
NodeUUID
{
for
num
:=
int32
(
1
);
num
<
1
<<
24
;
num
++
{
for
num
:=
int32
(
1
);
num
<
1
<<
24
;
num
++
{
uuid
:=
ne
o
.
UUID
(
nodeType
,
num
)
uuid
:=
prot
o
.
UUID
(
nodeType
,
num
)
if
m
.
node
.
NodeTab
.
Get
(
uuid
)
==
nil
{
if
m
.
node
.
NodeTab
.
Get
(
uuid
)
==
nil
{
return
uuid
return
uuid
}
}
...
...
go/neo/server/server.go
View file @
47f069a5
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"sync"
"sync"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
...
@@ -77,7 +78,7 @@ func Serve(ctx context.Context, l *neo.Listener, srv Server) error {
...
@@ -77,7 +78,7 @@ func Serve(ctx context.Context, l *neo.Listener, srv Server) error {
// IdentifyPeer identifies peer on the link
// IdentifyPeer identifies peer on the link
// it expects peer to send RequestIdentification packet and replies with AcceptIdentification if identification passes.
// it expects peer to send RequestIdentification packet and replies with AcceptIdentification if identification passes.
// returns information about identified node or error.
// returns information about identified node or error.
func
IdentifyPeer
(
ctx
context
.
Context
,
link
*
neo
.
NodeLink
,
myNodeType
neo
.
NodeType
)
(
nodeInfo
ne
o
.
RequestIdentification
,
err
error
)
{
func
IdentifyPeer
(
ctx
context
.
Context
,
link
*
neo
.
NodeLink
,
myNodeType
proto
.
NodeType
)
(
nodeInfo
prot
o
.
RequestIdentification
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s: identify"
,
link
)
defer
xerr
.
Contextf
(
&
err
,
"%s: identify"
,
link
)
// the first conn must come with RequestIdentification packet
// the first conn must come with RequestIdentification packet
...
@@ -93,7 +94,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
...
@@ -93,7 +94,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
}
}
}()
}()
req
:=
ne
o
.
RequestIdentification
{}
req
:=
prot
o
.
RequestIdentification
{}
_
,
err
=
conn
.
Expect
(
&
req
)
_
,
err
=
conn
.
Expect
(
&
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nodeInfo
,
err
return
nodeInfo
,
err
...
@@ -103,7 +104,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
...
@@ -103,7 +104,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
// TODO hook here in logic to check identification request, assign nodeID etc
// TODO hook here in logic to check identification request, assign nodeID etc
err
=
conn
.
Send
(
&
ne
o
.
AcceptIdentification
{
err
=
conn
.
Send
(
&
prot
o
.
AcceptIdentification
{
NodeType
:
myNodeType
,
NodeType
:
myNodeType
,
MyUUID
:
0
,
// XXX
MyUUID
:
0
,
// XXX
NumPartitions
:
1
,
// XXX
NumPartitions
:
1
,
// XXX
...
@@ -124,7 +125,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
...
@@ -124,7 +125,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
// event: node connects
// event: node connects
type
nodeCome
struct
{
type
nodeCome
struct
{
req
*
neo
.
Request
req
*
neo
.
Request
idReq
*
ne
o
.
RequestIdentification
// we received this identification request
idReq
*
prot
o
.
RequestIdentification
// we received this identification request
}
}
/*
/*
...
@@ -137,7 +138,7 @@ type nodeLeave struct {
...
@@ -137,7 +138,7 @@ type nodeLeave struct {
// reject sends rejective identification response and closes associated link
// reject sends rejective identification response and closes associated link
func
reject
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
resp
ne
o
.
Msg
)
{
func
reject
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
resp
prot
o
.
Msg
)
{
// XXX cancel on ctx?
// XXX cancel on ctx?
// log.Info(ctx, "identification rejected") ?
// log.Info(ctx, "identification rejected") ?
err1
:=
req
.
Reply
(
resp
)
err1
:=
req
.
Reply
(
resp
)
...
@@ -149,7 +150,7 @@ func reject(ctx context.Context, req *neo.Request, resp neo.Msg) {
...
@@ -149,7 +150,7 @@ func reject(ctx context.Context, req *neo.Request, resp neo.Msg) {
}
}
// goreject spawns reject in separate goroutine properly added/done on wg
// goreject spawns reject in separate goroutine properly added/done on wg
func
goreject
(
ctx
context
.
Context
,
wg
*
sync
.
WaitGroup
,
req
*
neo
.
Request
,
resp
ne
o
.
Msg
)
{
func
goreject
(
ctx
context
.
Context
,
wg
*
sync
.
WaitGroup
,
req
*
neo
.
Request
,
resp
prot
o
.
Msg
)
{
wg
.
Add
(
1
)
wg
.
Add
(
1
)
defer
wg
.
Done
()
defer
wg
.
Done
()
go
reject
(
ctx
,
req
,
resp
)
go
reject
(
ctx
,
req
,
resp
)
...
@@ -157,7 +158,7 @@ func goreject(ctx context.Context, wg *sync.WaitGroup, req *neo.Request, resp ne
...
@@ -157,7 +158,7 @@ func goreject(ctx context.Context, wg *sync.WaitGroup, req *neo.Request, resp ne
// accept replies with acceptive identification response
// accept replies with acceptive identification response
// XXX spawn ping goroutine from here?
// XXX spawn ping goroutine from here?
func
accept
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
resp
ne
o
.
Msg
)
error
{
func
accept
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
resp
prot
o
.
Msg
)
error
{
// XXX cancel on ctx
// XXX cancel on ctx
err1
:=
req
.
Reply
(
resp
)
err1
:=
req
.
Reply
(
resp
)
return
err1
// XXX while trying to work on single conn
return
err1
// XXX while trying to work on single conn
...
...
go/neo/server/storage.go
View file @
47f069a5
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"github.com/pkg/errors"
"github.com/pkg/errors"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/internal/common"
"lab.nexedi.com/kirr/neo/go/neo/internal/common"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
...
@@ -78,7 +79,7 @@ type Storage struct {
...
@@ -78,7 +79,7 @@ type Storage struct {
// Use Run to actually start running the node.
// Use Run to actually start running the node.
func
NewStorage
(
clusterName
,
masterAddr
,
serveAddr
string
,
net
xnet
.
Networker
,
zstor
*
fs1
.
FileStorage
)
*
Storage
{
func
NewStorage
(
clusterName
,
masterAddr
,
serveAddr
string
,
net
xnet
.
Networker
,
zstor
*
fs1
.
FileStorage
)
*
Storage
{
stor
:=
&
Storage
{
stor
:=
&
Storage
{
node
:
neo
.
NewNodeApp
(
net
,
ne
o
.
STORAGE
,
clusterName
,
masterAddr
,
serveAddr
),
node
:
neo
.
NewNodeApp
(
net
,
prot
o
.
STORAGE
,
clusterName
,
masterAddr
,
serveAddr
),
zstor
:
zstor
,
zstor
:
zstor
,
}
}
...
@@ -198,7 +199,7 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) {
...
@@ -198,7 +199,7 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) {
// XXX distinguish between temporary problems and non-temporary ones?
// XXX distinguish between temporary problems and non-temporary ones?
func
(
stor
*
Storage
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
func
(
stor
*
Storage
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
// XXX dup in Client.talkMaster1 ?
// XXX dup in Client.talkMaster1 ?
mlink
,
accept
,
err
:=
stor
.
node
.
Dial
(
ctx
,
ne
o
.
MASTER
,
stor
.
node
.
MasterAddr
)
mlink
,
accept
,
err
:=
stor
.
node
.
Dial
(
ctx
,
prot
o
.
MASTER
,
stor
.
node
.
MasterAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -274,49 +275,49 @@ func (stor *Storage) m1initialize1(ctx context.Context, req neo.Request) error {
...
@@ -274,49 +275,49 @@ func (stor *Storage) m1initialize1(ctx context.Context, req neo.Request) error {
default
:
default
:
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
case
*
ne
o
.
StartOperation
:
case
*
prot
o
.
StartOperation
:
// ok, transition to serve
// ok, transition to serve
return
cmdStart
return
cmdStart
case
*
ne
o
.
Recovery
:
case
*
prot
o
.
Recovery
:
err
=
req
.
Reply
(
&
ne
o
.
AnswerRecovery
{
err
=
req
.
Reply
(
&
prot
o
.
AnswerRecovery
{
PTid
:
stor
.
node
.
PartTab
.
PTid
,
PTid
:
stor
.
node
.
PartTab
.
PTid
,
BackupTid
:
ne
o
.
INVALID_TID
,
BackupTid
:
prot
o
.
INVALID_TID
,
TruncateTid
:
ne
o
.
INVALID_TID
})
TruncateTid
:
prot
o
.
INVALID_TID
})
case
*
ne
o
.
AskPartitionTable
:
case
*
prot
o
.
AskPartitionTable
:
// TODO initially read PT from disk
// TODO initially read PT from disk
err
=
req
.
Reply
(
&
ne
o
.
AnswerPartitionTable
{
err
=
req
.
Reply
(
&
prot
o
.
AnswerPartitionTable
{
PTid
:
stor
.
node
.
PartTab
.
PTid
,
PTid
:
stor
.
node
.
PartTab
.
PTid
,
RowList
:
stor
.
node
.
PartTab
.
Dump
()})
RowList
:
stor
.
node
.
PartTab
.
Dump
()})
case
*
ne
o
.
LockedTransactions
:
case
*
prot
o
.
LockedTransactions
:
// XXX r/o stub
// XXX r/o stub
err
=
req
.
Reply
(
&
ne
o
.
AnswerLockedTransactions
{})
err
=
req
.
Reply
(
&
prot
o
.
AnswerLockedTransactions
{})
// TODO AskUnfinishedTransactions
// TODO AskUnfinishedTransactions
case
*
ne
o
.
LastIDs
:
case
*
prot
o
.
LastIDs
:
lastTid
,
zerr1
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastTid
,
zerr1
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastOid
,
zerr2
:=
stor
.
zstor
.
LastOid
(
ctx
)
lastOid
,
zerr2
:=
stor
.
zstor
.
LastOid
(
ctx
)
if
zerr
:=
xerr
.
First
(
zerr1
,
zerr2
);
zerr
!=
nil
{
if
zerr
:=
xerr
.
First
(
zerr1
,
zerr2
);
zerr
!=
nil
{
return
zerr
// XXX send the error to M
return
zerr
// XXX send the error to M
}
}
err
=
req
.
Reply
(
&
ne
o
.
AnswerLastIDs
{
LastTid
:
lastTid
,
LastOid
:
lastOid
})
err
=
req
.
Reply
(
&
prot
o
.
AnswerLastIDs
{
LastTid
:
lastTid
,
LastOid
:
lastOid
})
case
*
ne
o
.
SendPartitionTable
:
case
*
prot
o
.
SendPartitionTable
:
// TODO M sends us whole PT -> save locally
// TODO M sends us whole PT -> save locally
stor
.
node
.
UpdatePartTab
(
ctx
,
msg
)
// XXX lock?
stor
.
node
.
UpdatePartTab
(
ctx
,
msg
)
// XXX lock?
case
*
ne
o
.
NotifyPartitionChanges
:
case
*
prot
o
.
NotifyPartitionChanges
:
// TODO M sends us δPT -> save locally?
// TODO M sends us δPT -> save locally?
case
*
ne
o
.
NotifyNodeInformation
:
case
*
prot
o
.
NotifyNodeInformation
:
// XXX check for myUUID and consider it a command (like neo/py) does?
// XXX check for myUUID and consider it a command (like neo/py) does?
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
case
*
ne
o
.
NotifyClusterState
:
case
*
prot
o
.
NotifyClusterState
:
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
}
}
...
@@ -347,7 +348,7 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
...
@@ -347,7 +348,7 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
// reply M we are ready
// reply M we are ready
// XXX according to current neo/py this is separate send - not reply - and so we do here
// XXX according to current neo/py this is separate send - not reply - and so we do here
err
=
reqStart
.
Reply
(
&
ne
o
.
NotifyReady
{})
err
=
reqStart
.
Reply
(
&
prot
o
.
NotifyReady
{})
reqStart
.
Close
()
reqStart
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -373,16 +374,16 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
...
@@ -373,16 +374,16 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
default
:
default
:
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
case
*
ne
o
.
StopOperation
:
case
*
prot
o
.
StopOperation
:
return
fmt
.
Errorf
(
"stop requested"
)
return
fmt
.
Errorf
(
"stop requested"
)
// XXX SendPartitionTable?
// XXX SendPartitionTable?
// XXX NotifyPartitionChanges?
// XXX NotifyPartitionChanges?
case
*
ne
o
.
NotifyNodeInformation
:
case
*
prot
o
.
NotifyNodeInformation
:
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
case
*
ne
o
.
NotifyClusterState
:
case
*
prot
o
.
NotifyClusterState
:
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
// TODO commit related messages
// TODO commit related messages
...
@@ -394,13 +395,13 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
...
@@ -394,13 +395,13 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
// --- serve incoming connections from other nodes ---
// --- serve incoming connections from other nodes ---
// identify processes identification request from connected peer.
// identify processes identification request from connected peer.
func
(
stor
*
Storage
)
identify
(
idReq
*
neo
.
RequestIdentification
)
(
ne
o
.
Msg
,
bool
)
{
func
(
stor
*
Storage
)
identify
(
idReq
*
proto
.
RequestIdentification
)
(
prot
o
.
Msg
,
bool
)
{
// XXX stub: we accept clients and don't care about their UUID
// XXX stub: we accept clients and don't care about their UUID
if
idReq
.
NodeType
!=
ne
o
.
CLIENT
{
if
idReq
.
NodeType
!=
prot
o
.
CLIENT
{
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
"only clients are accepted"
},
false
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
"only clients are accepted"
},
false
}
}
if
idReq
.
ClusterName
!=
stor
.
node
.
ClusterName
{
if
idReq
.
ClusterName
!=
stor
.
node
.
ClusterName
{
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
"cluster name mismatch"
},
false
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
"cluster name mismatch"
},
false
}
}
// check operational
// check operational
...
@@ -409,10 +410,10 @@ func (stor *Storage) identify(idReq *neo.RequestIdentification) (neo.Msg, bool)
...
@@ -409,10 +410,10 @@ func (stor *Storage) identify(idReq *neo.RequestIdentification) (neo.Msg, bool)
stor
.
opMu
.
Unlock
()
stor
.
opMu
.
Unlock
()
if
!
operational
{
if
!
operational
{
return
&
neo
.
Error
{
ne
o
.
NOT_READY
,
"cluster not operational"
},
false
return
&
proto
.
Error
{
prot
o
.
NOT_READY
,
"cluster not operational"
},
false
}
}
return
&
ne
o
.
AcceptIdentification
{
return
&
prot
o
.
AcceptIdentification
{
NodeType
:
stor
.
node
.
MyInfo
.
Type
,
NodeType
:
stor
.
node
.
MyInfo
.
Type
,
MyUUID
:
stor
.
node
.
MyInfo
.
UUID
,
// XXX lock wrt update
MyUUID
:
stor
.
node
.
MyInfo
.
UUID
,
// XXX lock wrt update
NumPartitions
:
1
,
// XXX
NumPartitions
:
1
,
// XXX
...
@@ -435,7 +436,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
...
@@ -435,7 +436,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
// serveLink serves incoming node-node link connection
// serveLink serves incoming node-node link connection
func
(
stor
*
Storage
)
serveLink
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
idReq
*
ne
o
.
RequestIdentification
)
(
err
error
)
{
func
(
stor
*
Storage
)
serveLink
(
ctx
context
.
Context
,
req
*
neo
.
Request
,
idReq
*
prot
o
.
RequestIdentification
)
(
err
error
)
{
link
:=
req
.
Link
()
link
:=
req
.
Link
()
defer
task
.
Runningf
(
&
ctx
,
"serve %s"
,
link
)(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"serve %s"
,
link
)(
&
err
)
defer
xio
.
CloseWhenDone
(
ctx
,
link
)()
defer
xio
.
CloseWhenDone
(
ctx
,
link
)()
...
@@ -507,7 +508,7 @@ func (stor *Storage) serveClient(ctx context.Context, req neo.Request) {
...
@@ -507,7 +508,7 @@ func (stor *Storage) serveClient(ctx context.Context, req neo.Request) {
// XXX hack -> resp.Release()
// XXX hack -> resp.Release()
// XXX req.Msg release too?
// XXX req.Msg release too?
if
resp
,
ok
:=
resp
.
(
*
ne
o
.
AnswerObject
);
ok
{
if
resp
,
ok
:=
resp
.
(
*
prot
o
.
AnswerObject
);
ok
{
resp
.
Data
.
Release
()
resp
.
Data
.
Release
()
}
}
...
@@ -547,11 +548,11 @@ func sha1Sum(b []byte) [sha1.Size]byte {
...
@@ -547,11 +548,11 @@ func sha1Sum(b []byte) [sha1.Size]byte {
}
}
// serveClient1 prepares response for 1 request from client
// serveClient1 prepares response for 1 request from client
func
(
stor
*
Storage
)
serveClient1
(
ctx
context
.
Context
,
req
neo
.
Msg
)
(
resp
ne
o
.
Msg
)
{
func
(
stor
*
Storage
)
serveClient1
(
ctx
context
.
Context
,
req
proto
.
Msg
)
(
resp
prot
o
.
Msg
)
{
switch
req
:=
req
.
(
type
)
{
switch
req
:=
req
.
(
type
)
{
case
*
ne
o
.
GetObject
:
case
*
prot
o
.
GetObject
:
xid
:=
zodb
.
Xid
{
Oid
:
req
.
Oid
}
xid
:=
zodb
.
Xid
{
Oid
:
req
.
Oid
}
if
req
.
Serial
!=
ne
o
.
INVALID_TID
{
if
req
.
Serial
!=
prot
o
.
INVALID_TID
{
xid
.
At
=
req
.
Serial
xid
.
At
=
req
.
Serial
}
else
{
}
else
{
xid
.
At
=
common
.
Before2At
(
req
.
Tid
)
xid
.
At
=
common
.
Before2At
(
req
.
Tid
)
...
@@ -562,15 +563,15 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
...
@@ -562,15 +563,15 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
if
err
!=
nil
{
if
err
!=
nil
{
// translate err to NEO protocol error codes
// translate err to NEO protocol error codes
e
:=
err
.
(
*
zodb
.
OpError
)
// XXX move this to ErrEncode?
e
:=
err
.
(
*
zodb
.
OpError
)
// XXX move this to ErrEncode?
return
ne
o
.
ErrEncode
(
e
.
Err
)
return
prot
o
.
ErrEncode
(
e
.
Err
)
}
}
// compatibility with py side:
// compatibility with py side:
// for loadSerial - check we have exact hit - else "nodata"
// for loadSerial - check we have exact hit - else "nodata"
if
req
.
Serial
!=
ne
o
.
INVALID_TID
{
if
req
.
Serial
!=
prot
o
.
INVALID_TID
{
if
serial
!=
req
.
Serial
{
if
serial
!=
req
.
Serial
{
return
&
ne
o
.
Error
{
return
&
prot
o
.
Error
{
Code
:
ne
o
.
OID_NOT_FOUND
,
Code
:
prot
o
.
OID_NOT_FOUND
,
Message
:
fmt
.
Sprintf
(
"%s: no data with serial %s"
,
xid
.
Oid
,
req
.
Serial
),
Message
:
fmt
.
Sprintf
(
"%s: no data with serial %s"
,
xid
.
Oid
,
req
.
Serial
),
}
}
}
}
...
@@ -578,10 +579,10 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
...
@@ -578,10 +579,10 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
// no next serial -> None
// no next serial -> None
if
nextSerial
==
zodb
.
TidMax
{
if
nextSerial
==
zodb
.
TidMax
{
nextSerial
=
ne
o
.
INVALID_TID
nextSerial
=
prot
o
.
INVALID_TID
}
}
return
&
ne
o
.
AnswerObject
{
return
&
prot
o
.
AnswerObject
{
Oid
:
xid
.
Oid
,
Oid
:
xid
.
Oid
,
Serial
:
serial
,
Serial
:
serial
,
NextSerial
:
nextSerial
,
NextSerial
:
nextSerial
,
...
@@ -594,19 +595,19 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
...
@@ -594,19 +595,19 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
// XXX .DataSerial
// XXX .DataSerial
}
}
case
*
ne
o
.
LastTransaction
:
case
*
prot
o
.
LastTransaction
:
lastTid
,
err
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastTid
,
err
:=
stor
.
zstor
.
LastTid
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
ne
o
.
ErrEncode
(
err
)
return
prot
o
.
ErrEncode
(
err
)
}
}
return
&
ne
o
.
AnswerLastTransaction
{
lastTid
}
return
&
prot
o
.
AnswerLastTransaction
{
lastTid
}
//case *ObjectHistory:
//case *ObjectHistory:
//case *StoreObject:
//case *StoreObject:
default
:
default
:
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
)}
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
fmt
.
Sprintf
(
"unexpected message %T"
,
req
)}
}
}
//req.Put(...)
//req.Put(...)
...
...
go/neo/server/ztrace_test.go
View file @
47f069a5
...
@@ -8,24 +8,33 @@ import (
...
@@ -8,24 +8,33 @@ import (
_
"unsafe"
_
"unsafe"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
)
// traceimport: "lab.nexedi.com/kirr/neo/go/neo"
// traceimport: "lab.nexedi.com/kirr/neo/go/neo"
// rerun "gotrace gen" if you see link failure ↓↓↓
// rerun "gotrace gen" if you see link failure ↓↓↓
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_
933f43c04bbb1566c5d1e9ea518f9ed6e0f147a7
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_
470beceafeb4cecc8dee4072ee06329e20eef0f1
func
neo_trace_exporthash
()
func
neo_trace_exporthash
()
func
init
()
{
neo_trace_exporthash
()
}
func
init
()
{
neo_trace_exporthash
()
}
//go:linkname neo_traceClusterStateChanged_Attach lab.nexedi.com/kirr/neo/go/neo.traceClusterStateChanged_Attach
func
neo_traceClusterStateChanged_Attach
(
*
tracing
.
ProbeGroup
,
func
(
cs
*
neo
.
ClusterState
))
*
tracing
.
Probe
//go:linkname neo_traceMsgRecv_Attach lab.nexedi.com/kirr/neo/go/neo.traceMsgRecv_Attach
//go:linkname neo_traceMsgRecv_Attach lab.nexedi.com/kirr/neo/go/neo.traceMsgRecv_Attach
func
neo_traceMsgRecv_Attach
(
*
tracing
.
ProbeGroup
,
func
(
c
*
neo
.
Conn
,
msg
ne
o
.
Msg
))
*
tracing
.
Probe
func
neo_traceMsgRecv_Attach
(
*
tracing
.
ProbeGroup
,
func
(
c
*
neo
.
Conn
,
msg
prot
o
.
Msg
))
*
tracing
.
Probe
//go:linkname neo_traceMsgSendPre_Attach lab.nexedi.com/kirr/neo/go/neo.traceMsgSendPre_Attach
//go:linkname neo_traceMsgSendPre_Attach lab.nexedi.com/kirr/neo/go/neo.traceMsgSendPre_Attach
func
neo_traceMsgSendPre_Attach
(
*
tracing
.
ProbeGroup
,
func
(
l
*
neo
.
NodeLink
,
connId
uint32
,
msg
ne
o
.
Msg
))
*
tracing
.
Probe
func
neo_traceMsgSendPre_Attach
(
*
tracing
.
ProbeGroup
,
func
(
l
*
neo
.
NodeLink
,
connId
uint32
,
msg
prot
o
.
Msg
))
*
tracing
.
Probe
//go:linkname neo_traceNodeChanged_Attach lab.nexedi.com/kirr/neo/go/neo.traceNodeChanged_Attach
//go:linkname neo_traceNodeChanged_Attach lab.nexedi.com/kirr/neo/go/neo.traceNodeChanged_Attach
func
neo_traceNodeChanged_Attach
(
*
tracing
.
ProbeGroup
,
func
(
nt
*
neo
.
NodeTable
,
n
*
neo
.
Node
))
*
tracing
.
Probe
func
neo_traceNodeChanged_Attach
(
*
tracing
.
ProbeGroup
,
func
(
nt
*
neo
.
NodeTable
,
n
*
neo
.
Node
))
*
tracing
.
Probe
// traceimport: "lab.nexedi.com/kirr/neo/go/neo/proto"
// rerun "gotrace gen" if you see link failure ↓↓↓
//go:linkname proto_trace_exporthash lab.nexedi.com/kirr/neo/go/neo/proto._trace_exporthash_20c3e52fbfabe08e304139ab4a6bbf7c569f0994
func
proto_trace_exporthash
()
func
init
()
{
proto_trace_exporthash
()
}
//go:linkname proto_traceClusterStateChanged_Attach lab.nexedi.com/kirr/neo/go/neo/proto.traceClusterStateChanged_Attach
func
proto_traceClusterStateChanged_Attach
(
*
tracing
.
ProbeGroup
,
func
(
cs
*
proto
.
ClusterState
))
*
tracing
.
Probe
go/neo/ztrace.go
View file @
47f069a5
...
@@ -6,84 +6,59 @@ package neo
...
@@ -6,84 +6,59 @@ package neo
import
(
import
(
"lab.nexedi.com/kirr/go123/tracing"
"lab.nexedi.com/kirr/go123/tracing"
"unsafe"
"unsafe"
)
// traceevent: traceClusterStateChanged(cs *ClusterState)
type
_t_traceClusterStateChanged
struct
{
tracing
.
Probe
probefunc
func
(
cs
*
ClusterState
)
}
var
_traceClusterStateChanged
*
_t_traceClusterStateChanged
func
traceClusterStateChanged
(
cs
*
ClusterState
)
{
"lab.nexedi.com/kirr/neo/go/neo/proto"
if
_traceClusterStateChanged
!=
nil
{
)
_traceClusterStateChanged_run
(
cs
)
}
}
func
_traceClusterStateChanged_run
(
cs
*
ClusterState
)
{
for
p
:=
_traceClusterStateChanged
;
p
!=
nil
;
p
=
(
*
_t_traceClusterStateChanged
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
cs
)
}
}
func
traceClusterStateChanged_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
cs
*
ClusterState
))
*
tracing
.
Probe
{
p
:=
_t_traceClusterStateChanged
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceClusterStateChanged
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceevent: traceMsgRecv(c *Conn, msg Msg)
// traceevent: traceMsgRecv(c *Conn, msg
proto.
Msg)
type
_t_traceMsgRecv
struct
{
type
_t_traceMsgRecv
struct
{
tracing
.
Probe
tracing
.
Probe
probefunc
func
(
c
*
Conn
,
msg
Msg
)
probefunc
func
(
c
*
Conn
,
msg
proto
.
Msg
)
}
}
var
_traceMsgRecv
*
_t_traceMsgRecv
var
_traceMsgRecv
*
_t_traceMsgRecv
func
traceMsgRecv
(
c
*
Conn
,
msg
Msg
)
{
func
traceMsgRecv
(
c
*
Conn
,
msg
proto
.
Msg
)
{
if
_traceMsgRecv
!=
nil
{
if
_traceMsgRecv
!=
nil
{
_traceMsgRecv_run
(
c
,
msg
)
_traceMsgRecv_run
(
c
,
msg
)
}
}
}
}
func
_traceMsgRecv_run
(
c
*
Conn
,
msg
Msg
)
{
func
_traceMsgRecv_run
(
c
*
Conn
,
msg
proto
.
Msg
)
{
for
p
:=
_traceMsgRecv
;
p
!=
nil
;
p
=
(
*
_t_traceMsgRecv
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
for
p
:=
_traceMsgRecv
;
p
!=
nil
;
p
=
(
*
_t_traceMsgRecv
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
c
,
msg
)
p
.
probefunc
(
c
,
msg
)
}
}
}
}
func
traceMsgRecv_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
c
*
Conn
,
msg
Msg
))
*
tracing
.
Probe
{
func
traceMsgRecv_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
c
*
Conn
,
msg
proto
.
Msg
))
*
tracing
.
Probe
{
p
:=
_t_traceMsgRecv
{
probefunc
:
probe
}
p
:=
_t_traceMsgRecv
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgRecv
)),
&
p
.
Probe
)
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgRecv
)),
&
p
.
Probe
)
return
&
p
.
Probe
return
&
p
.
Probe
}
}
// traceevent: traceMsgSendPre(l *NodeLink, connId uint32, msg Msg)
// traceevent: traceMsgSendPre(l *NodeLink, connId uint32, msg
proto.
Msg)
type
_t_traceMsgSendPre
struct
{
type
_t_traceMsgSendPre
struct
{
tracing
.
Probe
tracing
.
Probe
probefunc
func
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
)
probefunc
func
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
)
}
}
var
_traceMsgSendPre
*
_t_traceMsgSendPre
var
_traceMsgSendPre
*
_t_traceMsgSendPre
func
traceMsgSendPre
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
)
{
func
traceMsgSendPre
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
)
{
if
_traceMsgSendPre
!=
nil
{
if
_traceMsgSendPre
!=
nil
{
_traceMsgSendPre_run
(
l
,
connId
,
msg
)
_traceMsgSendPre_run
(
l
,
connId
,
msg
)
}
}
}
}
func
_traceMsgSendPre_run
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
)
{
func
_traceMsgSendPre_run
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
)
{
for
p
:=
_traceMsgSendPre
;
p
!=
nil
;
p
=
(
*
_t_traceMsgSendPre
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
for
p
:=
_traceMsgSendPre
;
p
!=
nil
;
p
=
(
*
_t_traceMsgSendPre
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
l
,
connId
,
msg
)
p
.
probefunc
(
l
,
connId
,
msg
)
}
}
}
}
func
traceMsgSendPre_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
))
*
tracing
.
Probe
{
func
traceMsgSendPre_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
))
*
tracing
.
Probe
{
p
:=
_t_traceMsgSendPre
{
probefunc
:
probe
}
p
:=
_t_traceMsgSendPre
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgSendPre
)),
&
p
.
Probe
)
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgSendPre
)),
&
p
.
Probe
)
return
&
p
.
Probe
return
&
p
.
Probe
...
@@ -117,4 +92,4 @@ func traceNodeChanged_Attach(pg *tracing.ProbeGroup, probe func(nt *NodeTable, n
...
@@ -117,4 +92,4 @@ func traceNodeChanged_Attach(pg *tracing.ProbeGroup, probe func(nt *NodeTable, n
}
}
// trace export signature
// trace export signature
func
_trace_exporthash_
933f43c04bbb1566c5d1e9ea518f9ed6e0f147a7
()
{}
func
_trace_exporthash_
470beceafeb4cecc8dee4072ee06329e20eef0f1
()
{}
go/
neo
/packed.go
→
go/
xcommon/packed
/packed.go
View file @
47f069a5
...
@@ -17,13 +17,8 @@
...
@@ -17,13 +17,8 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
neo
// Package packed provides types to use in packed structures.
// Types to use in packed structures
package
packed
import
(
"encoding/binary"
"unsafe"
)
// uintX has alignment requirement =X; [X]byte has alignment requirement 1.
// uintX has alignment requirement =X; [X]byte has alignment requirement 1.
// That's why we can use [X]byte and this way keep a struct packed, even if Go
// That's why we can use [X]byte and this way keep a struct packed, even if Go
...
@@ -34,135 +29,26 @@ import (
...
@@ -34,135 +29,26 @@ import (
// https://github.com/golang/go/issues/15925
// https://github.com/golang/go/issues/15925
//
//
// so in the end we use hand-crafted array-like byte-structs.
// so in the end we use hand-crafted array-like byte-structs.
type
be16
struct
{
_0
,
_1
byte
}
type
BE16
struct
{
_0
,
_1
byte
}
type
be32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
type
BE32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
type
be64
struct
{
_0
,
_1
,
_2
,
_3
,
_4
,
_5
,
_6
,
_7
byte
}
// XXX naming ntoh{s,l,q} ?
func
ntoh16
(
v
be16
)
uint16
{
return
_ntoh16_0
(
v
)
}
// FIXME becomes bad - why??? !!!
func
hton16
(
v
uint16
)
be16
{
return
_hton16_0
(
v
)
}
// good
func
ntoh32
(
v
be32
)
uint32
{
return
_ntoh32_0
(
v
)
}
// FIXME becomes bad - why??? !!!
func
hton32
(
v
uint32
)
be32
{
return
_hton32_0
(
v
)
}
// good
func
ntoh64
(
v
be64
)
uint64
{
return
_ntoh64_0
(
v
)
}
// bad: on-stack temp
//func ntoh64(v be64) uint64 { return _ntoh64_1(v) } // bad: on-stack temp
//func hton64(v uint64) be64 { return _hton64_0(v) } // bad: on-stack temp
func
hton64
(
v
uint64
)
be64
{
return
_hton64_1
(
v
)
}
// bad: pre-clears r (here twice)
// ----------------------------------------
// good
func
Ntoh16
(
v
BE16
)
uint16
{
func
_ntoh16_0
(
v
be16
)
uint16
{
// XXX not as good as BigEndian.Uint16
b
:=
(
*
[
2
]
byte
)(
unsafe
.
Pointer
(
&
v
))
// (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
return
binary
.
BigEndian
.
Uint16
(
b
[
:
])
}
// bad (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
// XXX why?
func
_ntoh16_1
(
v
be16
)
uint16
{
return
uint16
(
v
.
_1
)
|
uint16
(
v
.
_0
)
<<
8
return
uint16
(
v
.
_1
)
|
uint16
(
v
.
_0
)
<<
8
}
}
// good
func
Hton16
(
v
uint16
)
BE16
{
func
_hton16_0
(
v
uint16
)
be16
{
return
BE16
{
byte
(
v
>>
8
),
byte
(
v
)}
return
be16
{
byte
(
v
>>
8
),
byte
(
v
)}
}
// good
func
_hton16_1
(
v
uint16
)
(
r
be16
)
{
r
.
_0
=
byte
(
v
>>
8
)
r
.
_1
=
byte
(
v
)
return
r
}
// bad (partly (!?) preclears r)
func
_hton16_2
(
v
uint16
)
(
r
be16
)
{
b
:=
(
*
[
2
]
byte
)(
unsafe
.
Pointer
(
&
r
))
binary
.
BigEndian
.
PutUint16
(
b
[
:
],
v
)
return
r
}
// ----------------------------------------
// good
func
_ntoh32_0
(
v
be32
)
uint32
{
b
:=
(
*
[
4
]
byte
)(
unsafe
.
Pointer
(
&
v
))
return
binary
.
BigEndian
.
Uint32
(
b
[
:
])
}
}
// baaaadd (unnecessary MOVBLZX AL, AX + shifts not combined into BSWAPL)
func
Ntoh32
(
v
BE32
)
uint32
{
// XXX why?
// XXX not as good as BigEndian.Uint32
func
_ntoh32_1
(
v
be32
)
uint32
{
// (unnecessary MOVBLZX AL, AX + shifts not combined into BSWAPL)
return
uint32
(
v
.
_3
)
|
uint32
(
v
.
_2
)
<<
8
|
uint32
(
v
.
_1
)
<<
16
|
uint32
(
v
.
_0
)
<<
24
return
uint32
(
v
.
_3
)
|
uint32
(
v
.
_2
)
<<
8
|
uint32
(
v
.
_1
)
<<
16
|
uint32
(
v
.
_0
)
<<
24
}
}
// good
func
Hton32
(
v
uint32
)
BE32
{
func
_hton32_0
(
v
uint32
)
be32
{
return
BE32
{
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
return
be32
{
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
}
// good
func
_hton32_1
(
v
uint32
)
(
r
be32
)
{
r
.
_0
=
byte
(
v
>>
24
)
r
.
_1
=
byte
(
v
>>
16
)
r
.
_2
=
byte
(
v
>>
8
)
r
.
_3
=
byte
(
v
)
return
r
}
// bad (partly (!?) preclears r)
func
hton32_2
(
v
uint32
)
(
r
be32
)
{
b
:=
(
*
[
4
]
byte
)(
unsafe
.
Pointer
(
&
r
))
binary
.
BigEndian
.
PutUint32
(
b
[
:
],
v
)
return
r
}
// ----------------------------------------
// good
func
_ntoh64_0
(
v
be64
)
uint64
{
b
:=
(
*
[
8
]
byte
)(
unsafe
.
Pointer
(
&
v
))
return
binary
.
BigEndian
.
Uint64
(
b
[
:
])
}
// good (XXX why vs _ntoh32_1 ?)
func
_ntoh64_1
(
v
be64
)
uint64
{
return
uint64
(
v
.
_7
)
|
uint64
(
v
.
_6
)
<<
8
|
uint64
(
v
.
_5
)
<<
16
|
uint64
(
v
.
_4
)
<<
24
|
uint64
(
v
.
_3
)
<<
32
|
uint64
(
v
.
_2
)
<<
40
|
uint64
(
v
.
_1
)
<<
48
|
uint64
(
v
.
_0
)
<<
56
}
// baad (+local temp; r = temp)
func
_hton64_0
(
v
uint64
)
be64
{
return
be64
{
byte
(
v
>>
56
),
byte
(
v
>>
48
),
byte
(
v
>>
40
),
byte
(
v
>>
32
),
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
}
// bad (pre-clears r)
func
_hton64_1
(
v
uint64
)
(
r
be64
)
{
r
.
_0
=
byte
(
v
>>
56
)
r
.
_1
=
byte
(
v
>>
48
)
r
.
_2
=
byte
(
v
>>
40
)
r
.
_3
=
byte
(
v
>>
32
)
r
.
_4
=
byte
(
v
>>
24
)
r
.
_5
=
byte
(
v
>>
16
)
r
.
_6
=
byte
(
v
>>
8
)
r
.
_7
=
byte
(
v
)
return
r
}
// bad (pre-clears r)
func
hton64_2
(
v
uint64
)
(
r
be64
)
{
b
:=
(
*
[
8
]
byte
)(
unsafe
.
Pointer
(
&
r
))
binary
.
BigEndian
.
PutUint64
(
b
[
:
],
v
)
return
r
}
// bad (pre-clears r)
func
hton64_3
(
v
uint64
)
(
r
be64
)
{
b
:=
(
*
[
8
]
byte
)(
unsafe
.
Pointer
(
&
v
))
*
(
*
uint64
)(
unsafe
.
Pointer
(
&
r
))
=
binary
.
BigEndian
.
Uint64
(
b
[
:
])
return
}
}
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