aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/message.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-01-06 20:13:16 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-01-06 20:13:16 +0800
commit3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c (patch)
treecf9e8919920cfc3a3ea776bfd1d04442d05efdaf /p2p/message.go
parent117f66e82375b752cc6a9ff22aa0d398ac337bb4 (diff)
parent3caa4ad1baba3019c06733e1a80d78d9a57137bb (diff)
downloaddexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.gz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.bz2
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.lz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.xz
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.tar.zst
dexon-3b8725e0f5622733dcb6c3ec142a83ddbb94bd6c.zip
Merge pull request #239 from fjl/grab-bag
Grab bag of fixes
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 {