go-ethereum: github.com/ethereum/go-ethereum/p2p/rlpx Index | Files

package rlpx

import "github.com/ethereum/go-ethereum/p2p/rlpx"

Package rlpx implements the RLPx transport protocol.


Package Files


type Conn Uses

type Conn struct {
    // contains filtered or unexported fields

Conn is an RLPx network connection. It wraps a low-level network connection. The underlying connection should not be used for other activity when it is wrapped by Conn.

Before sending messages, a handshake must be performed by calling the Handshake method. This type is not generally safe for concurrent use, but reading and writing of messages may happen concurrently after the handshake.

func NewConn Uses

func NewConn(conn net.Conn, dialDest *ecdsa.PublicKey) *Conn

NewConn wraps the given network connection. If dialDest is non-nil, the connection behaves as the initiator during the handshake.

func (*Conn) Close Uses

func (c *Conn) Close() error

Close closes the underlying network connection.

func (*Conn) Handshake Uses

func (c *Conn) Handshake(prv *ecdsa.PrivateKey) (*ecdsa.PublicKey, error)

Handshake performs the handshake. This must be called before any data is written or read from the connection.

func (*Conn) InitWithSecrets Uses

func (c *Conn) InitWithSecrets(sec Secrets)

InitWithSecrets injects connection secrets as if a handshake had been performed. This cannot be called after the handshake.

func (*Conn) Read Uses

func (c *Conn) Read() (code uint64, data []byte, wireSize int, err error)

Read reads a message from the connection.

func (*Conn) SetDeadline Uses

func (c *Conn) SetDeadline(time time.Time) error

SetDeadline sets the deadline for all future read and write operations.

func (*Conn) SetReadDeadline Uses

func (c *Conn) SetReadDeadline(time time.Time) error

SetReadDeadline sets the deadline for all future read operations.

func (*Conn) SetSnappy Uses

func (c *Conn) SetSnappy(snappy bool)

SetSnappy enables or disables snappy compression of messages. This is usually called after the devp2p Hello message exchange when the negotiated version indicates that compression is available on both ends of the connection.

func (*Conn) SetWriteDeadline Uses

func (c *Conn) SetWriteDeadline(time time.Time) error

SetWriteDeadline sets the deadline for all future write operations.

func (*Conn) Write Uses

func (c *Conn) Write(code uint64, data []byte) (uint32, error)

Write writes a message to the connection.

Write returns the written size of the message data. This may be less than or equal to len(data) depending on whether snappy compression is enabled.

type Secrets Uses

type Secrets struct {
    AES, MAC              []byte
    EgressMAC, IngressMAC hash.Hash
    // contains filtered or unexported fields

Secrets represents the connection secrets which are negotiated during the handshake.

Package rlpx imports 20 packages (graph) and is imported by 14 packages. Updated 2020-09-22. Refresh now. Tools for package owners.