package util
import "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/util"
Index ¶
- func NewDelimitedWriter(w io.Writer) pbio.WriteCloser
- func PeerInfoToPeerV2(pi peer.AddrInfo) *pbv2.Peer
- func PeerToPeerInfoV2(p *pbv2.Peer) (peer.AddrInfo, error)
- type DelimitedReader
Functions ¶
func NewDelimitedWriter ¶
func NewDelimitedWriter(w io.Writer) pbio.WriteCloser
func PeerInfoToPeerV2 ¶
func PeerToPeerInfoV2 ¶
Types ¶
type DelimitedReader ¶
type DelimitedReader struct {
// contains filtered or unexported fields
}
func NewDelimitedReader ¶
func NewDelimitedReader(r io.Reader, maxSize int) *DelimitedReader
The gogo protobuf NewDelimitedReader is buffered, which may eat up stream data. So we need to implement a compatible delimited reader that reads unbuffered. There is a slowdown from unbuffered reading: when reading the message it can take multiple single byte Reads to read the length and another Read to read the message payload. However, this is not critical performance degradation as
- the reader is utilized to read one (dialer, stop) or two messages (hop) during the handshake, so it's a drop in the water for the connection lifetime.
- messages are small (max 4k) and the length fits in a couple of bytes, so overall we have at most three reads per message.
func (*DelimitedReader) Close ¶
func (d *DelimitedReader) Close()
func (*DelimitedReader) ReadByte ¶
func (d *DelimitedReader) ReadByte() (byte, error)
func (*DelimitedReader) ReadMsg ¶
func (d *DelimitedReader) ReadMsg(msg proto.Message) error
Source Files ¶
- Version
- v0.41.1 (latest)
- Published
- Mar 24, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 2 weeks ago –
Tools for package owners.