Documentation ¶
Overview ¶
Package v4wire implements the Discovery v4 Wire Protocol.
Index ¶
- Constants
- Variables
- func Decode(input []byte) (Packet, Pubkey, []byte, error)
- func DecodePubkey(e Pubkey) (*signaturealgorithm.PublicKey, error)
- func Encode(priv *signaturealgorithm.PrivateKey, req Packet) (packet, hash []byte, err error)
- func Expired(ts uint64) bool
- func WirePubKeyEquals(pub1 Pubkey, pub2 Pubkey) bool
- type ENRRequest
- type ENRResponse
- type Endpoint
- type Findnode
- type Neighbors
- type Node
- type Packet
- type Ping
- type Pong
- type Pubkey
Constants ¶
View Source
const ( PingPacket = iota + 1 // zero is 'reserved' PongPacket FindnodePacket NeighborsPacket ENRRequestPacket ENRResponsePacket )
RPC packet types
View Source
const MaxNeighbors = 1
This number is the maximum number of neighbor nodes in a Neigbors packet.
Variables ¶
Functions ¶
func DecodePubkey ¶
func DecodePubkey(e Pubkey) (*signaturealgorithm.PublicKey, error)
func Encode ¶
func Encode(priv *signaturealgorithm.PrivateKey, req Packet) (packet, hash []byte, err error)
Encode encodes a discovery packet.
func WirePubKeyEquals ¶
Types ¶
type ENRRequest ¶
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 ¶
func (req *ENRRequest) Kind() byte
func (*ENRRequest) Name ¶
func (req *ENRRequest) Name() string
type ENRResponse ¶
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 ¶
func (req *ENRResponse) Kind() byte
func (*ENRResponse) Name ¶
func (req *ENRResponse) Name() string
type Endpoint ¶
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.
type Findnode ¶
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.
type Neighbors ¶
type Neighbors struct { Nodes []Node Expiration uint64 // Ignore additional fields (for forward compatibility). Rest []rlp.RawValue `rlp:"tail"` }
Neighbors is the reply to findnode.
type Node ¶
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 Ping ¶
type Ping struct { Version uint From, To Endpoint Expiration uint64 ENRSeq uint64 `rlp:"optional"` // Sequence number of local record, added by EIP-868. // Ignore additional fields (for forward compatibility). Rest []rlp.RawValue `rlp:"tail"` }
RPC request structures
type Pong ¶
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. ENRSeq uint64 `rlp:"optional"` // Sequence number of local record, added by EIP-868. // Ignore additional fields (for forward compatibility). Rest []rlp.RawValue `rlp:"tail"` }
Pong is the reply to ping.
type Pubkey ¶
type Pubkey struct {
PubBytes []byte
}
func CreateWirePubKey ¶
func CreateWirePubKeyFromSigAlg ¶
func CreateWirePubKeyFromSigAlg(pubKey *signaturealgorithm.PublicKey) Pubkey
func EncodePubkey ¶
func EncodePubkey(key *signaturealgorithm.PublicKey) Pubkey
EncodePubkey encodes a secp256k1 public key.
Click to show internal directories.
Click to hide internal directories.