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

package v4wire

import "github.com/ethereum/go-ethereum/p2p/discover/v4wire"

Package v4wire implements the Discovery v4 Wire Protocol.

Index

Package Files

v4wire.go

Constants

const (
    PingPacket = iota + 1 // zero is 'reserved'
    PongPacket
    FindnodePacket
    NeighborsPacket
    ENRRequestPacket
    ENRResponsePacket
)

RPC packet types

const MaxNeighbors = 12

This number is the maximum number of neighbor nodes in a Neigbors packet.

Variables

var (
    ErrPacketTooSmall = errors.New("too small")
    ErrBadHash        = errors.New("bad hash")
    ErrBadPoint       = errors.New("invalid curve point")
)

func Decode Uses

func Decode(input []byte) (Packet, Pubkey, []byte, error)

Decode reads a discovery v4 packet.

func DecodePubkey Uses

func DecodePubkey(curve elliptic.Curve, e Pubkey) (*ecdsa.PublicKey, error)

DecodePubkey reads an encoded secp256k1 public key.

func Encode Uses

func Encode(priv *ecdsa.PrivateKey, req Packet) (packet, hash []byte, err error)

Encode encodes a discovery packet.

func Expired Uses

func Expired(ts uint64) bool

Expired checks whether the given UNIX time stamp is in the past.

type ENRRequest Uses

type ENRRequest struct {
    Expiration uint64
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

enrRequest queries for the remote node's record.

func (*ENRRequest) Kind Uses

func (req *ENRRequest) Kind() byte

func (*ENRRequest) Name Uses

func (req *ENRRequest) Name() string

type ENRResponse Uses

type ENRResponse struct {
    ReplyTok []byte // Hash of the enrRequest packet.
    Record   enr.Record
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

enrResponse is the reply to enrRequest.

func (*ENRResponse) Kind Uses

func (req *ENRResponse) Kind() byte

func (*ENRResponse) Name Uses

func (req *ENRResponse) Name() string

type Endpoint Uses

type Endpoint struct {
    IP  net.IP // len 4 for IPv4 or 16 for IPv6
    UDP uint16 // for discovery protocol
    TCP uint16 // for RLPx protocol
}

Endpoint represents a network endpoint.

func NewEndpoint Uses

func NewEndpoint(addr *net.UDPAddr, tcpPort uint16) Endpoint

NewEndpoint creates an endpoint.

type Findnode Uses

type Findnode struct {
    Target     Pubkey
    Expiration uint64
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

Findnode is a query for nodes close to the given target.

func (*Findnode) Kind Uses

func (req *Findnode) Kind() byte

func (*Findnode) Name Uses

func (req *Findnode) Name() string

type Neighbors Uses

type Neighbors struct {
    Nodes      []Node
    Expiration uint64
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

Neighbors is the reply to findnode.

func (*Neighbors) Kind Uses

func (req *Neighbors) Kind() byte

func (*Neighbors) Name Uses

func (req *Neighbors) Name() string

type Node Uses

type Node struct {
    IP  net.IP // len 4 for IPv4 or 16 for IPv6
    UDP uint16 // for discovery protocol
    TCP uint16 // for RLPx protocol
    ID  Pubkey
}

Node represents information about a node.

type Packet Uses

type Packet interface {
    // packet name and type for logging purposes.
    Name() string
    Kind() byte
}

type Ping Uses

type Ping struct {
    Version    uint
    From, To   Endpoint
    Expiration uint64
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

RPC request structures

func (*Ping) ENRSeq Uses

func (req *Ping) ENRSeq() uint64

func (*Ping) Kind Uses

func (req *Ping) Kind() byte

func (*Ping) Name Uses

func (req *Ping) Name() string

type Pong Uses

type Pong struct {
    // This field should mirror the UDP envelope address
    // of the ping packet, which provides a way to discover the
    // the external address (after NAT).
    To         Endpoint
    ReplyTok   []byte // This contains the hash of the ping packet.
    Expiration uint64 // Absolute timestamp at which the packet becomes invalid.
    // Ignore additional fields (for forward compatibility).
    Rest []rlp.RawValue `rlp:"tail"`
}

Pong is the reply to ping.

func (*Pong) ENRSeq Uses

func (req *Pong) ENRSeq() uint64

func (*Pong) Kind Uses

func (req *Pong) Kind() byte

func (*Pong) Name Uses

func (req *Pong) Name() string

type Pubkey Uses

type Pubkey [64]byte

Pubkey represents an encoded 64-byte secp256k1 public key.

func EncodePubkey Uses

func EncodePubkey(key *ecdsa.PublicKey) Pubkey

EncodePubkey encodes a secp256k1 public key.

func (Pubkey) ID Uses

func (e Pubkey) ID() enode.ID

ID returns the node ID corresponding to the public key.

Package v4wire imports 13 packages (graph) and is imported by 8 packages. Updated 2020-06-25. Refresh now. Tools for package owners.