diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-19 22:11:02 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-19 22:11:02 +0800 |
commit | 5ba51594c7eb1f04b3636e6413de6d4eb70228d2 (patch) | |
tree | 71614118e0026a69c72f4f900a51c26055f00167 /p2p/server.go | |
parent | 4811f460e7aad37c6c6867df0461a5fa162b5f2c (diff) | |
download | dexon-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/server.go')
-rw-r--r-- | p2p/server.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/p2p/server.go b/p2p/server.go index 9c148ba39..813b0676f 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -9,10 +9,10 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/nat" + "github.com/ethereum/go-ethereum/rlp" ) const ( @@ -129,10 +129,14 @@ func (srv *Server) SuggestPeer(n *discover.Node) { // Broadcast sends an RLP-encoded message to all connected peers. // This method is deprecated and will be removed later. -func (srv *Server) Broadcast(protocol string, code uint64, data ...interface{}) { +func (srv *Server) Broadcast(protocol string, code uint64, data interface{}) error { var payload []byte if data != nil { - payload = common.Encode(data) + var err error + payload, err = rlp.EncodeToBytes(data) + if err != nil { + return err + } } srv.lock.RLock() defer srv.lock.RUnlock() @@ -146,6 +150,7 @@ func (srv *Server) Broadcast(protocol string, code uint64, data ...interface{}) peer.writeProtoMsg(protocol, msg) } } + return nil } // Start starts running the server. |