aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/server.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/server.go
parent4811f460e7aad37c6c6867df0461a5fa162b5f2c (diff)
downloadgo-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar
go-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.gz
go-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.bz2
go-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.lz
go-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.xz
go-tangerine-5ba51594c7eb1f04b3636e6413de6d4eb70228d2.tar.zst
go-tangerine-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.go11
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.