brontide: add new ReadMessage method to brontide.Conn

This commit adds a new message to the brontide.Conn struct which allows
callers to read an _entire_ message from the stream. As defined now,
brontide is a message crypto messaging protocol. Previously the only
method that allowed callers to read attempted to hide this feature with
a stream-like abstraction. However, having this as the sole interface
is at odds with the message oriented Lightning wire protocol, and isn’t
sufficient to allow parsing messages that have been padded as is
allowed by the protocol.

This new ReadNextMessage is intended to be used by higher level systems
which implement the Lightning p2p protocol.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-04-20 15:35:35 -07:00
1 parent f867252139
commit 38d3c72dc8
2 files changed
+13 -5

No files matched your search

+1
View File
@@ -686,5 +686,6 @@ func (b *Machine) ReadMessage(r io.Reader) ([]byte, error) {
return nil, err
}
// TODO(roasbeef): modify to let pass in slice
return b.recvCipher.Decrypt(nil, nil, cipherText[:pktLen])
}