aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/handshake.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-19 22:11:02 +0800
committerFelix Lange <fjl@twurst.com>2015-03-19 22:11:02 +0800
commit5ba51594c7eb1f04b3636e6413de6d4eb70228d2 (patch)
tree71614118e0026a69c72f4f900a51c26055f00167 /p2p/handshake.go
parent4811f460e7aad37c6c6867df0461a5fa162b5f2c (diff)
downloaddexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.gz
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.bz2
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.lz
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.xz
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.zst
dexon-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.zip
p2p: use package rlp to encode messages
Message encoding functions have been renamed to catch any uses. The switch to the new encoder can cause subtle incompatibilities. If there are any users outside of our tree, they will at least be alerted that there was a change. NewMsg no longer exists. The replacements for EncodeMsg are called Send and SendItems.
Diffstat (limited to 'p2p/handshake.go')
-rw-r--r--p2p/handshake.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/p2p/handshake.go b/p2p/handshake.go
index 7fc497517..031064407 100644
--- a/p2p/handshake.go
+++ b/p2p/handshake.go
@@ -92,7 +92,7 @@ func setupInboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake) (
return nil, errors.New("node ID in protocol handshake does not match encryption handshake")
}
// TODO: validate that handshake node ID matches
- if err := writeProtocolHandshake(rw, our); err != nil {
+ if err := Send(rw, handshakeMsg, our); err != nil {
return nil, fmt.Errorf("protocol write error: %v", err)
}
return &conn{rw, rhs}, nil
@@ -106,7 +106,7 @@ func setupOutboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake,
// Run the protocol handshake using authenticated messages.
rw := newRlpxFrameRW(fd, secrets)
- if err := writeProtocolHandshake(rw, our); err != nil {
+ if err := Send(rw, handshakeMsg, our); err != nil {
return nil, fmt.Errorf("protocol write error: %v", err)
}
rhs, err := readProtocolHandshake(rw, our)
@@ -398,10 +398,6 @@ func xor(one, other []byte) (xor []byte) {
return xor
}
-func writeProtocolHandshake(w MsgWriter, our *protoHandshake) error {
- return EncodeMsg(w, handshakeMsg, our.Version, our.Name, our.Caps, our.ListenPort, our.ID[:])
-}
-
func readProtocolHandshake(r MsgReader, our *protoHandshake) (*protoHandshake, error) {
// read and handle remote handshake
msg, err := r.ReadMsg()