aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/message.go
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/message.go')
-rw-r--r--p2p/message.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/p2p/message.go b/p2p/message.go
index a6f62ec4c..daf2bf05c 100644
--- a/p2p/message.go
+++ b/p2p/message.go
@@ -71,14 +71,11 @@ type MsgReader interface {
}
type MsgWriter interface {
- // WriteMsg sends an existing message.
- // The Payload reader of the message is consumed.
+ // WriteMsg sends a message. It will block until the message's
+ // Payload has been consumed by the other end.
+ //
// Note that messages can be sent only once.
WriteMsg(Msg) error
-
- // EncodeMsg writes an RLP-encoded message with the given
- // code and data elements.
- EncodeMsg(code uint64, data ...interface{}) error
}
// MsgReadWriter provides reading and writing of encoded messages.
@@ -87,6 +84,12 @@ type MsgReadWriter interface {
MsgWriter
}
+// EncodeMsg writes an RLP-encoded message with the given code and
+// data elements.
+func EncodeMsg(w MsgWriter, code uint64, data ...interface{}) error {
+ return w.WriteMsg(NewMsg(code, data...))
+}
+
var magicToken = []byte{34, 64, 8, 145}
func writeMsg(w io.Writer, msg Msg) error {
@@ -209,11 +212,6 @@ func (p *MsgPipeRW) WriteMsg(msg Msg) error {
return ErrPipeClosed
}
-// EncodeMsg is a convenient shorthand for sending an RLP-encoded message.
-func (p *MsgPipeRW) EncodeMsg(code uint64, data ...interface{}) error {
- return p.WriteMsg(NewMsg(code, data...))
-}
-
// ReadMsg returns a message sent on the other end of the pipe.
func (p *MsgPipeRW) ReadMsg() (Msg, error) {
if atomic.LoadInt32(p.closed) == 0 {