Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMsgExceedsMaxSize = errors.New("message exceeds max size")
ErrMsgExceedsMaxSize is returned by ReadMsg when the declared message length exceeds the reader's maxSize. Callers that pass a maxSize to bound what an unauthenticated peer can make them allocate can classify the rejection with errors.Is instead of matching on the message text.
Functions ¶
Types ¶
type ReadCloser ¶
func NewDelimitedReader ¶
func NewDelimitedReader(r io.Reader, maxSize int) ReadCloser
NewDelimitedReader reads varint-delimited Protobuf messages from a reader. Unlike the gogoproto NewDelimitedReader, this does not buffer the reader, which may cause poor performance but is necessary when only reading single messages (e.g. in the p2p package). It also returns the number of bytes read, which is necessary for the p2p package.
type WriteCloser ¶
func NewDelimitedWriter ¶
func NewDelimitedWriter(w io.Writer) WriteCloser
NewDelimitedWriter writes a varint-delimited Protobuf message to a writer. It is equivalent to the gogoproto NewDelimitedWriter, except WriteMsg() also returns the number of bytes written, which is necessary in the p2p package.