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 (
"lab.nexedi.com/kirr/go123/xnet"
"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/zodb"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
...
...
@@ -77,7 +78,7 @@ var _ zodb.IStorageDriver = (*Client)(nil)
// It will connect to master @masterAddr and identify with specified cluster name.
func
NewClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
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
{}),
operational
:
false
,
opReady
:
make
(
chan
struct
{}),
...
...
@@ -225,7 +226,7 @@ func (c *Client) talkMaster(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
{
// FIXME it is not only identification - e.g. ECONNREFUSED
return
err
...
...
@@ -302,17 +303,17 @@ func (c *Client) recvMaster1(ctx context.Context, req neo.Request) error {
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
// M sends whole PT
case
*
ne
o
.
SendPartitionTable
:
case
*
prot
o
.
SendPartitionTable
:
c
.
node
.
UpdatePartTab
(
ctx
,
msg
)
// M sends δPT
//case *
ne
o.NotifyPartitionChanges:
//case *
prot
o.NotifyPartitionChanges:
// TODO
case
*
ne
o
.
NotifyNodeInformation
:
case
*
prot
o
.
NotifyNodeInformation
:
c
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
case
*
ne
o
.
NotifyClusterState
:
case
*
prot
o
.
NotifyClusterState
:
c
.
node
.
UpdateClusterState
(
ctx
,
msg
)
}
...
...
@@ -328,8 +329,8 @@ func (c *Client) initFromMaster(ctx context.Context, mlink *neo.NodeLink) (err e
defer
task
.
Running
(
&
ctx
,
"init"
)(
&
err
)
// ask M for PT
rpt
:=
ne
o
.
AnswerPartitionTable
{}
err
=
mlink
.
Ask1
(
&
ne
o
.
AskPartitionTable
{},
&
rpt
)
rpt
:=
prot
o
.
AnswerPartitionTable
{}
err
=
mlink
.
Ask1
(
&
prot
o
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
return
err
}
...
...
@@ -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 do we want to return error or retry?
reply
:=
ne
o
.
AnswerLastTransaction
{}
err
=
mlink
.
Ask1
(
&
ne
o
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
reply
:=
prot
o
.
AnswerLastTransaction
{}
err
=
mlink
.
Ask1
(
&
prot
o
.
LastTransaction
{},
&
reply
)
// XXX Ask += ctx
if
err
!=
nil
{
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
if
cell
.
Readable
()
{
stor
:=
c
.
node
.
NodeTab
.
Get
(
cell
.
UUID
)
// 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
)
}
}
...
...
@@ -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)
// on the wire it comes as "before", not "at"
req
:=
ne
o
.
GetObject
{
req
:=
prot
o
.
GetObject
{
Oid
:
xid
.
Oid
,
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
)
if
err
!=
nil
{
return
nil
,
0
,
err
// XXX err context
...
...
go/neo/connection.go
View file @
47f069a5
...
...
@@ -34,6 +34,9 @@ import (
"sync/atomic"
"time"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
"github.com/someonegg/gocontainer/rbuf"
"lab.nexedi.com/kirr/go123/xbytes"
...
...
@@ -457,7 +460,7 @@ func (c *Conn) shutdownTX() {
}
// 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
()
{
// close(c.rxdown) // wakeup Conn.Recv
c
.
downRX
(
errMsg
)
...
...
@@ -467,7 +470,7 @@ func (c *Conn) shutdownRX(errMsg *Error) {
// downRX marks .rxq as no longer operational.
//
// 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
c
.
rxdownFlag
.
Set
(
1
)
// XXX cmpxchg and return if already down?
...
...
@@ -740,7 +743,7 @@ func (nl *NodeLink) serveRecv() {
}
// pkt.ConnId -> Conn
connId
:=
n
toh32
(
pkt
.
Header
()
.
ConnId
)
connId
:=
packed
.
N
toh32
(
pkt
.
Header
()
.
ConnId
)
accept
:=
false
nl
.
connMu
.
Lock
()
...
...
@@ -921,11 +924,11 @@ func (nl *NodeLink) serveRecv() {
// ---- network replies for closed / refused connections ----
var
errConnClosed
=
&
Error
{
PROTOCOL_ERROR
,
"connection closed"
}
var
errConnRefused
=
&
Error
{
PROTOCOL_ERROR
,
"connection refused"
}
var
errConnClosed
=
&
proto
.
Error
{
proto
.
PROTOCOL_ERROR
,
"connection closed"
}
var
errConnRefused
=
&
proto
.
Error
{
proto
.
PROTOCOL_ERROR
,
"connection refused"
}
// 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)
link
.
sendMsg
(
connId
,
errMsg
)
// ignore errors
//fmt.Printf("%s .%d: replyNoConn(%v) -> %v\n", link, connId, errMsg, err)
...
...
@@ -967,7 +970,7 @@ func (c *Conn) sendPkt(pkt *PktBuf) error {
func
(
c
*
Conn
)
sendPkt2
(
pkt
*
PktBuf
)
error
{
// 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"
)
}
...
...
@@ -1052,7 +1055,7 @@ func (nl *NodeLink) serveSend() {
// sendPktDirect sends raw packet with appropriate connection ID directly via link.
func
(
c
*
Conn
)
sendPktDirect
(
pkt
*
PktBuf
)
error
{
// 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
err
:=
c
.
link
.
sendPkt
(
pkt
)
...
...
@@ -1108,13 +1111,13 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
// next packet could be already prefetched in part by previous read
if
nl
.
rxbuf
.
Len
()
>
0
{
δn
,
_
:=
nl
.
rxbuf
.
Read
(
data
[
:
pktHeaderLen
])
δn
,
_
:=
nl
.
rxbuf
.
Read
(
data
[
:
p
roto
.
P
ktHeaderLen
])
n
+=
δn
}
// first read to read pkt header and hopefully rest of packet in 1 syscall
if
n
<
pktHeaderLen
{
δn
,
err
:=
io
.
ReadAtLeast
(
nl
.
peerLink
,
data
[
n
:
],
pktHeaderLen
-
n
)
if
n
<
p
roto
.
P
ktHeaderLen
{
δn
,
err
:=
io
.
ReadAtLeast
(
nl
.
peerLink
,
data
[
n
:
],
p
roto
.
P
ktHeaderLen
-
n
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -1123,8 +1126,8 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
pkth
:=
pkt
.
Header
()
pktLen
:=
int
(
p
ktHeaderLen
+
n
toh32
(
pkth
.
MsgLen
))
// whole packet length
if
pktLen
>
pktMaxSize
{
pktLen
:=
int
(
p
roto
.
PktHeaderLen
+
packed
.
N
toh32
(
pkth
.
MsgLen
))
// whole packet length
if
pktLen
>
p
roto
.
P
ktMaxSize
{
return
nil
,
ErrPktTooBig
}
...
...
@@ -1171,7 +1174,7 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
// On success raw connection is returned wrapped into NodeLink.
// On error raw connection is closed.
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
{
return
nil
,
err
}
...
...
@@ -1450,21 +1453,21 @@ func (c *Conn) err(op string, e error) error {
// ---- exchange of messages ----
//trace:event traceMsgRecv(c *Conn, msg Msg)
//trace:event traceMsgSendPre(l *NodeLink, connId uint32, msg Msg)
//trace:event traceMsgRecv(c *Conn, msg
proto.
Msg)
//trace:event traceMsgSendPre(l *NodeLink, connId uint32, msg
proto.
Msg)
// XXX do we also need traceConnSend?
// msgPack allocates PktBuf and encodes msg into it.
func
msgPack
(
connId
uint32
,
msg
Msg
)
*
PktBuf
{
l
:=
msg
.
neo
MsgEncodedLen
()
buf
:=
pktAlloc
(
pktHeaderLen
+
l
)
func
msgPack
(
connId
uint32
,
msg
proto
.
Msg
)
*
PktBuf
{
l
:=
msg
.
NEO
MsgEncodedLen
()
buf
:=
pktAlloc
(
p
roto
.
P
ktHeaderLen
+
l
)
h
:=
buf
.
Header
()
h
.
ConnId
=
h
ton32
(
connId
)
h
.
MsgCode
=
hton16
(
msg
.
neo
MsgCode
())
h
.
MsgLen
=
h
ton32
(
uint32
(
l
))
// XXX casting: think again
h
.
ConnId
=
packed
.
H
ton32
(
connId
)
h
.
MsgCode
=
packed
.
Hton16
(
msg
.
NEO
MsgCode
())
h
.
MsgLen
=
packed
.
H
ton32
(
uint32
(
l
))
// XXX casting: think again
msg
.
neo
MsgEncode
(
buf
.
Payload
())
msg
.
NEO
MsgEncode
(
buf
.
Payload
())
return
buf
}
...
...
@@ -1472,7 +1475,7 @@ func msgPack(connId uint32, msg Msg) *PktBuf {
// Recv receives message
// 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
()
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -1483,11 +1486,11 @@ func (c *Conn) Recv() (Msg, error) {
return
msg
,
err
}
func
(
c
*
Conn
)
_Recv
(
pkt
*
PktBuf
)
(
Msg
,
error
)
{
func
(
c
*
Conn
)
_Recv
(
pkt
*
PktBuf
)
(
proto
.
Msg
,
error
)
{
// decode packet
pkth
:=
pkt
.
Header
()
msgCode
:=
n
toh16
(
pkth
.
MsgCode
)
msgType
:=
msgTypeRegistry
[
msgCode
]
msgCode
:=
packed
.
N
toh16
(
pkth
.
MsgCode
)
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
err
:=
fmt
.
Errorf
(
"invalid msgCode (%d)"
,
msgCode
)
// XXX "decode" -> "recv: decode"?
...
...
@@ -1495,11 +1498,11 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
}
// 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())
_
,
err
:=
msg
.
neo
MsgDecode
(
pkt
.
Payload
())
_
,
err
:=
msg
.
NEO
MsgDecode
(
pkt
.
Payload
())
if
err
!=
nil
{
return
nil
,
c
.
err
(
"decode"
,
err
)
// XXX "decode:" is already in ErrDecodeOverflow
}
...
...
@@ -1513,7 +1516,7 @@ func (c *Conn) _Recv(pkt *PktBuf) (Msg, error) {
// 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?
func
(
link
*
NodeLink
)
sendMsg
(
connId
uint32
,
msg
Msg
)
error
{
func
(
link
*
NodeLink
)
sendMsg
(
connId
uint32
,
msg
proto
.
Msg
)
error
{
traceMsgSendPre
(
link
,
connId
,
msg
)
buf
:=
msgPack
(
connId
,
msg
)
...
...
@@ -1524,14 +1527,14 @@ func (link *NodeLink) sendMsg(connId uint32, msg Msg) error {
// Send sends message.
//
// 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
)
buf
:=
msgPack
(
c
.
connId
,
msg
)
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
)
}
...
...
@@ -1542,7 +1545,7 @@ func (c *Conn) sendMsgDirect(msg Msg) error {
// which indicates index of received message.
//
// 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
pkt
,
err
:=
c
.
recvPkt
()
if
err
!=
nil
{
...
...
@@ -1554,13 +1557,13 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) {
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
()
msgCode
:=
n
toh16
(
pkth
.
MsgCode
)
msgCode
:=
packed
.
N
toh16
(
pkth
.
MsgCode
)
for
i
,
msg
:=
range
msgv
{
if
msg
.
neo
MsgCode
()
==
msgCode
{
_
,
err
:=
msg
.
neo
MsgDecode
(
pkt
.
Payload
())
if
msg
.
NEO
MsgCode
()
==
msgCode
{
_
,
err
:=
msg
.
NEO
MsgDecode
(
pkt
.
Payload
())
if
err
!=
nil
{
return
-
1
,
c
.
err
(
"decode"
,
err
)
}
...
...
@@ -1569,7 +1572,7 @@ func (c *Conn) _Expect(pkt *PktBuf, msgv ...Msg) (int, error) {
}
// unexpected message
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
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) {
// It expects response to be exactly of resp type and errors otherwise
// XXX clarify error semantic (when Error is decoded)
// 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
)
if
err
!=
nil
{
return
err
}
nerr
:=
&
Error
{}
nerr
:=
&
proto
.
Error
{}
which
,
err
:=
c
.
Expect
(
resp
,
nerr
)
switch
which
{
case
0
:
return
nil
case
1
:
return
ErrDecode
(
nerr
)
return
proto
.
ErrDecode
(
nerr
)
}
return
err
...
...
@@ -1637,7 +1640,7 @@ func (c *Conn) lightClose() {
//
// Request represents 1 request - 0|1 reply interaction model XXX
type
Request
struct
{
Msg
Msg
Msg
proto
.
Msg
conn
*
Conn
}
...
...
@@ -1668,7 +1671,7 @@ func (link *NodeLink) Recv1() (Request, error) {
// Reply sends response to request.
//
// XXX doc
func
(
req
*
Request
)
Reply
(
resp
Msg
)
error
{
func
(
req
*
Request
)
Reply
(
resp
proto
.
Msg
)
error
{
return
req
.
conn
.
sendMsgDirect
(
resp
)
//err1 := req.conn.Send(resp)
//err2 := req.conn.Close() // XXX no - only Send here?
...
...
@@ -1690,7 +1693,7 @@ func (req *Request) Close() { // XXX +error?
// Send1 sends one message over link.
//
// XXX doc
func
(
link
*
NodeLink
)
Send1
(
msg
Msg
)
error
{
func
(
link
*
NodeLink
)
Send1
(
msg
proto
.
Msg
)
error
{
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
return
err
...
...
@@ -1708,7 +1711,7 @@ func (link *NodeLink) Send1(msg Msg) error {
//
// See Conn.Ask for semantic details.
// 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
()
if
err
!=
nil
{
return
err
...
...
@@ -1720,19 +1723,19 @@ func (link *NodeLink) Ask1(req Msg, resp Msg) (err error) {
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
)
if
err
!=
nil
{
return
err
}
nerr
:=
&
Error
{}
nerr
:=
&
proto
.
Error
{}
which
,
err
:=
conn
.
Expect
(
resp
,
nerr
)
switch
which
{
case
0
:
return
nil
case
1
:
return
ErrDecode
(
nerr
)
return
proto
.
ErrDecode
(
nerr
)
}
return
err
...
...
go/neo/connection_test.go
View file @
47f069a5
...
...
@@ -35,7 +35,10 @@ import (
"lab.nexedi.com/kirr/go123/exc"
"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/neo/proto"
"github.com/kylelemons/godebug/pretty"
"github.com/pkg/errors"
...
...
@@ -103,11 +106,11 @@ func xconnError(err error) error {
// Prepare PktBuf with content
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
.
ConnId
=
h
ton32
(
connid
)
h
.
MsgCode
=
h
ton16
(
msgcode
)
h
.
MsgLen
=
h
ton32
(
uint32
(
len
(
payload
)))
h
.
ConnId
=
packed
.
H
ton32
(
connid
)
h
.
MsgCode
=
packed
.
H
ton16
(
msgcode
)
h
.
MsgLen
=
packed
.
H
ton32
(
uint32
(
len
(
payload
)))
copy
(
pkt
.
Payload
(),
payload
)
return
pkt
}
...
...
@@ -122,14 +125,14 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
errv
:=
xerr
.
Errorv
{}
h
:=
pkt
.
Header
()
// TODO include caller location
if
n
toh32
(
h
.
ConnId
)
!=
connid
{
errv
.
Appendf
(
"header: unexpected connid %v (want %v)"
,
n
toh32
(
h
.
ConnId
),
connid
)
if
packed
.
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
{
errv
.
Appendf
(
"header: unexpected msgcode %v (want %v)"
,
n
toh16
(
h
.
MsgCode
),
msgcode
)
if
packed
.
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
))
{
errv
.
Appendf
(
"header: unexpected msglen %v (want %v)"
,
n
toh32
(
h
.
MsgLen
),
len
(
payload
))
if
packed
.
N
toh32
(
h
.
MsgLen
)
!=
uint32
(
len
(
payload
))
{
errv
.
Appendf
(
"header: unexpected msglen %v (want %v)"
,
packed
.
N
toh32
(
h
.
MsgLen
),
len
(
payload
))
}
if
!
bytes
.
Equal
(
pkt
.
Payload
(),
payload
)
{
errv
.
Appendf
(
"payload differ:
\n
%s"
,
...
...
@@ -140,10 +143,10 @@ func xverifyPkt(pkt *PktBuf, connid uint32, msgcode uint16, payload []byte) {
}
// Verify PktBuf to match expected message
func
xverifyPktMsg
(
pkt
*
PktBuf
,
connid
uint32
,
msg
Msg
)
{
data
:=
make
([]
byte
,
msg
.
neo
MsgEncodedLen
())
msg
.
neo
MsgEncode
(
data
)
xverifyPkt
(
pkt
,
connid
,
msg
.
neo
MsgCode
(),
data
)
func
xverifyPktMsg
(
pkt
*
PktBuf
,
connid
uint32
,
msg
proto
.
Msg
)
{
data
:=
make
([]
byte
,
msg
.
NEO
MsgEncodedLen
())
msg
.
NEO
MsgEncode
(
data
)
xverifyPkt
(
pkt
,
connid
,
msg
.
NEO
MsgCode
(),
data
)
}
// delay a bit
...
...
@@ -625,7 +628,7 @@ func TestNodeLink(t *testing.T) {
gox
(
wg
,
func
()
{
pkt
:=
xrecvPkt
(
c
)
n
:=
n
toh16
(
pkt
.
Header
()
.
MsgCode
)
n
:=
packed
.
N
toh16
(
pkt
.
Header
()
.
MsgCode
)
x
:=
replyOrder
[
n
]
// wait before it is our turn & echo pkt back
...
...
@@ -743,12 +746,12 @@ func TestHandshake(t *testing.T) {
// ---- recv1 mode ----
func
xSend
(
c
*
Conn
,
msg
Msg
)
{
func
xSend
(
c
*
Conn
,
msg
proto
.
Msg
)
{
err
:=
c
.
Send
(
msg
)
exc
.
Raiseif
(
err
)
}
func
xRecv
(
c
*
Conn
)
Msg
{
func
xRecv
(
c
*
Conn
)
proto
.
Msg
{
msg
,
err
:=
c
.
Recv
()
exc
.
Raiseif
(
err
)
return
msg
...
...
@@ -760,12 +763,12 @@ func xRecv1(l *NodeLink) Request {
return
req
}
func
xSend1
(
l
*
NodeLink
,
msg
Msg
)
{
func
xSend1
(
l
*
NodeLink
,
msg
proto
.
Msg
)
{
err
:=
l
.
Send1
(
msg
)
exc
.
Raiseif
(
err
)
}
func
xverifyMsg
(
msg1
,
msg2
Msg
)
{
func
xverifyMsg
(
msg1
,
msg2
proto
.
Msg
)
{
if
!
reflect
.
DeepEqual
(
msg1
,
msg2
)
{
exc
.
Raisef
(
"messages differ:
\n
%s"
,
pretty
.
Compare
(
msg1
,
msg2
))
}
...
...
@@ -789,8 +792,8 @@ func TestRecv1Mode(t *testing.T) {
//println("X aaa + 1")
msg
:=
xRecv
(
c
)
//println("X aaa + 2")
xverifyMsg
(
msg
,
&
Ping
{})
xSend
(
c
,
&
Pong
{})
xverifyMsg
(
msg
,
&
proto
.
Ping
{})
xSend
(
c
,
&
proto
.
Pong
{})
//println("X aaa + 3")
msg
=
xRecv
(
c
)
//println("X aaa + 4")
...
...
@@ -803,8 +806,8 @@ func TestRecv1Mode(t *testing.T) {
c
=
xaccept
(
nl2
)
msg
=
xRecv
(
c
)
//fmt.Println("X zzz + 1", c, msg)
xverifyMsg
(
msg
,
&
Error
{
ACK
,
"hello up there"
})
xSend
(
c
,
&
Error
{
ACK
,
"hello to you too"
})
xverifyMsg
(
msg
,
&
proto
.
Error
{
proto
.
ACK
,
"hello up there"
})
xSend
(
c
,
&
proto
.
Error
{
proto
.
ACK
,
"hello to you too"
})
msg
=
xRecv
(
c
)
//println("X zzz + 2")
xverifyMsg
(
msg
,
errConnClosed
)
...
...
@@ -813,14 +816,14 @@ func TestRecv1Mode(t *testing.T) {
})
//println("aaa")
xSend1
(
nl1
,
&
Ping
{})
xSend1
(
nl1
,
&
proto
.
Ping
{})
// before next Send1 wait till peer receives errConnClosed from us
// otherwise peer could be already in accept while our errConnClosed is received
// and there is only one receiving thread there ^^^
<-
sync
//println("bbb")
xSend1
(
nl1
,
&
Error
{
ACK
,
"hello up there"
})
xSend1
(
nl1
,
&
proto
.
Error
{
proto
.
ACK
,
"hello up there"
})
//println("ccc")
xwait
(
wg
)
...
...
@@ -832,9 +835,9 @@ func TestRecv1Mode(t *testing.T) {
c
:=
xnewconn
(
nl2
)
//println("aaa")
xSend
(
c
,
&
Ping
{})
xSend
(
c
,
&
proto
.
Ping
{})
//println("bbb")
xSend
(
c
,
&
Ping
{})
xSend
(
c
,
&
proto
.
Ping
{})
//println("ccc")
msg
:=
xRecv
(
c
)
//println("ddd")
...
...
@@ -1158,8 +1161,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
default
:
b
.
Fatalf
(
"read -> unexpected message %T"
,
msg
)
case
*
GetObject
:
err
=
req
.
Reply
(
&
AnswerObject
{
case
*
proto
.
GetObject
:
err
=
req
.
Reply
(
&
proto
.
AnswerObject
{
Oid
:
msg
.
Oid
,
Serial
:
msg
.
Serial
,
DataSerial
:
msg
.
Tid
,
...
...
@@ -1175,8 +1178,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
// NOTE keeping inside loop to simulate what happens in real Load
get
:=
&
GetObject
{}
obj
:=
&
AnswerObject
{}
get
:=
&
proto
.
GetObject
{}
obj
:=
&
proto
.
AnswerObject
{}
get
.
Oid
=
zodb
.
Oid
(
i
)
get
.
Serial
=
zodb
.
Tid
(
i
+
1
)
...
...
go/neo/neo.go
View file @
47f069a5
...
...
@@ -38,26 +38,15 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
//"lab.nexedi.com/kirr/neo/go/xcommon/xio"
"lab.nexedi.com/kirr/neo/go/zodb"
)
const
(
//INVALID_UUID UUID = 0
// XXX -> zodb?
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
// OID_LEN = 8
// TID_LEN = 8
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
// NodeApp is base for implementing NEO node applications.
//
// XXX -> internal?
type
NodeApp
struct
{
MyInfo
NodeInfo
MyInfo
proto
.
NodeInfo
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
...
...
@@ -66,22 +55,22 @@ type NodeApp struct {
StateMu
sync
.
RWMutex
// <- XXX just embed?
NodeTab
*
NodeTable
// information about nodes 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
OnShutdown
func
()
}
// 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
addr
,
err
:=
AddrString
(
net
.
Network
(),
serveAddr
)
addr
,
err
:=
proto
.
AddrString
(
net
.
Network
(),
serveAddr
)
if
err
!=
nil
{
panic
(
err
)
// XXX
}
app
:=
&
NodeApp
{
MyInfo
:
NodeInfo
{
Type
:
typ
,
Addr
:
addr
,
IdTime
:
IdTimeNone
},
MyInfo
:
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
addr
,
IdTime
:
proto
.
IdTimeNone
},
ClusterName
:
clusterName
,
Net
:
net
,
MasterAddr
:
masterAddr
,
...
...
@@ -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.
// 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
)
link
,
err
:=
DialLink
(
ctx
,
app
.
Net
,
addr
)
...
...
@@ -125,14 +114,14 @@ func (app *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_
}
}()
req
:=
&
RequestIdentification
{
req
:=
&
proto
.
RequestIdentification
{
NodeType
:
app
.
MyInfo
.
Type
,
UUID
:
app
.
MyInfo
.
UUID
,
Address
:
app
.
MyInfo
.
Addr
,
ClusterName
:
app
.
ClusterName
,
IdTime
:
app
.
MyInfo
.
IdTime
,
// XXX ok?
}
accept
:=
&
AcceptIdentification
{}
accept
:=
&
proto
.
AcceptIdentification
{}
// FIXME error if peer sends us something with another connID
// (currently we ignore and serveRecv will deadlock)
//
...
...
@@ -179,7 +168,7 @@ func (app *NodeApp) Listen() (Listener, error) {
// NOTE listen("tcp", ":1234") gives l.Addr 0.0.0.0:1234 and
// listen("tcp6", ":1234") gives l.Addr [::]:1234
// -> host is never empty
addr
,
err
:=
Addr
(
ll
.
Addr
())
addr
,
err
:=
proto
.
Addr
(
ll
.
Addr
())
if
err
!=
nil
{
// XXX -> panic here ?
ll
.
Close
()
...
...
@@ -216,7 +205,7 @@ type Listener interface {
// After successful accept it is the caller responsibility to reply the request.
//
// NOTE established link is Request.Link().
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
RequestIdentification
,
error
)
Accept
(
ctx
context
.
Context
)
(
*
Request
,
*
proto
.
RequestIdentification
,
error
)
}
type
listener
struct
{
...
...
@@ -227,7 +216,7 @@ type listener struct {
type
accepted
struct
{
req
*
Request
idReq
*
RequestIdentification
idReq
*
proto
.
RequestIdentification
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
{
return
nil
,
nil
,
err0
}
...
...
@@ -299,16 +288,16 @@ func (l *listener) accept1(ctx context.Context, link *NodeLink, err0 error) (_ *
}
switch
msg
:=
req
.
Msg
.
(
type
)
{
case
*
RequestIdentification
:
case
*
proto
.
RequestIdentification
:
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
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
{
case
<-
l
.
closed
:
// we know raw listener is already closed - return proper error about it
...
...
@@ -330,7 +319,7 @@ func (l *listener) Addr() net.Addr {
// ----------------------------------------
// 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 ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"node update: %v"
,
nodeInfo
)
...
...
@@ -344,7 +333,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
app
.
MyInfo
.
IdTime
=
nodeInfo
.
IdTime
// 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
.
Flush
()
app
.
OnShutdown
()
...
...
@@ -359,7 +348,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
}
// 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
)
// XXX logging under lock
log
.
Infof
(
ctx
,
"parttab update: %v"
,
pt
)
...
...
@@ -367,7 +356,7 @@ func (app *NodeApp) UpdatePartTab(ctx context.Context, msg *SendPartitionTable)
}
// 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
log
.
Infof
(
ctx
,
"state update: %v"
,
msg
.
State
)
app
.
ClusterState
.
Set
(
msg
.
State
)
...
...
go/neo/nodetab.go
View file @
47f069a5
...
...
@@ -27,6 +27,8 @@ import (
"sync"
"time"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
)
...
...
@@ -67,7 +69,7 @@ type NodeTable struct {
//storv []*Node // storages
nodev
[]
*
Node
// all other nodes
notifyv
[]
chan
NodeInfo
// subscribers
notifyv
[]
chan
proto
.
NodeInfo
// subscribers
}
//trace:event traceNodeChanged(nt *NodeTable, n *Node)
...
...
@@ -78,7 +80,7 @@ type NodeTable struct {
type
Node
struct
{
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
link
*
NodeLink
// link to this peer; nil if not connected
...
...
@@ -115,7 +117,7 @@ func (nt *NodeTable) All() []*Node {
}
// Get finds node by uuid.
func
(
nt
*
NodeTable
)
Get
(
uuid
NodeUUID
)
*
Node
{
func
(
nt
*
NodeTable
)
Get
(
uuid
proto
.
NodeUUID
)
*
Node
{
// FIXME linear scan
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
UUID
==
uuid
{
...
...
@@ -130,7 +132,7 @@ func (nt *NodeTable) Get(uuid NodeUUID) *Node {
// Update updates information about a node.
//
// 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
)
if
node
==
nil
{
node
=
&
Node
{
nodeTab
:
nt
}
...
...
@@ -156,7 +158,7 @@ func (nt *NodeTable) StorageList() []*Node {
// FIXME linear scan
sl
:=
[]
*
Node
{}
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
Type
==
STORAGE
{
if
node
.
Type
==
proto
.
STORAGE
{
sl
=
append
(
sl
,
node
)
}
}
...
...
@@ -165,7 +167,7 @@ func (nt *NodeTable) StorageList() []*Node {
// XXX doc
func
(
n
*
Node
)
SetState
(
state
NodeState
)
{
func
(
n
*
Node
)
SetState
(
state
proto
.
NodeState
)
{
n
.
State
=
state
traceNodeChanged
(
n
.
nodeTab
,
n
)
n
.
nodeTab
.
notify
(
n
.
NodeInfo
)
...
...
@@ -188,7 +190,7 @@ func (nt *NodeTable) String() string {
// ---- subscription to nodetab updates ----
// 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 ?
for
_
,
notify
:=
range
nt
.
notifyv
{
notify
<-
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.
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
func
(
nt
*
NodeTable
)
Subscribe
()
(
ch
chan
NodeInfo
,
unsubscribe
func
())
{
ch
=
make
(
chan
NodeInfo
)
// XXX how to specify ch buf size if needed ?
func
(
nt
*
NodeTable
)
Subscribe
()
(
ch
chan
proto
.
NodeInfo
,
unsubscribe
func
())
{
ch
=
make
(
chan
proto
.
NodeInfo
)
// XXX how to specify ch buf size if needed ?
nt
.
notifyv
=
append
(
nt
.
notifyv
,
ch
)
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.
//
// 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
()
ch
=
make
(
chan
[]
NodeInfo
)
ch
=
make
(
chan
[]
proto
.
NodeInfo
)
go
func
()
{
var
updatev
[]
NodeInfo
var
updatev
[]
proto
.
NodeInfo
shutdown
:=
false
for
{
...
...
go/neo/parttab.go
View file @
47f069a5
...
...
@@ -25,6 +25,7 @@ import (
"fmt"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
// PartitionTable represents object space partitioning in a cluster
...
...
@@ -118,12 +119,12 @@ type PartitionTable struct {
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
type
Cell
struct
{
CellInfo
// .uuid + .state
proto
.
CellInfo
// .uuid + .state
// XXX ? + .haveUpToTid associated node has data up to such tid
// = uptodate if haveUpToTid == lastTid
...
...
@@ -149,7 +150,7 @@ func (pt *PartitionTable) Get(oid zodb.Oid) []Cell {
// Readable reports whether it is ok to read data from a cell
func
(
c
*
Cell
)
Readable
()
bool
{
switch
c
.
State
{
case
UP_TO_DATE
,
FEEDING
:
case
proto
.
UP_TO_DATE
,
proto
.
FEEDING
:
return
true
}
return
false
...
...
@@ -165,7 +166,7 @@ func MakePartTab(np int, nodev []*Node) *PartitionTable {
node
:=
nodev
[
j
]
// XXX assert node.State > DOWN
//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
}
...
...
@@ -203,7 +204,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
//
// We leave it as is for now.
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
}
...
...
@@ -245,20 +246,20 @@ func (pt *PartitionTable) String() string {
}
// XXX -> RowList() ?
func
(
pt
*
PartitionTable
)
Dump
()
[]
RowInfo
{
// XXX also include .ptid? -> struct ?
rowv
:=
make
([]
RowInfo
,
len
(
pt
.
tab
))
func
(
pt
*
PartitionTable
)
Dump
()
[]
proto
.
RowInfo
{
// XXX also include .ptid? -> struct ?
rowv
:=
make
([]
proto
.
RowInfo
,
len
(
pt
.
tab
))
for
i
,
row
:=
range
pt
.
tab
{
cellv
:=
make
([]
CellInfo
,
len
(
row
))
cellv
:=
make
([]
proto
.
CellInfo
,
len
(
row
))
for
j
,
cell
:=
range
row
{
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
}
func
PartTabFromDump
(
ptid
PTid
,
rowv
[]
RowInfo
)
*
PartitionTable
{
func
PartTabFromDump
(
ptid
proto
.
PTid
,
rowv
[]
proto
.
RowInfo
)
*
PartitionTable
{
// reconstruct partition table from response
pt
:=
&
PartitionTable
{}
pt
.
PTid
=
ptid
...
...
go/neo/parttab_test.go
View file @
47f069a5
...
...
@@ -21,19 +21,21 @@ package neo
import
(
"testing"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
func
TestPartTabOperational
(
t
*
testing
.
T
)
{
s1
:=
UUID
(
STORAGE
,
1
)
s2
:=
UUID
(
STORAGE
,
2
)
s1
:=
proto
.
UUID
(
proto
.
STORAGE
,
1
)
s2
:=
proto
.
UUID
(
proto
.
STORAGE
,
2
)
// create nodeinfo for uuid/state
n
:=
func
(
uuid
NodeUUID
,
state
NodeState
)
NodeInfo
{
return
NodeInfo
{
UUID
:
uuid
,
State
:
state
}
// XXX .Type?
n
:=
func
(
uuid
proto
.
NodeUUID
,
state
proto
.
NodeState
)
proto
.
NodeInfo
{
return
proto
.
NodeInfo
{
UUID
:
uuid
,
State
:
state
}
// XXX .Type?
}
// create nodetab with [](uuid, state)
N
:=
func
(
nodeiv
...
NodeInfo
)
*
NodeTable
{
N
:=
func
(
nodeiv
...
proto
.
NodeInfo
)
*
NodeTable
{
nt
:=
&
NodeTable
{}
for
_
,
nodei
:=
range
nodeiv
{
nt
.
Update
(
nodei
)
...
...
@@ -42,8 +44,8 @@ func TestPartTabOperational(t *testing.T) {
}
// create cell with uuid/state
C
:=
func
(
uuid
NodeUUID
,
state
CellState
)
Cell
{
return
Cell
{
CellInfo
{
UUID
:
uuid
,
State
:
state
}}
C
:=
func
(
uuid
proto
.
NodeUUID
,
state
proto
.
CellState
)
Cell
{
return
Cell
{
proto
.
CellInfo
{
UUID
:
uuid
,
State
:
state
}}
}
// shortcut to create []Cell
...
...
@@ -57,14 +59,14 @@ func TestPartTabOperational(t *testing.T) {
var
testv
=
[]
struct
{
pt
*
PartitionTable
;
nt
*
NodeTable
;
operational
bool
}{
// empty parttab is non-operational
{
P
(),
N
(),
false
},
{
P
(),
N
(
n
(
s1
,
RUNNING
)),
false
},
{
P
(),
N
(
n
(
s1
,
proto
.
RUNNING
)),
false
},
// parttab with 1 storage
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(),
false
},
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(
n
(
s2
,
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
OUT_OF_DATE
))),
N
(
n
(
s1
,
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
UP_TO_DATE
))),
N
(
n
(
s1
,
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
FEEDING
))),
N
(
n
(
s1
,
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(
n
(
s2
,
proto
.
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
OUT_OF_DATE
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
false
},
{
P
(
v
(
C
(
s1
,
proto
.
UP_TO_DATE
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
true
},
{
P
(
v
(
C
(
s1
,
proto
.
FEEDING
))),
N
(
n
(
s1
,
proto
.
RUNNING
)),
true
},
// TODO more tests
}
...
...
go/neo/pkt.go
View file @
47f069a5
...
...
@@ -27,26 +27,29 @@ import (
"unsafe"
"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).
//
// 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
{
Data
[]
byte
// whole packet data including all headers
}
// Header returns pointer to packet header.
func
(
pkt
*
PktBuf
)
Header
()
*
PktHeader
{
// XXX check len(Data) < PktHeader ? -> no, Data has to be allocated with cap >=
p
ktHeaderLen
return
(
*
PktHeader
)(
unsafe
.
Pointer
(
&
pkt
.
Data
[
0
]))
func
(
pkt
*
PktBuf
)
Header
()
*
proto
.
PktHeader
{
// XXX check len(Data) < PktHeader ? -> no, Data has to be allocated with cap >=
P
ktHeaderLen
return
(
*
proto
.
PktHeader
)(
unsafe
.
Pointer
(
&
pkt
.
Data
[
0
]))
}
// Payload returns []byte representing packet payload.
func
(
pkt
*
PktBuf
)
Payload
()
[]
byte
{
return
pkt
.
Data
[
pktHeaderLen
:
]
return
pkt
.
Data
[
p
roto
.
P
ktHeaderLen
:
]
}
// ---- PktBuf freelist ----
...
...
@@ -73,25 +76,25 @@ func (pkt *PktBuf) Free() {
// Strings dumps a packet in human-readable form
func
(
pkt
*
PktBuf
)
String
()
string
{
if
len
(
pkt
.
Data
)
<
pktHeaderLen
{
return
fmt
.
Sprintf
(
"(! <
p
ktHeaderLen) % x"
,
pkt
.
Data
)
if
len
(
pkt
.
Data
)
<
p
roto
.
P
ktHeaderLen
{
return
fmt
.
Sprintf
(
"(! <
P
ktHeaderLen) % x"
,
pkt
.
Data
)
}
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
)
msgLen
:=
n
toh32
(
h
.
MsgLen
)
msgCode
:=
packed
.
N
toh16
(
h
.
MsgCode
)
msgLen
:=
packed
.
N
toh32
(
h
.
MsgLen
)
data
:=
pkt
.
Payload
()
msgType
:=
msgTypeRegistry
[
msgCode
]
msgType
:=
proto
.
MsgType
(
msgCode
)
if
msgType
==
nil
{
s
+=
fmt
.
Sprintf
(
" ? (%d) #%d [%d]: % x"
,
msgCode
,
msgLen
,
len
(
data
),
data
)
return
s
}
// XXX dup wrt Conn.Recv
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
Msg
)
n
,
err
:=
msg
.
neo
MsgDecode
(
data
)
msg
:=
reflect
.
New
(
msgType
)
.
Interface
()
.
(
proto
.
Msg
)
n
,
err
:=
msg
.
NEO
MsgDecode
(
data
)
if
err
!=
nil
{
s
+=
fmt
.
Sprintf
(
" (%s) %v; #%d [%d]: % x"
,
msgType
,
err
,
msgLen
,
len
(
data
),
data
)
}
...
...
@@ -108,12 +111,12 @@ func (pkt *PktBuf) String() string {
// Dump dumps a packet in raw form
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
)
}
h
:=
pkt
.
Header
()
data
:=
pkt
.
Payload
()
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 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
package
prot
o
// error related utilities
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.
// 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 @@
// See COPYING file for full licensing terms.
// 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
import
(
"fmt"
"math"
"net"
"reflect"
"strconv"
"strings"
"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 here - not in proto.go - because else stringer will be confused
func
(
e
*
Error
)
Error
()
string
{
...
...
@@ -44,6 +53,8 @@ func (e *Error) Error() string {
// Set sets cluster state value to v.
// 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
)
{
*
cs
=
v
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
// it under the terms of the GNU General Public License version 3, or (at your
...
...
@@ -16,8 +16,24 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
neo
// protocol definition
// Package proto provides definition of NEO messages and their marshalling
// 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.
// In particular every type that is included in a message is defined here as well.
...
...
@@ -39,6 +55,7 @@ package neo
// The code to marshal/unmarshal messages is generated by protogen.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
...
...
@@ -53,6 +70,8 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/xcommon/packed"
"encoding/binary"
"errors"
"math"
...
...
@@ -62,17 +81,24 @@ const (
// 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
// the high order byte 0 is different from TLS Handshake (0x16).
Protocol
Version
=
1
Version
=
1
// 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
.
//
in particular this avoids
out-of-memory error on packets with corrupt message len.
p
ktMaxSize
=
0x4000000
//
packets larger than PktMaxSize are not allowed
.
//
this helps to avoid
out-of-memory error on packets with corrupt message len.
P
ktMaxSize
=
0x4000000
// answerBit is set in message code in answer messages for compatibility with neo/py
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.
...
...
@@ -81,29 +107,29 @@ const (
//
//neo:proto typeonly
type
PktHeader
struct
{
ConnId
be
32
// NOTE is .msgid in py
MsgCode
be
16
// payload message code
MsgLen
be
32
// payload message length (excluding packet header)
ConnId
packed
.
BE
32
// NOTE is .msgid in py
MsgCode
packed
.
BE
16
// payload message code
MsgLen
packed
.
BE
32
// payload message length (excluding packet header)
}
// Msg is the interface implemented by all NEO messages.
type
Msg
interface
{
// 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.
neo
MsgCode
()
uint16
NEO
MsgCode
()
uint16
//
neo
MsgEncodedLen returns how much space is needed to encode current message payload.
neo
MsgEncodedLen
()
int
//
NEO
MsgEncodedLen returns how much space is needed to encode current message payload.
NEO
MsgEncodedLen
()
int
//
neo
MsgEncode encodes current message state into buf.
//
NEO
MsgEncode encodes current message state into buf.
//
// len(buf) must be >= neoMsgEncodedLen().
neo
MsgEncode
(
buf
[]
byte
)
NEO
MsgEncode
(
buf
[]
byte
)
//
neo
MsgDecode decodes data into message in-place.
neo
MsgDecode
(
data
[]
byte
)
(
nread
int
,
err
error
)
//
NEO
MsgDecode decodes data into message in-place.
NEO
MsgDecode
(
data
[]
byte
)
(
nread
int
,
err
error
)
}
// ErrDecodeOverflow is the error returned by neoMsgDecode when decoding hits buffer overflow
...
...
@@ -127,6 +153,7 @@ const (
INCOMPLETE_TRANSACTION
)
// XXX move this to neo.clusterState wrapping proto.ClusterState?
//trace:event traceClusterStateChanged(cs *ClusterState)
type
ClusterState
int32
...
...
@@ -584,7 +611,7 @@ type AnswerRebaseObject struct {
// FIXME POption('data')
Compression
bool
Checksum
Checksum
Data
[]
byte
// XXX was string
Data
*
mem
.
Buf
}
...
...
@@ -596,7 +623,7 @@ type StoreObject struct {
Serial
zodb
.
Tid
Compression
bool
Checksum
Checksum
Data
[]
byte
// TODO encode ->
separately (for writev)
Data
[]
byte
// TODO -> msg.Buf,
separately (for writev)
DataSerial
zodb
.
Tid
Tid
zodb
.
Tid
}
...
...
@@ -1036,7 +1063,7 @@ type AddObject struct {
Serial
zodb
.
Tid
Compression
bool
Checksum
Checksum
Data
[]
byte
// TODO from pool, separately (?)
Data
*
mem
.
Buf
DataSerial
zodb
.
Tid
}
...
...
go/neo/proto_test.go
→
go/neo/proto
/proto
_test.go
View file @
47f069a5
...
...
@@ -17,8 +17,8 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
//
protocol
tests
package
prot
o
//
NEO. protocol encoding
tests
import
(
hexpkg
"encoding/hex"
...
...
@@ -64,12 +64,12 @@ func u64(v uint64) string {
}
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
{
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want 10"
,
unsafe
.
Sizeof
(
PktHeader
{}))
}
if
unsafe
.
Sizeof
(
PktHeader
{})
!=
p
ktHeaderLen
{
t
.
Fatalf
(
"sizeof(PktHeader) = %v ; want %v"
,
unsafe
.
Sizeof
(
PktHeader
{}),
p
ktHeaderLen
)
if
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) {
}()
// msg.encode() == expected
msgCode
:=
msg
.
neo
MsgCode
()
n
:=
msg
.
neo
MsgEncodedLen
()
msgType
:=
msgTypeRegistry
[
msgCode
]
msgCode
:=
msg
.
NEO
MsgCode
()
n
:=
msg
.
NEO
MsgEncodedLen
()
msgType
:=
MsgType
(
msgCode
)
if
msgType
!=
typ
{
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) {
}
buf
:=
make
([]
byte
,
n
)
msg
.
neo
MsgEncode
(
buf
)
msg
.
NEO
MsgEncode
(
buf
)
if
string
(
buf
)
!=
encoded
{
t
.
Errorf
(
"%v: encode result unexpected:"
,
typ
)
t
.
Errorf
(
"
\t
have: %s"
,
hexpkg
.
EncodeToString
(
buf
))
...
...
@@ -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
data
:=
[]
byte
(
encoded
+
"noise"
)
n
,
err
:=
msg2
.
neo
MsgDecode
(
data
)
n
,
err
:=
msg2
.
NEO
MsgDecode
(
data
)
if
err
!=
nil
{
t
.
Errorf
(
"%v: decode error %v"
,
typ
,
err
)
}
...
...
@@ -146,7 +146,7 @@ func testMsgMarshal(t *testing.T, msg Msg, encoded string) {
// decode must detect buffer overflow
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
)
{
t
.
Errorf
(
"%v: decode overflow not detected on [:%v]"
,
typ
,
l
)
}
...
...
@@ -281,11 +281,11 @@ func TestMsgMarshalAllOverflowLightly(t *testing.T) {
for
_
,
typ
:=
range
msgTypeRegistry
{
// zero-value for a type
msg
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
Msg
)
l
:=
msg
.
neo
MsgEncodedLen
()
l
:=
msg
.
NEO
MsgEncodedLen
()
zerol
:=
make
([]
byte
,
l
)
// decoding will turn nil slice & map into empty allocated ones.
// 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
)
{
t
.
Errorf
(
"%v: zero-decode unexpected: %v, %v ; want %v, nil"
,
typ
,
n
,
err
,
l
)
}
...
...
@@ -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
)
{
t
.
Errorf
(
"%T: decode %x
\n
have: %d, %v
\n
want: %d, %v"
,
tt
.
msg
,
data
,
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 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
ne
o
// test wire protocol compatibility with python
package
prot
o
//
NEO.
test wire protocol compatibility with python
//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>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -25,10 +25,10 @@ NEO. Protocol module. Code generator
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:
neo
MsgCode() uint16
neo
MsgEncodedLen() int
neo
MsgEncode(buf []byte)
neo
MsgDecode(data []byte) (nread int, err error)
NEO
MsgCode() uint16
NEO
MsgEncodedLen() int
NEO
MsgEncode(buf []byte)
NEO
MsgDecode(data []byte) (nread int, err error)
List of message types is obtained via searching through proto.go AST - looking
for appropriate struct declarations there.
...
...
@@ -94,12 +94,12 @@ func pos(x interface { Pos() token.Pos }) token.Position {
}
// get type name in context of neo package
var
zodbPkg
*
types
.
Package
var
neoPkg
*
types
.
Package
var
zodbPkg
*
types
.
Package
var
protoPkg
*
types
.
Package
func
typeName
(
typ
types
.
Type
)
string
{
qf
:=
func
(
pkg
*
types
.
Package
)
string
{
switch
pkg
{
case
ne
oPkg
:
case
prot
oPkg
:
// same package - unqualified
return
""
...
...
@@ -247,11 +247,11 @@ func main() {
log
.
SetFlags
(
0
)
// go through proto.go and AST'ify & typecheck it
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"
)
zodbPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/zodb"
,
"../
../zodb/zodb.go"
)
protoPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/neo/proto"
,
"proto
.go"
)
// extract neo.customCodec
cc
:=
ne
oPkg
.
Scope
()
.
Lookup
(
"customCodec"
)
cc
:=
prot
oPkg
.
Scope
()
.
Lookup
(
"customCodec"
)
if
cc
==
nil
{
log
.
Fatal
(
"cannot find `customCodec`"
)
}
...
...
@@ -285,8 +285,8 @@ func main() {
buf
:=
Buffer
{}
buf
.
emit
(
`// Code generated by protogen.go; DO NOT EDIT.
package
ne
o
// protocol messages to/from wire marshalling.
package
prot
o
//
NEO.
protocol messages to/from wire marshalling.
import (
"encoding/binary"
...
...
@@ -350,7 +350,7 @@ import (
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
(
"}
\n
"
)
...
...
@@ -629,7 +629,7 @@ type sizer struct {
//
// 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
// 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 code emitted looks like:
...
...
@@ -638,7 +638,7 @@ type sizer struct {
// 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)
type
encoder
struct
{
commonCodeGen
...
...
@@ -686,7 +686,7 @@ var _ CodeGenerator = (*decoder)(nil)
func
(
s
*
sizer
)
generatedCode
()
string
{
code
:=
Buffer
{}
// 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"
]
{
code
.
emit
(
"var %s int"
,
s
.
var_
(
"size"
))
}
...
...
@@ -707,7 +707,7 @@ func (s *sizer) generatedCode() string {
func
(
e
*
encoder
)
generatedCode
()
string
{
code
:=
Buffer
{}
// 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
())
...
...
@@ -819,7 +819,7 @@ func (d *decoder) generatedCode() string {
code
:=
Buffer
{}
// 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"
]
{
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'
def
main
():
pyprotog
=
{}
execfile
(
'../../neo/lib/protocol.py'
,
pyprotog
)
execfile
(
'../../
../
neo/lib/protocol.py'
,
pyprotog
)
pypacket
=
pyprotog
[
'Packet'
]
pypackets
=
pyprotog
[
'Packets'
]
...
...
@@ -74,7 +74,7 @@ def main():
def
emit
(
v
):
print
>>
f
,
v
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"package
ne
o"
)
emit
(
"package
prot
o"
)
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.
package
ne
o
package
prot
o
// protocol messages to/from wire marshalling.
//
NEO.
protocol messages to/from wire marshalling.
import
(
"encoding/binary"
...
...
@@ -17,15 +17,15 @@ import (
// 0 | answerBit. Error
func
(
*
Error
)
neo
MsgCode
()
uint16
{
func
(
*
Error
)
NEO
MsgCode
()
uint16
{
return
0
|
answerBit
}
func
(
p
*
Error
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Error
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
Message
))
...
...
@@ -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
if
len
(
data
)
<
8
{
goto
overflow
...
...
@@ -60,15 +60,15 @@ overflow:
// 1. RequestIdentification
func
(
*
RequestIdentification
)
neo
MsgCode
()
uint16
{
func
(
*
RequestIdentification
)
NEO
MsgCode
()
uint16
{
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
()
}
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
[
4
:
],
uint32
(
int32
(
p
.
UUID
)))
{
...
...
@@ -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
if
len
(
data
)
<
8
{
goto
overflow
...
...
@@ -133,15 +133,15 @@ overflow:
// 1 | answerBit. AcceptIdentification
func
(
*
AcceptIdentification
)
neo
MsgCode
()
uint16
{
func
(
*
AcceptIdentification
)
NEO
MsgCode
()
uint16
{
return
1
|
answerBit
}
func
(
p
*
AcceptIdentification
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AcceptIdentification
)
NEO
MsgEncodedLen
()
int
{
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
[
4
:
],
uint32
(
int32
(
p
.
MyUUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
p
.
NumPartitions
)
...
...
@@ -149,7 +149,7 @@ func (p *AcceptIdentification) neoMsgEncode(data []byte) {
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
{
goto
overflow
}
...
...
@@ -166,87 +166,87 @@ overflow:
// 3. Ping
func
(
*
Ping
)
neo
MsgCode
()
uint16
{
func
(
*
Ping
)
NEO
MsgCode
()
uint16
{
return
3
}
func
(
p
*
Ping
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Ping
)
NEO
MsgEncodedLen
()
int
{
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
}
// 3 | answerBit. Pong
func
(
*
Pong
)
neo
MsgCode
()
uint16
{
func
(
*
Pong
)
NEO
MsgCode
()
uint16
{
return
3
|
answerBit
}
func
(
p
*
Pong
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Pong
)
NEO
MsgEncodedLen
()
int
{
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
}
// 5. CloseClient
func
(
*
CloseClient
)
neo
MsgCode
()
uint16
{
func
(
*
CloseClient
)
NEO
MsgCode
()
uint16
{
return
5
}
func
(
p
*
CloseClient
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CloseClient
)
NEO
MsgEncodedLen
()
int
{
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
}
// 6. PrimaryMaster
func
(
*
PrimaryMaster
)
neo
MsgCode
()
uint16
{
func
(
*
PrimaryMaster
)
NEO
MsgCode
()
uint16
{
return
6
}
func
(
p
*
PrimaryMaster
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PrimaryMaster
)
NEO
MsgEncodedLen
()
int
{
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
}
// 6 | answerBit. AnswerPrimary
func
(
*
AnswerPrimary
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPrimary
)
NEO
MsgCode
()
uint16
{
return
6
|
answerBit
}
func
(
p
*
AnswerPrimary
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPrimary
)
NEO
MsgEncodedLen
()
int
{
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
)))
}
func
(
p
*
AnswerPrimary
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerPrimary
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
goto
overflow
}
...
...
@@ -259,11 +259,11 @@ overflow:
// 8. NotPrimaryMaster
func
(
*
NotPrimaryMaster
)
neo
MsgCode
()
uint16
{
func
(
*
NotPrimaryMaster
)
NEO
MsgCode
()
uint16
{
return
8
}
func
(
p
*
NotPrimaryMaster
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotPrimaryMaster
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
a
:=
&
p
.
KnownMasterList
[
i
]
...
...
@@ -272,7 +272,7 @@ func (p *NotPrimaryMaster) neoMsgEncodedLen() int {
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
)))
{
l
:=
uint32
(
len
(
p
.
KnownMasterList
))
...
...
@@ -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
if
len
(
data
)
<
8
{
goto
overflow
...
...
@@ -319,11 +319,11 @@ overflow:
// 9. NotifyNodeInformation
func
(
*
NotifyNodeInformation
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyNodeInformation
)
NEO
MsgCode
()
uint16
{
return
9
}
func
(
p
*
NotifyNodeInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyNodeInformation
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
...
...
@@ -332,7 +332,7 @@ func (p *NotifyNodeInformation) neoMsgEncodedLen() int {
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
:
])
data
=
data
[
0
+
n
:
]
...
...
@@ -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
{
n
,
ok
:=
p
.
IdTime
.
neoDecode
(
data
)
...
...
@@ -416,38 +416,38 @@ overflow:
// 10. Recovery
func
(
*
Recovery
)
neo
MsgCode
()
uint16
{
func
(
*
Recovery
)
NEO
MsgCode
()
uint16
{
return
10
}
func
(
p
*
Recovery
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Recovery
)
NEO
MsgEncodedLen
()
int
{
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
}
// 10 | answerBit. AnswerRecovery
func
(
*
AnswerRecovery
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRecovery
)
NEO
MsgCode
()
uint16
{
return
10
|
answerBit
}
func
(
p
*
AnswerRecovery
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerRecovery
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
BackupTid
))
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
{
goto
overflow
}
...
...
@@ -462,37 +462,37 @@ overflow:
// 12. LastIDs
func
(
*
LastIDs
)
neo
MsgCode
()
uint16
{
func
(
*
LastIDs
)
NEO
MsgCode
()
uint16
{
return
12
}
func
(
p
*
LastIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LastIDs
)
NEO
MsgEncodedLen
()
int
{
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
}
// 12 | answerBit. AnswerLastIDs
func
(
*
AnswerLastIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLastIDs
)
NEO
MsgCode
()
uint16
{
return
12
|
answerBit
}
func
(
p
*
AnswerLastIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLastIDs
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -506,28 +506,28 @@ overflow:
// 14. AskPartitionTable
func
(
*
AskPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
AskPartitionTable
)
NEO
MsgCode
()
uint16
{
return
14
}
func
(
p
*
AskPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskPartitionTable
)
NEO
MsgEncodedLen
()
int
{
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
}
// 14 | answerBit. AnswerPartitionTable
func
(
*
AnswerPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPartitionTable
)
NEO
MsgCode
()
uint16
{
return
14
|
answerBit
}
func
(
p
*
AnswerPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPartitionTable
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
...
...
@@ -536,7 +536,7 @@ func (p *AnswerPartitionTable) neoMsgEncodedLen() int {
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
))
{
l
:=
uint32
(
len
(
p
.
RowList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -603,11 +603,11 @@ overflow:
// 16. SendPartitionTable
func
(
*
SendPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
SendPartitionTable
)
NEO
MsgCode
()
uint16
{
return
16
}
func
(
p
*
SendPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SendPartitionTable
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
...
...
@@ -616,7 +616,7 @@ func (p *SendPartitionTable) neoMsgEncodedLen() int {
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
))
{
l
:=
uint32
(
len
(
p
.
RowList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -683,15 +683,15 @@ overflow:
// 17. NotifyPartitionChanges
func
(
*
NotifyPartitionChanges
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyPartitionChanges
)
NEO
MsgCode
()
uint16
{
return
17
}
func
(
p
*
NotifyPartitionChanges
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyPartitionChanges
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
CellList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -740,19 +740,19 @@ overflow:
// 18. StartOperation
func
(
*
StartOperation
)
neo
MsgCode
()
uint16
{
func
(
*
StartOperation
)
NEO
MsgCode
()
uint16
{
return
18
}
func
(
p
*
StartOperation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StartOperation
)
NEO
MsgEncodedLen
()
int
{
return
1
}
func
(
p
*
StartOperation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StartOperation
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
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
{
goto
overflow
}
...
...
@@ -765,32 +765,32 @@ overflow:
// 19. StopOperation
func
(
*
StopOperation
)
neo
MsgCode
()
uint16
{
func
(
*
StopOperation
)
NEO
MsgCode
()
uint16
{
return
19
}
func
(
p
*
StopOperation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StopOperation
)
NEO
MsgEncodedLen
()
int
{
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
}
// 20. UnfinishedTransactions
func
(
*
UnfinishedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
UnfinishedTransactions
)
NEO
MsgCode
()
uint16
{
return
20
}
func
(
p
*
UnfinishedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
UnfinishedTransactions
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -830,15 +830,15 @@ overflow:
// 20 | answerBit. AnswerUnfinishedTransactions
func
(
*
AnswerUnfinishedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerUnfinishedTransactions
)
NEO
MsgCode
()
uint16
{
return
20
|
answerBit
}
func
(
p
*
AnswerUnfinishedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerUnfinishedTransactions
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
TidList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -880,32 +880,32 @@ overflow:
// 22. LockedTransactions
func
(
*
LockedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
LockedTransactions
)
NEO
MsgCode
()
uint16
{
return
22
}
func
(
p
*
LockedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LockedTransactions
)
NEO
MsgEncodedLen
()
int
{
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
}
// 22 | answerBit. AnswerLockedTransactions
func
(
*
AnswerLockedTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLockedTransactions
)
NEO
MsgCode
()
uint16
{
return
22
|
answerBit
}
func
(
p
*
AnswerLockedTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLockedTransactions
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -951,19 +951,19 @@ overflow:
// 24. FinalTID
func
(
*
FinalTID
)
neo
MsgCode
()
uint16
{
func
(
*
FinalTID
)
NEO
MsgCode
()
uint16
{
return
24
}
func
(
p
*
FinalTID
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FinalTID
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
FinalTID
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
FinalTID
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -976,19 +976,19 @@ overflow:
// 24 | answerBit. AnswerFinalTID
func
(
*
AnswerFinalTID
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFinalTID
)
NEO
MsgCode
()
uint16
{
return
24
|
answerBit
}
func
(
p
*
AnswerFinalTID
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFinalTID
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
AnswerFinalTID
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerFinalTID
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1001,20 +1001,20 @@ overflow:
// 26. ValidateTransaction
func
(
*
ValidateTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
ValidateTransaction
)
NEO
MsgCode
()
uint16
{
return
26
}
func
(
p
*
ValidateTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ValidateTransaction
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1028,19 +1028,19 @@ overflow:
// 27. BeginTransaction
func
(
*
BeginTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
BeginTransaction
)
NEO
MsgCode
()
uint16
{
return
27
}
func
(
p
*
BeginTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
BeginTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
BeginTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
BeginTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1053,19 +1053,19 @@ overflow:
// 27 | answerBit. AnswerBeginTransaction
func
(
*
AnswerBeginTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerBeginTransaction
)
NEO
MsgCode
()
uint16
{
return
27
|
answerBit
}
func
(
p
*
AnswerBeginTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerBeginTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
AnswerBeginTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerBeginTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1078,15 +1078,15 @@ overflow:
// 29. FailedVote
func
(
*
FailedVote
)
neo
MsgCode
()
uint16
{
func
(
*
FailedVote
)
NEO
MsgCode
()
uint16
{
return
29
}
func
(
p
*
FailedVote
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FailedVote
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
NodeList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -1128,15 +1128,15 @@ overflow:
// 30. FinishTransaction
func
(
*
FinishTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
FinishTransaction
)
NEO
MsgCode
()
uint16
{
return
30
}
func
(
p
*
FinishTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FinishTransaction
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
OIDList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -1202,20 +1202,20 @@ overflow:
// 30 | answerBit. AnswerTransactionFinished
func
(
*
AnswerTransactionFinished
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTransactionFinished
)
NEO
MsgCode
()
uint16
{
return
30
|
answerBit
}
func
(
p
*
AnswerTransactionFinished
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTransactionFinished
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1229,20 +1229,20 @@ overflow:
// 32. LockInformation
func
(
*
LockInformation
)
neo
MsgCode
()
uint16
{
func
(
*
LockInformation
)
NEO
MsgCode
()
uint16
{
return
32
}
func
(
p
*
LockInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LockInformation
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1256,19 +1256,19 @@ overflow:
// 32 | answerBit. AnswerInformationLocked
func
(
*
AnswerInformationLocked
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerInformationLocked
)
NEO
MsgCode
()
uint16
{
return
32
|
answerBit
}
func
(
p
*
AnswerInformationLocked
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerInformationLocked
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
AnswerInformationLocked
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerInformationLocked
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1281,15 +1281,15 @@ overflow:
// 34. InvalidateObjects
func
(
*
InvalidateObjects
)
neo
MsgCode
()
uint16
{
func
(
*
InvalidateObjects
)
NEO
MsgCode
()
uint16
{
return
34
}
func
(
p
*
InvalidateObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
InvalidateObjects
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
OidList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -1331,19 +1331,19 @@ overflow:
// 35. NotifyUnlockInformation
func
(
*
NotifyUnlockInformation
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyUnlockInformation
)
NEO
MsgCode
()
uint16
{
return
35
}
func
(
p
*
NotifyUnlockInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyUnlockInformation
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
NotifyUnlockInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
NotifyUnlockInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1356,19 +1356,19 @@ overflow:
// 36. AskNewOIDs
func
(
*
AskNewOIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AskNewOIDs
)
NEO
MsgCode
()
uint16
{
return
36
}
func
(
p
*
AskNewOIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskNewOIDs
)
NEO
MsgEncodedLen
()
int
{
return
4
}
func
(
p
*
AskNewOIDs
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AskNewOIDs
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1381,15 +1381,15 @@ overflow:
// 36 | answerBit. AnswerNewOIDs
func
(
*
AnswerNewOIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerNewOIDs
)
NEO
MsgCode
()
uint16
{
return
36
|
answerBit
}
func
(
p
*
AnswerNewOIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerNewOIDs
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -1429,20 +1429,20 @@ overflow:
// 38. NotifyDeadlock
func
(
*
NotifyDeadlock
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyDeadlock
)
NEO
MsgCode
()
uint16
{
return
38
}
func
(
p
*
NotifyDeadlock
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyDeadlock
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1456,20 +1456,20 @@ overflow:
// 39. RebaseTransaction
func
(
*
RebaseTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
RebaseTransaction
)
NEO
MsgCode
()
uint16
{
return
39
}
func
(
p
*
RebaseTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RebaseTransaction
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1483,15 +1483,15 @@ overflow:
// 39 | answerBit. AnswerRebaseTransaction
func
(
*
AnswerRebaseTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRebaseTransaction
)
NEO
MsgCode
()
uint16
{
return
39
|
answerBit
}
func
(
p
*
AnswerRebaseTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerRebaseTransaction
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -1531,20 +1531,20 @@ overflow:
// 41. RebaseObject
func
(
*
RebaseObject
)
neo
MsgCode
()
uint16
{
func
(
*
RebaseObject
)
NEO
MsgCode
()
uint16
{
return
41
}
func
(
p
*
RebaseObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RebaseObject
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -1558,29 +1558,29 @@ overflow:
// 41 | answerBit. AnswerRebaseObject
func
(
*
AnswerRebaseObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerRebaseObject
)
NEO
MsgCode
()
uint16
{
return
41
|
answerBit
}
func
(
p
*
AnswerRebaseObject
)
neo
MsgEncodedLen
()
int
{
return
41
+
len
(
p
.
Data
)
func
(
p
*
AnswerRebaseObject
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
ConflictSerial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
{
l
:=
uint32
(
len
(
p
.
Data
))
l
:=
uint32
(
len
(
p
.
Data
.
XData
()
))
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
data
=
data
[
41
:
]
copy
(
data
,
p
.
Data
)
copy
(
data
,
p
.
Data
.
XData
()
)
data
=
data
[
l
:
]
}
}
func
(
p
*
AnswerRebaseObject
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerRebaseObject
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread
uint64
if
len
(
data
)
<
41
{
goto
overflow
...
...
@@ -1596,8 +1596,8 @@ func (p *AnswerRebaseObject) neoMsgDecode(data []byte) (int, error) {
goto
overflow
}
nread
+=
uint64
(
l
)
p
.
Data
=
m
ake
([]
byte
,
l
)
copy
(
p
.
Data
,
data
[
:
l
])
p
.
Data
=
m
em
.
BufAlloc
(
int
(
l
)
)
copy
(
p
.
Data
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
}
return
41
+
int
(
nread
),
nil
...
...
@@ -1608,15 +1608,15 @@ overflow:
// 43. StoreObject
func
(
*
StoreObject
)
neo
MsgCode
()
uint16
{
func
(
*
StoreObject
)
NEO
MsgCode
()
uint16
{
return
43
}
func
(
p
*
StoreObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
StoreObject
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
Serial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
...
...
@@ -1632,7 +1632,7 @@ func (p *StoreObject) neoMsgEncode(data []byte) {
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
if
len
(
data
)
<
41
{
goto
overflow
...
...
@@ -1662,19 +1662,19 @@ overflow:
// 43 | answerBit. AnswerStoreObject
func
(
*
AnswerStoreObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerStoreObject
)
NEO
MsgCode
()
uint16
{
return
43
|
answerBit
}
func
(
p
*
AnswerStoreObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerStoreObject
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
AnswerStoreObject
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerStoreObject
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1687,15 +1687,15 @@ overflow:
// 45. AbortTransaction
func
(
*
AbortTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AbortTransaction
)
NEO
MsgCode
()
uint16
{
return
45
}
func
(
p
*
AbortTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AbortTransaction
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
NodeList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -1737,15 +1737,15 @@ overflow:
// 46. StoreTransaction
func
(
*
StoreTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
StoreTransaction
)
NEO
MsgCode
()
uint16
{
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
}
func
(
p
*
StoreTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
StoreTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
l
:=
uint32
(
len
(
p
.
User
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -1838,36 +1838,36 @@ overflow:
// 46 | answerBit. AnswerStoreTransaction
func
(
*
AnswerStoreTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerStoreTransaction
)
NEO
MsgCode
()
uint16
{
return
46
|
answerBit
}
func
(
p
*
AnswerStoreTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerStoreTransaction
)
NEO
MsgEncodedLen
()
int
{
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
}
// 48. VoteTransaction
func
(
*
VoteTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
VoteTransaction
)
NEO
MsgCode
()
uint16
{
return
48
}
func
(
p
*
VoteTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
VoteTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
VoteTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
VoteTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -1880,38 +1880,38 @@ overflow:
// 48 | answerBit. AnswerVoteTransaction
func
(
*
AnswerVoteTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerVoteTransaction
)
NEO
MsgCode
()
uint16
{
return
48
|
answerBit
}
func
(
p
*
AnswerVoteTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerVoteTransaction
)
NEO
MsgEncodedLen
()
int
{
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
}
// 50. GetObject
func
(
*
GetObject
)
neo
MsgCode
()
uint16
{
func
(
*
GetObject
)
NEO
MsgCode
()
uint16
{
return
50
}
func
(
p
*
GetObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
GetObject
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
Serial
))
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
{
goto
overflow
}
...
...
@@ -1926,15 +1926,15 @@ overflow:
// 50 | answerBit. AnswerObject
func
(
*
AnswerObject
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObject
)
NEO
MsgCode
()
uint16
{
return
50
|
answerBit
}
func
(
p
*
AnswerObject
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObject
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextSerial
))
...
...
@@ -1950,7 +1950,7 @@ func (p *AnswerObject) neoMsgEncode(data []byte) {
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
if
len
(
data
)
<
49
{
goto
overflow
...
...
@@ -1980,21 +1980,21 @@ overflow:
// 52. AskTIDs
func
(
*
AskTIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AskTIDs
)
NEO
MsgCode
()
uint16
{
return
52
}
func
(
p
*
AskTIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskTIDs
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
p
.
Last
)
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
{
goto
overflow
}
...
...
@@ -2009,15 +2009,15 @@ overflow:
// 52 | answerBit. AnswerTIDs
func
(
*
AnswerTIDs
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTIDs
)
NEO
MsgCode
()
uint16
{
return
52
|
answerBit
}
func
(
p
*
AnswerTIDs
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTIDs
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2057,19 +2057,19 @@ overflow:
// 54. TransactionInformation
func
(
*
TransactionInformation
)
neo
MsgCode
()
uint16
{
func
(
*
TransactionInformation
)
NEO
MsgCode
()
uint16
{
return
54
}
func
(
p
*
TransactionInformation
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
TransactionInformation
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
TransactionInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
TransactionInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -2082,15 +2082,15 @@ overflow:
// 54 | answerBit. AnswerTransactionInformation
func
(
*
AnswerTransactionInformation
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTransactionInformation
)
NEO
MsgCode
()
uint16
{
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
}
func
(
p
*
AnswerTransactionInformation
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerTransactionInformation
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
l
:=
uint32
(
len
(
p
.
User
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -2185,21 +2185,21 @@ overflow:
// 56. ObjectHistory
func
(
*
ObjectHistory
)
neo
MsgCode
()
uint16
{
func
(
*
ObjectHistory
)
NEO
MsgCode
()
uint16
{
return
56
}
func
(
p
*
ObjectHistory
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ObjectHistory
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
p
.
First
)
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
{
goto
overflow
}
...
...
@@ -2214,15 +2214,15 @@ overflow:
// 56 | answerBit. AnswerObjectHistory
func
(
*
AnswerObjectHistory
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObjectHistory
)
NEO
MsgCode
()
uint16
{
return
56
|
answerBit
}
func
(
p
*
AnswerObjectHistory
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObjectHistory
)
NEO
MsgEncodedLen
()
int
{
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
))
{
l
:=
uint32
(
len
(
p
.
HistoryList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -2269,21 +2269,21 @@ overflow:
// 58. PartitionList
func
(
*
PartitionList
)
neo
MsgCode
()
uint16
{
func
(
*
PartitionList
)
NEO
MsgCode
()
uint16
{
return
58
}
func
(
p
*
PartitionList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PartitionList
)
NEO
MsgEncodedLen
()
int
{
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
[
4
:
],
p
.
MaxOffset
)
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
{
goto
overflow
}
...
...
@@ -2298,11 +2298,11 @@ overflow:
// 58 | answerBit. AnswerPartitionList
func
(
*
AnswerPartitionList
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPartitionList
)
NEO
MsgCode
()
uint16
{
return
58
|
answerBit
}
func
(
p
*
AnswerPartitionList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPartitionList
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
...
...
@@ -2311,7 +2311,7 @@ func (p *AnswerPartitionList) neoMsgEncodedLen() int {
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
))
{
l
:=
uint32
(
len
(
p
.
RowList
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -2378,19 +2378,19 @@ overflow:
// 60. NodeList
func
(
*
NodeList
)
neo
MsgCode
()
uint16
{
func
(
*
NodeList
)
NEO
MsgCode
()
uint16
{
return
60
}
func
(
p
*
NodeList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NodeList
)
NEO
MsgEncodedLen
()
int
{
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
)))
}
func
(
p
*
NodeList
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NodeList
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
goto
overflow
}
...
...
@@ -2403,11 +2403,11 @@ overflow:
// 60 | answerBit. AnswerNodeList
func
(
*
AnswerNodeList
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerNodeList
)
NEO
MsgCode
()
uint16
{
return
60
|
answerBit
}
func
(
p
*
AnswerNodeList
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerNodeList
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
...
...
@@ -2416,7 +2416,7 @@ func (p *AnswerNodeList) neoMsgEncodedLen() int {
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2488,20 +2488,20 @@ overflow:
// 62. SetNodeState
func
(
*
SetNodeState
)
neo
MsgCode
()
uint16
{
func
(
*
SetNodeState
)
NEO
MsgCode
()
uint16
{
return
62
}
func
(
p
*
SetNodeState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SetNodeState
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -2515,15 +2515,15 @@ overflow:
// 63. AddPendingNodes
func
(
*
AddPendingNodes
)
neo
MsgCode
()
uint16
{
func
(
*
AddPendingNodes
)
NEO
MsgCode
()
uint16
{
return
63
}
func
(
p
*
AddPendingNodes
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AddPendingNodes
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2563,15 +2563,15 @@ overflow:
// 64. TweakPartitionTable
func
(
*
TweakPartitionTable
)
neo
MsgCode
()
uint16
{
func
(
*
TweakPartitionTable
)
NEO
MsgCode
()
uint16
{
return
64
}
func
(
p
*
TweakPartitionTable
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
TweakPartitionTable
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2611,19 +2611,19 @@ overflow:
// 65. SetClusterState
func
(
*
SetClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
SetClusterState
)
NEO
MsgCode
()
uint16
{
return
65
}
func
(
p
*
SetClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
SetClusterState
)
NEO
MsgEncodedLen
()
int
{
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
)))
}
func
(
p
*
SetClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
SetClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
goto
overflow
}
...
...
@@ -2636,15 +2636,15 @@ overflow:
// 66. Repair
func
(
*
Repair
)
neo
MsgCode
()
uint16
{
func
(
*
Repair
)
NEO
MsgCode
()
uint16
{
return
66
}
func
(
p
*
Repair
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Repair
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -2658,7 +2658,7 @@ func (p *Repair) neoMsgEncode(data []byte) {
(
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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2686,19 +2686,19 @@ overflow:
// 67. RepairOne
func
(
*
RepairOne
)
neo
MsgCode
()
uint16
{
func
(
*
RepairOne
)
NEO
MsgCode
()
uint16
{
return
67
}
func
(
p
*
RepairOne
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
RepairOne
)
NEO
MsgEncodedLen
()
int
{
return
1
}
func
(
p
*
RepairOne
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
RepairOne
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
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
{
goto
overflow
}
...
...
@@ -2711,19 +2711,19 @@ overflow:
// 68. NotifyClusterState
func
(
*
NotifyClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyClusterState
)
NEO
MsgCode
()
uint16
{
return
68
}
func
(
p
*
NotifyClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyClusterState
)
NEO
MsgEncodedLen
()
int
{
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
)))
}
func
(
p
*
NotifyClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
NotifyClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
goto
overflow
}
...
...
@@ -2736,36 +2736,36 @@ overflow:
// 69. AskClusterState
func
(
*
AskClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
AskClusterState
)
NEO
MsgCode
()
uint16
{
return
69
}
func
(
p
*
AskClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskClusterState
)
NEO
MsgEncodedLen
()
int
{
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
}
// 69 | answerBit. AnswerClusterState
func
(
*
AnswerClusterState
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerClusterState
)
NEO
MsgCode
()
uint16
{
return
69
|
answerBit
}
func
(
p
*
AnswerClusterState
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerClusterState
)
NEO
MsgEncodedLen
()
int
{
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
)))
}
func
(
p
*
AnswerClusterState
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerClusterState
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
4
{
goto
overflow
}
...
...
@@ -2778,15 +2778,15 @@ overflow:
// 71. ObjectUndoSerial
func
(
*
ObjectUndoSerial
)
neo
MsgCode
()
uint16
{
func
(
*
ObjectUndoSerial
)
NEO
MsgCode
()
uint16
{
return
71
}
func
(
p
*
ObjectUndoSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ObjectUndoSerial
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
LTID
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
UndoneTID
))
...
...
@@ -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
if
len
(
data
)
<
28
{
goto
overflow
...
...
@@ -2832,15 +2832,15 @@ overflow:
// 71 | answerBit. AnswerObjectUndoSerial
func
(
*
AnswerObjectUndoSerial
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerObjectUndoSerial
)
NEO
MsgCode
()
uint16
{
return
71
|
answerBit
}
func
(
p
*
AnswerObjectUndoSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerObjectUndoSerial
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2900,22 +2900,22 @@ overflow:
// 73. AskTIDsFrom
func
(
*
AskTIDsFrom
)
neo
MsgCode
()
uint16
{
func
(
*
AskTIDsFrom
)
NEO
MsgCode
()
uint16
{
return
73
}
func
(
p
*
AskTIDsFrom
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AskTIDsFrom
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
MaxTID
))
binary
.
BigEndian
.
PutUint32
(
data
[
16
:
],
p
.
Length
)
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
{
goto
overflow
}
...
...
@@ -2931,15 +2931,15 @@ overflow:
// 73 | answerBit. AnswerTIDsFrom
func
(
*
AnswerTIDsFrom
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerTIDsFrom
)
NEO
MsgCode
()
uint16
{
return
73
|
answerBit
}
func
(
p
*
AnswerTIDsFrom
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerTIDsFrom
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -2979,19 +2979,19 @@ overflow:
// 75. Pack
func
(
*
Pack
)
neo
MsgCode
()
uint16
{
func
(
*
Pack
)
NEO
MsgCode
()
uint16
{
return
75
}
func
(
p
*
Pack
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Pack
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
Pack
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Pack
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -3004,19 +3004,19 @@ overflow:
// 75 | answerBit. AnswerPack
func
(
*
AnswerPack
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerPack
)
NEO
MsgCode
()
uint16
{
return
75
|
answerBit
}
func
(
p
*
AnswerPack
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerPack
)
NEO
MsgEncodedLen
()
int
{
return
1
}
func
(
p
*
AnswerPack
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerPack
)
NEO
MsgEncode
(
data
[]
byte
)
{
(
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
{
goto
overflow
}
...
...
@@ -3029,15 +3029,15 @@ overflow:
// 77. CheckReplicas
func
(
*
CheckReplicas
)
neo
MsgCode
()
uint16
{
func
(
*
CheckReplicas
)
NEO
MsgCode
()
uint16
{
return
77
}
func
(
p
*
CheckReplicas
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckReplicas
)
NEO
MsgEncodedLen
()
int
{
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
))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
...
...
@@ -3057,7 +3057,7 @@ func (p *CheckReplicas) neoMsgEncode(data []byte) {
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
if
len
(
data
)
<
4
{
goto
overflow
...
...
@@ -3087,15 +3087,15 @@ overflow:
// 78. CheckPartition
func
(
*
CheckPartition
)
neo
MsgCode
()
uint16
{
func
(
*
CheckPartition
)
NEO
MsgCode
()
uint16
{
return
78
}
func
(
p
*
CheckPartition
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckPartition
)
NEO
MsgEncodedLen
()
int
{
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
)
{
l
:=
uint32
(
len
(
p
.
Source
.
UpstreamName
))
...
...
@@ -3112,7 +3112,7 @@ func (p *CheckPartition) neoMsgEncode(data []byte) {
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
if
len
(
data
)
<
8
{
goto
overflow
...
...
@@ -3149,22 +3149,22 @@ overflow:
// 79. CheckTIDRange
func
(
*
CheckTIDRange
)
neo
MsgCode
()
uint16
{
func
(
*
CheckTIDRange
)
NEO
MsgCode
()
uint16
{
return
79
}
func
(
p
*
CheckTIDRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckTIDRange
)
NEO
MsgEncodedLen
()
int
{
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
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
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
{
goto
overflow
}
...
...
@@ -3180,21 +3180,21 @@ overflow:
// 79 | answerBit. AnswerCheckTIDRange
func
(
*
AnswerCheckTIDRange
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckTIDRange
)
NEO
MsgCode
()
uint16
{
return
79
|
answerBit
}
func
(
p
*
AnswerCheckTIDRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckTIDRange
)
NEO
MsgEncodedLen
()
int
{
return
32
}
func
(
p
*
AnswerCheckTIDRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerCheckTIDRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
copy
(
data
[
4
:
],
p
.
Checksum
[
:
])
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
{
goto
overflow
}
...
...
@@ -3209,15 +3209,15 @@ overflow:
// 81. CheckSerialRange
func
(
*
CheckSerialRange
)
neo
MsgCode
()
uint16
{
func
(
*
CheckSerialRange
)
NEO
MsgCode
()
uint16
{
return
81
}
func
(
p
*
CheckSerialRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckSerialRange
)
NEO
MsgEncodedLen
()
int
{
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
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTID
))
...
...
@@ -3225,7 +3225,7 @@ func (p *CheckSerialRange) neoMsgEncode(data []byte) {
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
{
goto
overflow
}
...
...
@@ -3242,15 +3242,15 @@ overflow:
// 81 | answerBit. AnswerCheckSerialRange
func
(
*
AnswerCheckSerialRange
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckSerialRange
)
NEO
MsgCode
()
uint16
{
return
81
|
answerBit
}
func
(
p
*
AnswerCheckSerialRange
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckSerialRange
)
NEO
MsgEncodedLen
()
int
{
return
60
}
func
(
p
*
AnswerCheckSerialRange
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerCheckSerialRange
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
Count
)
copy
(
data
[
4
:
],
p
.
TidChecksum
[
:
])
binary
.
BigEndian
.
PutUint64
(
data
[
24
:
],
uint64
(
p
.
MaxTID
))
...
...
@@ -3258,7 +3258,7 @@ func (p *AnswerCheckSerialRange) neoMsgEncode(data []byte) {
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
{
goto
overflow
}
...
...
@@ -3275,15 +3275,15 @@ overflow:
// 83. PartitionCorrupted
func
(
*
PartitionCorrupted
)
neo
MsgCode
()
uint16
{
func
(
*
PartitionCorrupted
)
NEO
MsgCode
()
uint16
{
return
83
}
func
(
p
*
PartitionCorrupted
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
PartitionCorrupted
)
NEO
MsgEncodedLen
()
int
{
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
)
{
l
:=
uint32
(
len
(
p
.
CellList
))
...
...
@@ -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
if
len
(
data
)
<
8
{
goto
overflow
...
...
@@ -3325,53 +3325,53 @@ overflow:
// 84. NotifyReady
func
(
*
NotifyReady
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyReady
)
NEO
MsgCode
()
uint16
{
return
84
}
func
(
p
*
NotifyReady
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyReady
)
NEO
MsgEncodedLen
()
int
{
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
}
// 85. LastTransaction
func
(
*
LastTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
LastTransaction
)
NEO
MsgCode
()
uint16
{
return
85
}
func
(
p
*
LastTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
LastTransaction
)
NEO
MsgEncodedLen
()
int
{
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
}
// 85 | answerBit. AnswerLastTransaction
func
(
*
AnswerLastTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerLastTransaction
)
NEO
MsgCode
()
uint16
{
return
85
|
answerBit
}
func
(
p
*
AnswerLastTransaction
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerLastTransaction
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
AnswerLastTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerLastTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
goto
overflow
}
...
...
@@ -3384,21 +3384,21 @@ overflow:
// 87. CheckCurrentSerial
func
(
*
CheckCurrentSerial
)
neo
MsgCode
()
uint16
{
func
(
*
CheckCurrentSerial
)
NEO
MsgCode
()
uint16
{
return
87
}
func
(
p
*
CheckCurrentSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
CheckCurrentSerial
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
Oid
))
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
{
goto
overflow
}
...
...
@@ -3413,19 +3413,19 @@ overflow:
// 87 | answerBit. AnswerCheckCurrentSerial
func
(
*
AnswerCheckCurrentSerial
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerCheckCurrentSerial
)
NEO
MsgCode
()
uint16
{
return
87
|
answerBit
}
func
(
p
*
AnswerCheckCurrentSerial
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEO
MsgEncodedLen
()
int
{
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
))
}
func
(
p
*
AnswerCheckCurrentSerial
)
neo
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEO
MsgDecode
(
data
[]
byte
)
(
int
,
error
)
{
if
len
(
data
)
<
8
{
goto
overflow
}
...
...
@@ -3438,20 +3438,20 @@ overflow:
// 89. NotifyTransactionFinished
func
(
*
NotifyTransactionFinished
)
neo
MsgCode
()
uint16
{
func
(
*
NotifyTransactionFinished
)
NEO
MsgCode
()
uint16
{
return
89
}
func
(
p
*
NotifyTransactionFinished
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
NotifyTransactionFinished
)
NEO
MsgEncodedLen
()
int
{
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
[
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
{
goto
overflow
}
...
...
@@ -3465,11 +3465,11 @@ overflow:
// 90. Replicate
func
(
*
Replicate
)
neo
MsgCode
()
uint16
{
func
(
*
Replicate
)
NEO
MsgCode
()
uint16
{
return
90
}
func
(
p
*
Replicate
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Replicate
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
SourceDict
{
size
+=
len
(
p
.
SourceDict
[
key
])
...
...
@@ -3477,7 +3477,7 @@ func (p *Replicate) neoMsgEncodedLen() int {
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
))
{
l
:=
uint32
(
len
(
p
.
UpstreamName
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -3556,20 +3556,20 @@ overflow:
// 91. ReplicationDone
func
(
*
ReplicationDone
)
neo
MsgCode
()
uint16
{
func
(
*
ReplicationDone
)
NEO
MsgCode
()
uint16
{
return
91
}
func
(
p
*
ReplicationDone
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
ReplicationDone
)
NEO
MsgEncodedLen
()
int
{
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
.
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
{
goto
overflow
}
...
...
@@ -3583,15 +3583,15 @@ overflow:
// 92. FetchTransactions
func
(
*
FetchTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
FetchTransactions
)
NEO
MsgCode
()
uint16
{
return
92
}
func
(
p
*
FetchTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FetchTransactions
)
NEO
MsgEncodedLen
()
int
{
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
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
...
...
@@ -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
if
len
(
data
)
<
28
{
goto
overflow
...
...
@@ -3639,15 +3639,15 @@ overflow:
// 92 | answerBit. AnswerFetchTransactions
func
(
*
AnswerFetchTransactions
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFetchTransactions
)
NEO
MsgCode
()
uint16
{
return
92
|
answerBit
}
func
(
p
*
AnswerFetchTransactions
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFetchTransactions
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
NextTid
))
{
...
...
@@ -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
if
len
(
data
)
<
20
{
goto
overflow
...
...
@@ -3691,11 +3691,11 @@ overflow:
// 94. FetchObjects
func
(
*
FetchObjects
)
neo
MsgCode
()
uint16
{
func
(
*
FetchObjects
)
NEO
MsgCode
()
uint16
{
return
94
}
func
(
p
*
FetchObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
FetchObjects
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
ObjKnownDict
{
size
+=
len
(
p
.
ObjKnownDict
[
key
])
*
8
...
...
@@ -3703,7 +3703,7 @@ func (p *FetchObjects) neoMsgEncodedLen() int {
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
[
4
:
],
p
.
Length
)
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
MinTid
))
...
...
@@ -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
if
len
(
data
)
<
36
{
goto
overflow
...
...
@@ -3782,11 +3782,11 @@ overflow:
// 94 | answerBit. AnswerFetchObjects
func
(
*
AnswerFetchObjects
)
neo
MsgCode
()
uint16
{
func
(
*
AnswerFetchObjects
)
NEO
MsgCode
()
uint16
{
return
94
|
answerBit
}
func
(
p
*
AnswerFetchObjects
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
AnswerFetchObjects
)
NEO
MsgEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
ObjDeleteDict
{
size
+=
len
(
p
.
ObjDeleteDict
[
key
])
*
8
...
...
@@ -3794,7 +3794,7 @@ func (p *AnswerFetchObjects) neoMsgEncodedLen() int {
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
[
8
:
],
uint64
(
p
.
NextTid
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextOid
))
...
...
@@ -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
if
len
(
data
)
<
28
{
goto
overflow
...
...
@@ -3869,15 +3869,15 @@ overflow:
// 96. AddTransaction
func
(
*
AddTransaction
)
neo
MsgCode
()
uint16
{
func
(
*
AddTransaction
)
NEO
MsgCode
()
uint16
{
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
}
func
(
p
*
AddTransaction
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
AddTransaction
)
NEO
MsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Tid
))
{
l
:=
uint32
(
len
(
p
.
User
))
...
...
@@ -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
if
len
(
data
)
<
12
{
goto
overflow
...
...
@@ -3974,30 +3974,30 @@ overflow:
// 97. AddObject
func
(
*
AddObject
)
neo
MsgCode
()
uint16
{
func
(
*
AddObject
)
NEO
MsgCode
()
uint16
{
return
97
}
func
(
p
*
AddObject
)
neo
MsgEncodedLen
()
int
{
return
49
+
len
(
p
.
Data
)
func
(
p
*
AddObject
)
NEO
MsgEncodedLen
()
int
{
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
[
8
:
],
uint64
(
p
.
Serial
))
(
data
[
16
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
copy
(
data
[
17
:
],
p
.
Checksum
[
:
])
{
l
:=
uint32
(
len
(
p
.
Data
))
l
:=
uint32
(
len
(
p
.
Data
.
XData
()
))
binary
.
BigEndian
.
PutUint32
(
data
[
37
:
],
l
)
data
=
data
[
41
:
]
copy
(
data
,
p
.
Data
)
copy
(
data
,
p
.
Data
.
XData
()
)
data
=
data
[
l
:
]
}
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
if
len
(
data
)
<
41
{
goto
overflow
...
...
@@ -4013,8 +4013,8 @@ func (p *AddObject) neoMsgDecode(data []byte) (int, error) {
goto
overflow
}
nread
+=
8
+
uint64
(
l
)
p
.
Data
=
m
ake
([]
byte
,
l
)
copy
(
p
.
Data
,
data
[
:
l
])
p
.
Data
=
m
em
.
BufAlloc
(
int
(
l
)
)
copy
(
p
.
Data
.
Data
,
data
[
:
l
])
data
=
data
[
l
:
]
}
p
.
DataSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
0
+
8
]))
...
...
@@ -4026,19 +4026,19 @@ overflow:
// 98. Truncate
func
(
*
Truncate
)
neo
MsgCode
()
uint16
{
func
(
*
Truncate
)
NEO
MsgCode
()
uint16
{
return
98
}
func
(
p
*
Truncate
)
neo
MsgEncodedLen
()
int
{
func
(
p
*
Truncate
)
NEO
MsgEncodedLen
()
int
{
return
8
}
func
(
p
*
Truncate
)
neo
MsgEncode
(
data
[]
byte
)
{
func
(
p
*
Truncate
)
NEO
MsgEncode
(
data
[]
byte
)
{
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
{
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"
...
...
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.
package
ne
o
package
prot
o
var
pyMsgRegistry
=
map
[
uint16
]
string
{
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 (
//"github.com/kylelemons/godebug/pretty"
"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/internal/common"
...
...
@@ -77,17 +78,17 @@ type eventNetListen struct {
type
eventNeoSend
struct
{
Src
,
Dst
string
ConnID
uint32
Msg
ne
o
.
Msg
Msg
prot
o
.
Msg
}
// event: cluster state changed
type
eventClusterState
struct
{
//Ptr *neo.ClusterState // pointer to variable which holds the state
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
}
}
...
...
@@ -95,7 +96,7 @@ func clusterState(where string, v neo.ClusterState) *eventClusterState {
type
eventNodeTab
struct
{
//NodeTab unsafe.Pointer // *neo.NodeTable XXX not to noise test diff
Where
string
// host of running node XXX ok? XXX -> TabName?
NodeInfo
ne
o
.
NodeInfo
NodeInfo
prot
o
.
NodeInfo
}
// event: master ready to start changed
...
...
@@ -293,7 +294,7 @@ type TraceCollector struct {
node2Name
map
[
*
neo
.
NodeApp
]
string
nodeTab2Owner
map
[
*
neo
.
NodeTable
]
string
clusterState2Owner
map
[
*
ne
o
.
ClusterState
]
string
clusterState2Owner
map
[
*
prot
o
.
ClusterState
]
string
}
func
NewTraceCollector
(
dispatch
*
tsync
.
EventDispatcher
)
*
TraceCollector
{
...
...
@@ -303,18 +304,19 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
node2Name
:
make
(
map
[
*
neo
.
NodeApp
]
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/proto"
// Attach attaches the tracer to appropriate trace points.
func
(
t
*
TraceCollector
)
Attach
()
{
tracing
.
Lock
()
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
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
)
traceMasterStartReady_Attach
(
t
.
pg
,
t
.
traceMasterStartReady
)
tracing
.
Unlock
()
...
...
@@ -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
)
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
})
}
func
(
t
*
TraceCollector
)
traceClusterState
(
cs
*
ne
o
.
ClusterState
)
{
func
(
t
*
TraceCollector
)
traceClusterState
(
cs
*
prot
o
.
ClusterState
)
{
//t.d.Dispatch(&eventClusterState{cs, *cs})
where
:=
t
.
clusterState2Owner
[
cs
]
t
.
d
.
Dispatch
(
&
eventClusterState
{
where
,
*
cs
})
...
...
@@ -400,11 +402,11 @@ func TestMasterStorage(t *testing.T) {
exc
.
Raiseif
(
err
)
return
a
}
xnaddr
:=
func
(
addr
string
)
ne
o
.
Address
{
xnaddr
:=
func
(
addr
string
)
prot
o
.
Address
{
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
)
return
a
}
...
...
@@ -419,23 +421,23 @@ func TestMasterStorage(t *testing.T) {
}
// 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
}
}
// shortcut for NodeInfo
nodei
:=
func
(
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtime
neo
.
IdTime
)
ne
o
.
NodeInfo
{
return
ne
o
.
NodeInfo
{
nodei
:=
func
(
laddr
string
,
typ
proto
.
NodeType
,
num
int32
,
state
proto
.
NodeState
,
idtime
proto
.
IdTime
)
prot
o
.
NodeInfo
{
return
prot
o
.
NodeInfo
{
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
ne
o
.
UUID
(
typ
,
num
),
UUID
:
prot
o
.
UUID
(
typ
,
num
),
State
:
state
,
IdTime
:
idtime
,
}
}
// 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
{
Where
:
where
,
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtime
),
...
...
@@ -507,8 +509,8 @@ func TestMasterStorage(t *testing.T) {
// M starts listening
tM
.
Expect
(
netlisten
(
"m:1"
))
tM
.
Expect
(
node
(
"m"
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
ne
o
.
IdTimeNone
))
tM
.
Expect
(
clusterState
(
"m"
,
ne
o
.
ClusterRecovering
))
tM
.
Expect
(
node
(
"m"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
))
tM
.
Expect
(
clusterState
(
"m"
,
prot
o
.
ClusterRecovering
))
// TODO create C; C tries connect to master - rejected ("not yet operational")
...
...
@@ -517,39 +519,39 @@ func TestMasterStorage(t *testing.T) {
// S connects M
tSM
.
Expect
(
netconnect
(
"s:2"
,
"m:2"
,
"m:1"
))
tSM
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
1
,
&
ne
o
.
RequestIdentification
{
NodeType
:
ne
o
.
STORAGE
,
tSM
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
1
,
&
prot
o
.
RequestIdentification
{
NodeType
:
prot
o
.
STORAGE
,
UUID
:
0
,
Address
:
xnaddr
(
"s:1"
),
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
{
NodeType
:
ne
o
.
MASTER
,
MyUUID
:
neo
.
UUID
(
ne
o
.
MASTER
,
1
),
tSM
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
prot
o
.
AcceptIdentification
{
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
proto
.
UUID
(
prot
o
.
MASTER
,
1
),
NumPartitions
:
1
,
NumReplicas
:
1
,
YourUUID
:
neo
.
UUID
(
ne
o
.
STORAGE
,
1
),
YourUUID
:
proto
.
UUID
(
prot
o
.
STORAGE
,
1
),
}))
// TODO test ID rejects (uuid already registered, ...)
// M starts recovery on S
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
0
,
&
ne
o
.
Recovery
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
0
,
&
ne
o
.
AnswerRecovery
{
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
0
,
&
prot
o
.
Recovery
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
0
,
&
prot
o
.
AnswerRecovery
{
// empty new node
PTid
:
0
,
BackupTid
:
ne
o
.
INVALID_TID
,
TruncateTid
:
ne
o
.
INVALID_TID
,
BackupTid
:
prot
o
.
INVALID_TID
,
TruncateTid
:
prot
o
.
INVALID_TID
,
}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
2
,
&
ne
o
.
AskPartitionTable
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
2
,
&
ne
o
.
AnswerPartitionTable
{
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
2
,
&
prot
o
.
AskPartitionTable
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
2
,
&
prot
o
.
AnswerPartitionTable
{
PTid
:
0
,
RowList
:
[]
ne
o
.
RowInfo
{},
RowList
:
[]
prot
o
.
RowInfo
{},
}))
// M ready to start: new cluster, no in-progress S recovery
...
...
@@ -567,31 +569,31 @@ func TestMasterStorage(t *testing.T) {
// 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
)
// XXX M.partTab <- S1
// 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
,
RowList
:
[]
ne
o
.
RowInfo
{
{
0
,
[]
neo
.
CellInfo
{{
neo
.
UUID
(
neo
.
STORAGE
,
1
),
ne
o
.
UP_TO_DATE
}}},
RowList
:
[]
prot
o
.
RowInfo
{
{
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
(
"s:2"
,
"m:2"
,
6
,
&
ne
o
.
AnswerLockedTransactions
{
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
6
,
&
prot
o
.
LockedTransactions
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
6
,
&
prot
o
.
AnswerLockedTransactions
{
TidDict
:
nil
,
// map[zodb.Tid]zodb.Tid{},
}))
lastOid
,
err1
:=
zstor
.
LastOid
(
bg
)
lastTid
,
err2
:=
zstor
.
LastTid
(
bg
)
exc
.
Raiseif
(
xerr
.
Merge
(
err1
,
err2
))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
8
,
&
ne
o
.
LastIDs
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
8
,
&
ne
o
.
AnswerLastIDs
{
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
8
,
&
prot
o
.
LastIDs
{}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
8
,
&
prot
o
.
AnswerLastIDs
{
LastOid
:
lastOid
,
LastTid
:
lastTid
,
}))
...
...
@@ -604,11 +606,11 @@ func TestMasterStorage(t *testing.T) {
// TODO M.Stop() while verify
// 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
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
10
,
&
ne
o
.
StartOperation
{
Backup
:
false
}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
10
,
&
ne
o
.
NotifyReady
{}))
tMS
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
10
,
&
prot
o
.
StartOperation
{
Backup
:
false
}))
tMS
.
Expect
(
conntx
(
"s:2"
,
"m:2"
,
10
,
&
prot
o
.
NotifyReady
{}))
// TODO S leave while service
// TODO S join while service
...
...
@@ -629,48 +631,48 @@ func TestMasterStorage(t *testing.T) {
// C connects M
tCM
.
Expect
(
netconnect
(
"c:1"
,
"m:3"
,
"m:1"
))
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
1
,
&
ne
o
.
RequestIdentification
{
NodeType
:
ne
o
.
CLIENT
,
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
1
,
&
prot
o
.
RequestIdentification
{
NodeType
:
prot
o
.
CLIENT
,
UUID
:
0
,
Address
:
xnaddr
(
""
),
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
{
NodeType
:
ne
o
.
MASTER
,
MyUUID
:
neo
.
UUID
(
ne
o
.
MASTER
,
1
),
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
prot
o
.
AcceptIdentification
{
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
proto
.
UUID
(
prot
o
.
MASTER
,
1
),
NumPartitions
:
1
,
NumReplicas
:
1
,
YourUUID
:
neo
.
UUID
(
ne
o
.
CLIENT
,
1
),
YourUUID
:
proto
.
UUID
(
prot
o
.
CLIENT
,
1
),
}))
// C asks M about PT
// 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
(
"m:3"
,
"c:1"
,
3
,
&
ne
o
.
AnswerPartitionTable
{
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
3
,
&
prot
o
.
AskPartitionTable
{}))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
3
,
&
prot
o
.
AnswerPartitionTable
{
PTid
:
1
,
RowList
:
[]
ne
o
.
RowInfo
{
{
0
,
[]
neo
.
CellInfo
{{
neo
.
UUID
(
neo
.
STORAGE
,
1
),
ne
o
.
UP_TO_DATE
}}},
RowList
:
[]
prot
o
.
RowInfo
{
{
0
,
[]
proto
.
CellInfo
{{
proto
.
UUID
(
proto
.
STORAGE
,
1
),
prot
o
.
UP_TO_DATE
}}},
},
}))
// C <- M NotifyNodeInformation C1,M1,S1
// FIXME this might come in parallel with ^^^ "C asks M about PT"
tMC
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
ne
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
ne
o
.
NodeInfo
{
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
ne
o
.
IdTimeNone
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
RUNNING
,
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
ne
o
.
RUNNING
,
0.02
),
tMC
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
prot
o
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
prot
o
.
NodeInfo
{
nodei
(
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
),
nodei
(
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
RUNNING
,
0.01
),
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"
,
"s:1"
,
neo
.
STORAGE
,
1
,
ne
o
.
RUNNING
,
0.01
))
tMC
.
Expect
(
node
(
"c"
,
""
,
neo
.
CLIENT
,
1
,
ne
o
.
RUNNING
,
0.02
))
tMC
.
Expect
(
node
(
"c"
,
"m:1"
,
proto
.
MASTER
,
1
,
proto
.
RUNNING
,
prot
o
.
IdTimeNone
))
tMC
.
Expect
(
node
(
"c"
,
"s:1"
,
proto
.
STORAGE
,
1
,
prot
o
.
RUNNING
,
0.01
))
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
...
...
@@ -684,8 +686,8 @@ func TestMasterStorage(t *testing.T) {
}
})
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
5
,
&
ne
o
.
LastTransaction
{}))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
5
,
&
ne
o
.
AnswerLastTransaction
{
tCM
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
5
,
&
prot
o
.
LastTransaction
{}))
tCM
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
5
,
&
prot
o
.
AnswerLastTransaction
{
Tid
:
lastTid
,
}))
...
...
go/neo/server/master.go
View file @
47f069a5
...
...
@@ -34,6 +34,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"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/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
...
...
@@ -73,7 +74,7 @@ type Master struct {
// Use Run to actually start running the node.
func
NewMaster
(
clusterName
,
serveAddr
string
,
net
xnet
.
Networker
)
*
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
),
ctlStop
:
make
(
chan
chan
struct
{}),
...
...
@@ -118,7 +119,7 @@ func (m *Master) Shutdown() error {
// 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
)
// TODO notify subscribers
...
...
@@ -136,19 +137,19 @@ func (m *Master) Run(ctx context.Context) (err error) {
defer
task
.
Runningf
(
&
ctx
,
"master(%v)"
,
l
.
Addr
())(
&
err
)
m
.
node
.
MasterAddr
=
l
.
Addr
()
.
String
()
naddr
,
err
:=
ne
o
.
Addr
(
l
.
Addr
())
naddr
,
err
:=
prot
o
.
Addr
(
l
.
Addr
())
if
err
!=
nil
{
// must be ok since l.Addr() is valid since it is listening
// XXX panic -> errors.Wrap?
panic
(
err
)
}
m
.
node
.
MyInfo
=
ne
o
.
NodeInfo
{
Type
:
ne
o
.
MASTER
,
m
.
node
.
MyInfo
=
prot
o
.
NodeInfo
{
Type
:
prot
o
.
MASTER
,
Addr
:
naddr
,
UUID
:
m
.
allocUUID
(
ne
o
.
MASTER
),
State
:
ne
o
.
RUNNING
,
IdTime
:
ne
o
.
IdTimeNone
,
// XXX ok?
UUID
:
m
.
allocUUID
(
prot
o
.
MASTER
),
State
:
prot
o
.
RUNNING
,
IdTime
:
prot
o
.
IdTimeNone
,
// XXX ok?
}
// update nodeTab with self
...
...
@@ -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
// listening for it on our side anymore.
switch
idReq
.
NodeType
{
case
ne
o
.
CLIENT
:
case
prot
o
.
CLIENT
:
// ok
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
fallthrough
default
:
req
.
Link
()
.
CloseAccept
()
...
...
@@ -287,7 +288,7 @@ type storRecovery struct {
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"recovery"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterRecovering
)
m
.
setClusterState
(
prot
o
.
ClusterRecovering
)
ctx
,
rcancel
:=
context
.
WithCancel
(
ctx
)
defer
rcancel
()
...
...
@@ -301,7 +302,7 @@ func (m *Master) recovery(ctx context.Context) (err error) {
// start recovery on all storages we are currently in touch with
// XXX close links to clients
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
++
wg
.
Add
(
1
)
go
func
()
{
...
...
@@ -352,7 +353,7 @@ loop:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
ne
o
.
DOWN
)
r
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
}
else
{
...
...
@@ -371,7 +372,7 @@ loop:
// recovery and there is no in-progress recovery running
nup
:=
0
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
if
stor
.
State
>
prot
o
.
DOWN
{
nup
++
}
}
...
...
@@ -436,7 +437,7 @@ loop2:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
ne
o
.
DOWN
)
r
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
case
<-
done
:
...
...
@@ -453,8 +454,8 @@ loop2:
// S PENDING -> RUNNING
// XXX recheck logic is ok for when starting existing cluster
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
==
ne
o
.
PENDING
{
stor
.
SetState
(
ne
o
.
RUNNING
)
if
stor
.
State
==
prot
o
.
PENDING
{
stor
.
SetState
(
prot
o
.
RUNNING
)
}
}
...
...
@@ -463,7 +464,7 @@ loop2:
// XXX -> m.nodeTab.StorageList(State > DOWN)
storv
:=
[]
*
neo
.
Node
{}
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
>
ne
o
.
DOWN
{
if
stor
.
State
>
prot
o
.
DOWN
{
storv
=
append
(
storv
,
stor
)
}
}
...
...
@@ -492,14 +493,14 @@ func storCtlRecovery(ctx context.Context, stor *neo.Node, res chan storRecovery)
// XXX cancel on ctx
recovery
:=
ne
o
.
AnswerRecovery
{}
err
=
slink
.
Ask1
(
&
ne
o
.
Recovery
{},
&
recovery
)
recovery
:=
prot
o
.
AnswerRecovery
{}
err
=
slink
.
Ask1
(
&
prot
o
.
Recovery
{},
&
recovery
)
if
err
!=
nil
{
return
}
resp
:=
ne
o
.
AnswerPartitionTable
{}
err
=
slink
.
Ask1
(
&
ne
o
.
AskPartitionTable
{},
&
resp
)
resp
:=
prot
o
.
AnswerPartitionTable
{}
err
=
slink
.
Ask1
(
&
prot
o
.
AskPartitionTable
{},
&
resp
)
if
err
!=
nil
{
return
}
...
...
@@ -536,7 +537,7 @@ var errClusterDegraded = stderrors.New("cluster became non-operatonal")
func
(
m
*
Master
)
verify
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"verify"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterVerifying
)
m
.
setClusterState
(
prot
o
.
ClusterVerifying
)
ctx
,
vcancel
:=
context
.
WithCancel
(
ctx
)
defer
vcancel
()
...
...
@@ -549,7 +550,7 @@ func (m *Master) verify(ctx context.Context) (err error) {
// start verification on all storages we are currently in touch with
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
++
wg
.
Add
(
1
)
go
func
()
{
...
...
@@ -587,7 +588,7 @@ loop:
/*
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 !m.node.PartTab.OperationalWith(m.node.NodeTab) {
...
...
@@ -611,7 +612,7 @@ loop:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
ne
o
.
DOWN
)
v
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
// check partTab is still operational
...
...
@@ -660,7 +661,7 @@ loop2:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
ne
o
.
DOWN
)
v
.
stor
.
SetState
(
prot
o
.
DOWN
)
}
case
<-
done
:
...
...
@@ -694,7 +695,7 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
defer
task
.
Runningf
(
&
ctx
,
"%s: stor verify"
,
slink
)(
&
err
)
// send just recovered parttab so storage saves it
err
=
slink
.
Send1
(
&
ne
o
.
SendPartitionTable
{
err
=
slink
.
Send1
(
&
prot
o
.
SendPartitionTable
{
PTid
:
pt
.
PTid
,
RowList
:
pt
.
Dump
(),
})
...
...
@@ -702,8 +703,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
return
}
locked
:=
ne
o
.
AnswerLockedTransactions
{}
err
=
slink
.
Ask1
(
&
ne
o
.
LockedTransactions
{},
&
locked
)
locked
:=
prot
o
.
AnswerLockedTransactions
{}
err
=
slink
.
Ask1
(
&
prot
o
.
LockedTransactions
{},
&
locked
)
if
err
!=
nil
{
return
}
...
...
@@ -714,8 +715,8 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
return
}
last
:=
ne
o
.
AnswerLastIDs
{}
err
=
slink
.
Ask1
(
&
ne
o
.
LastIDs
{},
&
last
)
last
:=
prot
o
.
AnswerLastIDs
{}
err
=
slink
.
Ask1
(
&
prot
o
.
LastIDs
{},
&
last
)
if
err
!=
nil
{
return
}
...
...
@@ -749,7 +750,7 @@ type serviceDone struct {
func
(
m
*
Master
)
service
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Running
(
&
ctx
,
"service"
)(
&
err
)
m
.
setClusterState
(
ne
o
.
ClusterRunning
)
m
.
setClusterState
(
prot
o
.
ClusterRunning
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
...
...
@@ -758,7 +759,7 @@ func (m *Master) service(ctx context.Context) (err error) {
// spawn per-storage service driver
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
)
go
func
()
{
defer
wg
.
Done
()
...
...
@@ -791,10 +792,10 @@ loop:
}
switch
node
.
Type
{
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
err
=
storCtlService
(
ctx
,
node
)
case
ne
o
.
CLIENT
:
case
prot
o
.
CLIENT
:
err
=
m
.
serveClient
(
ctx
,
node
)
// XXX ADMIN
...
...
@@ -810,7 +811,7 @@ loop:
/*
// XXX who sends here?
case n := <-m.nodeLeave:
n.node.SetState(
ne
o.DOWN)
n.node.SetState(
prot
o.DOWN)
// if cluster became non-operational - cancel service
if !m.node.PartTab.OperationalWith(m.node.NodeTab) {
...
...
@@ -853,9 +854,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
// XXX current neo/py does StartOperation / NotifyReady as separate
// sends, not exchange on the same conn. - fixed
ready
:=
ne
o
.
NotifyReady
{}
err
=
slink
.
Ask1
(
&
ne
o
.
StartOperation
{
Backup
:
false
},
&
ready
)
//err = slink.Send1(&
ne
o.StartOperation{Backup: false})
ready
:=
prot
o
.
NotifyReady
{}
err
=
slink
.
Ask1
(
&
prot
o
.
StartOperation
{
Backup
:
false
},
&
ready
)
//err = slink.Send1(&
prot
o.StartOperation{Backup: false})
//if err != nil {
// return err
//}
...
...
@@ -865,9 +866,9 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
//}
//req.Close() XXX must be after req handling
//switch msg := req.Msg.(type) {
//case *
ne
o.NotifyReady:
//case *
prot
o.NotifyReady:
// // ok
//case *
ne
o.Error:
//case *
prot
o.Error:
// return msg
//default:
// return fmt.Errorf("unexpected message %T", msg)
...
...
@@ -924,23 +925,23 @@ func (m *Master) serveClient(ctx context.Context, cli *neo.Node) (err error) {
}
// 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
)
{
case
*
ne
o
.
AskPartitionTable
:
case
*
prot
o
.
AskPartitionTable
:
m
.
node
.
StateMu
.
RLock
()
rpt
:=
&
ne
o
.
AnswerPartitionTable
{
rpt
:=
&
prot
o
.
AnswerPartitionTable
{
PTid
:
m
.
node
.
PartTab
.
PTid
,
RowList
:
m
.
node
.
PartTab
.
Dump
(),
}
m
.
node
.
StateMu
.
RUnlock
()
return
rpt
case
*
ne
o
.
LastTransaction
:
case
*
prot
o
.
LastTransaction
:
// XXX lock
return
&
ne
o
.
AnswerLastTransaction
{
m
.
lastTid
}
return
&
prot
o
.
AnswerLastTransaction
{
m
.
lastTid
}
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
// XXX ^^^ + subscribe
nodev
:=
m
.
node
.
NodeTab
.
All
()
nodeiv
:=
make
([]
ne
o
.
NodeInfo
,
len
(
nodev
))
nodeiv
:=
make
([]
prot
o
.
NodeInfo
,
len
(
nodev
))
for
i
,
node
:=
range
nodev
{
// NOTE .NodeInfo is data not pointers - so won't change after we copy it to nodeiv
nodeiv
[
i
]
=
node
.
NodeInfo
...
...
@@ -982,8 +983,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// first send the snapshot.
// XXX +ClusterState
err
=
link
.
Send1
(
&
ne
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX what here?
err
=
link
.
Send1
(
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
prot
o
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
})
if
err
!=
nil
{
...
...
@@ -992,7 +993,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// now proxy the updates until we are done
for
{
var
msg
ne
o
.
Msg
var
msg
prot
o
.
Msg
select
{
case
<-
ctx
.
Done
()
:
...
...
@@ -1001,8 +1002,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX ClusterState
case
nodeiv
=
<-
nodech
:
msg
=
&
ne
o
.
NotifyNodeInformation
{
IdTime
:
ne
o
.
IdTimeNone
,
// XXX what here?
msg
=
&
prot
o
.
NotifyNodeInformation
{
IdTime
:
prot
o
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
}
}
...
...
@@ -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.
// 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.
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 ? :
// - NodeType valid
// - IdTime ?
...
...
@@ -1032,9 +1033,9 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
uuid
:=
n
.
idReq
.
UUID
nodeType
:=
n
.
idReq
.
NodeType
err
:=
func
()
*
ne
o
.
Error
{
err
:=
func
()
*
prot
o
.
Error
{
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
{
...
...
@@ -1048,23 +1049,23 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
if
node
!=
nil
{
// reject - uuid is already occupied by someone else
// 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.
// XXX ok to have this logic inside identify? (better provide from outside ?)
switch
nodeType
{
case
ne
o
.
CLIENT
:
if
m
.
node
.
ClusterState
!=
ne
o
.
ClusterRunning
{
return
&
neo
.
Error
{
ne
o
.
NOT_READY
,
"cluster not operational"
}
case
prot
o
.
CLIENT
:
if
m
.
node
.
ClusterState
!=
prot
o
.
ClusterRunning
{
return
&
proto
.
Error
{
prot
o
.
NOT_READY
,
"cluster not operational"
}
}
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
// ok
// TODO +master, admin
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
...
...
@@ -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
)
accept
:=
&
ne
o
.
AcceptIdentification
{
NodeType
:
ne
o
.
MASTER
,
accept
:=
&
prot
o
.
AcceptIdentification
{
NodeType
:
prot
o
.
MASTER
,
MyUUID
:
m
.
node
.
MyInfo
.
UUID
,
NumPartitions
:
1
,
// FIXME hardcoded
NumReplicas
:
1
,
// FIXME hardcoded
...
...
@@ -1087,22 +1088,22 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
}
// update nodeTab
var
nodeState
ne
o
.
NodeState
var
nodeState
prot
o
.
NodeState
switch
nodeType
{
case
ne
o
.
STORAGE
:
case
prot
o
.
STORAGE
:
// FIXME py sets to RUNNING/PENDING depending on cluster state
nodeState
=
ne
o
.
PENDING
nodeState
=
prot
o
.
PENDING
default
:
nodeState
=
ne
o
.
RUNNING
nodeState
=
prot
o
.
RUNNING
}
nodeInfo
:=
ne
o
.
NodeInfo
{
nodeInfo
:=
prot
o
.
NodeInfo
{
Type
:
nodeType
,
Addr
:
n
.
idReq
.
Address
,
UUID
:
uuid
,
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
...
...
@@ -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
// 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
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
++
{
uuid
:=
ne
o
.
UUID
(
nodeType
,
num
)
uuid
:=
prot
o
.
UUID
(
nodeType
,
num
)
if
m
.
node
.
NodeTab
.
Get
(
uuid
)
==
nil
{
return
uuid
}
...
...
go/neo/server/server.go
View file @
47f069a5
...
...
@@ -29,6 +29,7 @@ import (
"sync"
"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/go123/xerr"
...
...
@@ -77,7 +78,7 @@ func Serve(ctx context.Context, l *neo.Listener, srv Server) error {
// IdentifyPeer identifies peer on the link
// it expects peer to send RequestIdentification packet and replies with AcceptIdentification if identification passes.
// 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
)
// the first conn must come with RequestIdentification packet
...
...
@@ -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
)
if
err
!=
nil
{
return
nodeInfo
,
err
...
...
@@ -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
err
=
conn
.
Send
(
&
ne
o
.
AcceptIdentification
{
err
=
conn
.
Send
(
&
prot
o
.
AcceptIdentification
{
NodeType
:
myNodeType
,
MyUUID
:
0
,
// XXX
NumPartitions
:
1
,
// XXX
...
...
@@ -124,7 +125,7 @@ func IdentifyPeer(ctx context.Context, link *neo.NodeLink, myNodeType neo.NodeTy
// event: node connects
type
nodeCome
struct
{
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 {
// 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?
// log.Info(ctx, "identification rejected") ?
err1
:=
req
.
Reply
(
resp
)
...
...
@@ -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
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
)
defer
wg
.
Done
()
go
reject
(
ctx
,
req
,
resp
)
...
...
@@ -157,7 +158,7 @@ func goreject(ctx context.Context, wg *sync.WaitGroup, req *neo.Request, resp ne
// accept replies with acceptive identification response
// 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
err1
:=
req
.
Reply
(
resp
)
return
err1
// XXX while trying to work on single conn
...
...
go/neo/server/storage.go
View file @
47f069a5
...
...
@@ -31,6 +31,7 @@ import (
"github.com/pkg/errors"
"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/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
...
...
@@ -78,7 +79,7 @@ type Storage struct {
// Use Run to actually start running the node.
func
NewStorage
(
clusterName
,
masterAddr
,
serveAddr
string
,
net
xnet
.
Networker
,
zstor
*
fs1
.
FileStorage
)
*
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
,
}
...
...
@@ -198,7 +199,7 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) {
// XXX distinguish between temporary problems and non-temporary ones?
func
(
stor
*
Storage
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
// 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
{
return
err
}
...
...
@@ -274,49 +275,49 @@ func (stor *Storage) m1initialize1(ctx context.Context, req neo.Request) error {
default
:
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
case
*
ne
o
.
StartOperation
:
case
*
prot
o
.
StartOperation
:
// ok, transition to serve
return
cmdStart
case
*
ne
o
.
Recovery
:
err
=
req
.
Reply
(
&
ne
o
.
AnswerRecovery
{
case
*
prot
o
.
Recovery
:
err
=
req
.
Reply
(
&
prot
o
.
AnswerRecovery
{
PTid
:
stor
.
node
.
PartTab
.
PTid
,
BackupTid
:
ne
o
.
INVALID_TID
,
TruncateTid
:
ne
o
.
INVALID_TID
})
BackupTid
:
prot
o
.
INVALID_TID
,
TruncateTid
:
prot
o
.
INVALID_TID
})
case
*
ne
o
.
AskPartitionTable
:
case
*
prot
o
.
AskPartitionTable
:
// TODO initially read PT from disk
err
=
req
.
Reply
(
&
ne
o
.
AnswerPartitionTable
{
err
=
req
.
Reply
(
&
prot
o
.
AnswerPartitionTable
{
PTid
:
stor
.
node
.
PartTab
.
PTid
,
RowList
:
stor
.
node
.
PartTab
.
Dump
()})
case
*
ne
o
.
LockedTransactions
:
case
*
prot
o
.
LockedTransactions
:
// XXX r/o stub
err
=
req
.
Reply
(
&
ne
o
.
AnswerLockedTransactions
{})
err
=
req
.
Reply
(
&
prot
o
.
AnswerLockedTransactions
{})
// TODO AskUnfinishedTransactions
case
*
ne
o
.
LastIDs
:
case
*
prot
o
.
LastIDs
:
lastTid
,
zerr1
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastOid
,
zerr2
:=
stor
.
zstor
.
LastOid
(
ctx
)
if
zerr
:=
xerr
.
First
(
zerr1
,
zerr2
);
zerr
!=
nil
{
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
stor
.
node
.
UpdatePartTab
(
ctx
,
msg
)
// XXX lock?
case
*
ne
o
.
NotifyPartitionChanges
:
case
*
prot
o
.
NotifyPartitionChanges
:
// 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?
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?
}
...
...
@@ -347,7 +348,7 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
// reply M we are ready
// 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
()
if
err
!=
nil
{
return
err
...
...
@@ -373,16 +374,16 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
default
:
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
case
*
ne
o
.
StopOperation
:
case
*
prot
o
.
StopOperation
:
return
fmt
.
Errorf
(
"stop requested"
)
// XXX SendPartitionTable?
// XXX NotifyPartitionChanges?
case
*
ne
o
.
NotifyNodeInformation
:
case
*
prot
o
.
NotifyNodeInformation
:
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?
// TODO commit related messages
...
...
@@ -394,13 +395,13 @@ func (stor *Storage) m1serve1(ctx context.Context, req neo.Request) error {
// --- serve incoming connections from other nodes ---
// 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
if
idReq
.
NodeType
!=
ne
o
.
CLIENT
{
return
&
neo
.
Error
{
ne
o
.
PROTOCOL_ERROR
,
"only clients are accepted"
},
false
if
idReq
.
NodeType
!=
prot
o
.
CLIENT
{
return
&
proto
.
Error
{
prot
o
.
PROTOCOL_ERROR
,
"only clients are accepted"
},
false
}
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
...
...
@@ -409,10 +410,10 @@ func (stor *Storage) identify(idReq *neo.RequestIdentification) (neo.Msg, bool)
stor
.
opMu
.
Unlock
()
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
,
MyUUID
:
stor
.
node
.
MyInfo
.
UUID
,
// XXX lock wrt update
NumPartitions
:
1
,
// XXX
...
...
@@ -435,7 +436,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
// 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
()
defer
task
.
Runningf
(
&
ctx
,
"serve %s"
,
link
)(
&
err
)
defer
xio
.
CloseWhenDone
(
ctx
,
link
)()
...
...
@@ -507,7 +508,7 @@ func (stor *Storage) serveClient(ctx context.Context, req neo.Request) {
// XXX hack -> resp.Release()
// XXX req.Msg release too?
if
resp
,
ok
:=
resp
.
(
*
ne
o
.
AnswerObject
);
ok
{
if
resp
,
ok
:=
resp
.
(
*
prot
o
.
AnswerObject
);
ok
{
resp
.
Data
.
Release
()
}
...
...
@@ -547,11 +548,11 @@ func sha1Sum(b []byte) [sha1.Size]byte {
}
// 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
)
{
case
*
ne
o
.
GetObject
:
case
*
prot
o
.
GetObject
:
xid
:=
zodb
.
Xid
{
Oid
:
req
.
Oid
}
if
req
.
Serial
!=
ne
o
.
INVALID_TID
{
if
req
.
Serial
!=
prot
o
.
INVALID_TID
{
xid
.
At
=
req
.
Serial
}
else
{
xid
.
At
=
common
.
Before2At
(
req
.
Tid
)
...
...
@@ -562,15 +563,15 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
if
err
!=
nil
{
// translate err to NEO protocol error codes
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:
// 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
{
return
&
ne
o
.
Error
{
Code
:
ne
o
.
OID_NOT_FOUND
,
return
&
prot
o
.
Error
{
Code
:
prot
o
.
OID_NOT_FOUND
,
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
// no next serial -> None
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
,
Serial
:
serial
,
NextSerial
:
nextSerial
,
...
...
@@ -594,19 +595,19 @@ func (stor *Storage) serveClient1(ctx context.Context, req neo.Msg) (resp neo.Ms
// XXX .DataSerial
}
case
*
ne
o
.
LastTransaction
:
case
*
prot
o
.
LastTransaction
:
lastTid
,
err
:=
stor
.
zstor
.
LastTid
(
ctx
)
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 *StoreObject:
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(...)
...
...
go/neo/server/ztrace_test.go
View file @
47f069a5
...
...
@@ -8,24 +8,33 @@ import (
_
"unsafe"
"lab.nexedi.com/kirr/neo/go/neo"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
// traceimport: "lab.nexedi.com/kirr/neo/go/neo"
// 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
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
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
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
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
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
}
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
// traceevent: traceMsgRecv(c *Conn, msg Msg)
// traceevent: traceMsgRecv(c *Conn, msg
proto.
Msg)
type
_t_traceMsgRecv
struct
{
tracing
.
Probe
probefunc
func
(
c
*
Conn
,
msg
Msg
)
probefunc
func
(
c
*
Conn
,
msg
proto
.
Msg
)
}
var
_traceMsgRecv
*
_t_traceMsgRecv
func
traceMsgRecv
(
c
*
Conn
,
msg
Msg
)
{
func
traceMsgRecv
(
c
*
Conn
,
msg
proto
.
Msg
)
{
if
_traceMsgRecv
!=
nil
{
_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
()))
{
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
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgRecv
)),
&
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
{
tracing
.
Probe
probefunc
func
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
)
probefunc
func
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
)
}
var
_traceMsgSendPre
*
_t_traceMsgSendPre
func
traceMsgSendPre
(
l
*
NodeLink
,
connId
uint32
,
msg
Msg
)
{
func
traceMsgSendPre
(
l
*
NodeLink
,
connId
uint32
,
msg
proto
.
Msg
)
{
if
_traceMsgSendPre
!=
nil
{
_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
()))
{
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
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceMsgSendPre
)),
&
p
.
Probe
)
return
&
p
.
Probe
...
...
@@ -117,4 +92,4 @@ func traceNodeChanged_Attach(pg *tracing.ProbeGroup, probe func(nt *NodeTable, n
}
// 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 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
neo
// Types to use in packed structures
import
(
"encoding/binary"
"unsafe"
)
// Package packed provides types to use in packed structures.
package
packed
// 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
...
...
@@ -34,135 +29,26 @@ import (
// https://github.com/golang/go/issues/15925
//
// so in the end we use hand-crafted array-like byte-structs.
type
be16
struct
{
_0
,
_1
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)
type
BE16
struct
{
_0
,
_1
byte
}
type
BE32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
// ----------------------------------------
// good
func
_ntoh16_0
(
v
be16
)
uint16
{
b
:=
(
*
[
2
]
byte
)(
unsafe
.
Pointer
(
&
v
))
return
binary
.
BigEndian
.
Uint16
(
b
[
:
])
}
// bad (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
// XXX why?
func
_ntoh16_1
(
v
be16
)
uint16
{
func
Ntoh16
(
v
BE16
)
uint16
{
// XXX not as good as BigEndian.Uint16
// (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
return
uint16
(
v
.
_1
)
|
uint16
(
v
.
_0
)
<<
8
}
// good
func
_hton16_0
(
v
uint16
)
be16
{
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
[
:
])
func
Hton16
(
v
uint16
)
BE16
{
return
BE16
{
byte
(
v
>>
8
),
byte
(
v
)}
}
// baaaadd (unnecessary MOVBLZX AL, AX + shifts not combined into BSWAPL)
// XXX why?
func
_ntoh32_1
(
v
be32
)
uint32
{
func
Ntoh32
(
v
BE32
)
uint32
{
// XXX not as good as BigEndian.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
}
// good
func
_hton32_0
(
v
uint32
)
be32
{
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
func
Hton32
(
v
uint32
)
BE32
{
return
BE32
{
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
}
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