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
0983b672
Commit
0983b672
authored
Jan 13, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
aae27bf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
go/neo/neonet/connection.go
go/neo/neonet/connection.go
+8
-10
go/neo/neonet/newlink.go
go/neo/neonet/newlink.go
+2
-2
No files found.
go/neo/neonet/connection.go
View file @
0983b672
...
@@ -1391,14 +1391,8 @@ func (c *Conn) err(op string, e error) error {
...
@@ -1391,14 +1391,8 @@ func (c *Conn) err(op string, e error) error {
// XXX do we also need traceConnSend?
// XXX do we also need traceConnSend?
// XXX think again; XXX move to proto?
const
(
encN
=
proto
.
Encoding
(
'N'
)
encM
=
proto
.
Encoding
(
'M'
)
)
// pktEncode allocates pktBuf and encodes msg into it.
// pktEncode allocates pktBuf and encodes msg into it.
//func (e Encoding) pktEncode(connId uint32, msg proto.Msg) *pktBuf {
// XXX move to proto ? -> YES: Encoding.PktEncode + .PktDecode
// XXX move to proto ? -> YES: Encoding.PktEncode + .PktDecode
func
pktEncode
(
e
proto
.
Encoding
,
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
func
pktEncode
(
e
proto
.
Encoding
,
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
switch
e
{
switch
e
{
...
@@ -1424,7 +1418,9 @@ func pktDecodeHead(e proto.Encoding, pkt *pktBuf) (connID uint32, msgCode uint16
...
@@ -1424,7 +1418,9 @@ func pktDecodeHead(e proto.Encoding, pkt *pktBuf) (connID uint32, msgCode uint16
func
pktEncodeN
(
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
func
pktEncodeN
(
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
l
:=
encN
.
NEOMsgEncodedLen
(
msg
)
const
enc
=
proto
.
Encoding
(
'N'
)
l
:=
enc
.
NEOMsgEncodedLen
(
msg
)
buf
:=
pktAlloc
(
proto
.
PktHeaderLenN
+
l
)
buf
:=
pktAlloc
(
proto
.
PktHeaderLenN
+
l
)
h
:=
buf
.
HeaderN
()
h
:=
buf
.
HeaderN
()
...
@@ -1432,7 +1428,7 @@ func pktEncodeN(connId uint32, msg proto.Msg) *pktBuf {
...
@@ -1432,7 +1428,7 @@ func pktEncodeN(connId uint32, msg proto.Msg) *pktBuf {
h
.
MsgCode
=
packed
.
Hton16
(
proto
.
MsgCode
(
msg
))
h
.
MsgCode
=
packed
.
Hton16
(
proto
.
MsgCode
(
msg
))
h
.
MsgLen
=
packed
.
Hton32
(
uint32
(
l
))
// XXX casting: think again
h
.
MsgLen
=
packed
.
Hton32
(
uint32
(
l
))
// XXX casting: think again
enc
N
.
NEOMsgEncode
(
msg
,
buf
.
PayloadN
())
enc
.
NEOMsgEncode
(
msg
,
buf
.
PayloadN
())
return
buf
return
buf
}
}
...
@@ -1452,12 +1448,14 @@ func pktDecodeHeadN(pkt *pktBuf) (connID uint32, msgCode uint16, payload []byte,
...
@@ -1452,12 +1448,14 @@ func pktDecodeHeadN(pkt *pktBuf) (connID uint32, msgCode uint16, payload []byte,
}
}
func
pktEncodeM
(
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
func
pktEncodeM
(
connId
uint32
,
msg
proto
.
Msg
)
*
pktBuf
{
const
enc
=
proto
.
Encoding
(
'M'
)
// [3](connID, msgCode, argv)
// [3](connID, msgCode, argv)
msgCode
:=
proto
.
MsgCode
(
msg
)
msgCode
:=
proto
.
MsgCode
(
msg
)
hroom
:=
msgpack
.
ArrayHeadSize
(
3
)
+
hroom
:=
msgpack
.
ArrayHeadSize
(
3
)
+
msgpack
.
Uint32Size
(
connId
)
+
msgpack
.
Uint32Size
(
connId
)
+
msgpack
.
Uint16Size
(
msgCode
)
msgpack
.
Uint16Size
(
msgCode
)
l
:=
enc
M
.
NEOMsgEncodedLen
(
msg
)
l
:=
enc
.
NEOMsgEncodedLen
(
msg
)
buf
:=
pktAlloc
(
hroom
+
l
)
buf
:=
pktAlloc
(
hroom
+
l
)
...
@@ -1469,7 +1467,7 @@ func pktEncodeM(connId uint32, msg proto.Msg) *pktBuf {
...
@@ -1469,7 +1467,7 @@ func pktEncodeM(connId uint32, msg proto.Msg) *pktBuf {
if
i
!=
hroom
{
if
i
!=
hroom
{
panic
(
"bug"
)
panic
(
"bug"
)
}
}
enc
M
.
NEOMsgEncode
(
msg
,
b
[
hroom
:
])
enc
.
NEOMsgEncode
(
msg
,
b
[
hroom
:
])
return
buf
return
buf
}
}
...
...
go/neo/neonet/newlink.go
View file @
0983b672
...
@@ -232,7 +232,7 @@ func rxHello(errctx string, rx *fwd.Reader) (enc proto.Encoding, version uint32,
...
@@ -232,7 +232,7 @@ func rxHello(errctx string, rx *fwd.Reader) (enc proto.Encoding, version uint32,
badMagic
:=
false
badMagic
:=
false
switch
{
switch
{
case
bytes
.
Equal
(
b
[
:
3
],
[]
byte
{
0
,
0
,
0
})
:
case
bytes
.
Equal
(
b
[
:
3
],
[]
byte
{
0
,
0
,
0
})
:
peerEnc
=
encN
peerEnc
=
'N'
peerVer
=
uint32
(
b
[
3
])
peerVer
=
uint32
(
b
[
3
])
case
bytes
.
Equal
(
b
,
[]
byte
{
0x92
,
0xc4
,
3
,
'N'
})
:
// start of "fixarray<2> bin8 'N | EO' ...
case
bytes
.
Equal
(
b
,
[]
byte
{
0x92
,
0xc4
,
3
,
'N'
})
:
// start of "fixarray<2> bin8 'N | EO' ...
...
@@ -247,7 +247,7 @@ func rxHello(errctx string, rx *fwd.Reader) (enc proto.Encoding, version uint32,
...
@@ -247,7 +247,7 @@ func rxHello(errctx string, rx *fwd.Reader) (enc proto.Encoding, version uint32,
break
break
}
}
peerEnc
=
encM
peerEnc
=
'M'
rxM
:=
msgp
.
Reader
{
R
:
rx
}
rxM
:=
msgp
.
Reader
{
R
:
rx
}
peerVer
,
err
=
rxM
.
ReadUint32
()
peerVer
,
err
=
rxM
.
ReadUint32
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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