p2p

package
v0.1.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(n *enode.Node) (*rlpxConn, error)

Dial attempts to Dial the given node and perform a handshake, returning the created Conn if successful.

func Listen added in v0.1.21

func Listen(ln *enode.LocalNode) (*net.UDPConn, error)

func NewEthProtocol added in v0.1.36

func NewEthProtocol(version uint, opts EthProtocolOptions) ethp2p.Protocol

NewEthProctocol creates the new eth protocol. This will handle writing the status exchange, message handling, and writing blocks/txs to the database.

func ParseBootnodes

func ParseBootnodes(bootnodes string) ([]*enode.Node, error)

ParseBootnodes parses the bootnodes string and returns a node slice.

func ParseNode

func ParseNode(source string) (*enode.Node, error)

ParseNode parses a node record and verifies its signature.

func ReadNodeSet added in v0.1.32

func ReadNodeSet(file string) ([]*enode.Node, error)

ReadNodeSet parses a list of discovery node URLs loaded from a JSON file.

func WriteNodeSet added in v0.1.32

func WriteNodeSet(file string, nodes NodeSet) error

WriteNodeSet writes the node set as a JSON list of URLs to a file.

Types

type AccountRange

type AccountRange snap.AccountRangePacket

func (AccountRange) Code

func (msg AccountRange) Code() int

func (AccountRange) ReqID

func (msg AccountRange) ReqID() uint64

type BlockBodies

type BlockBodies eth.BlockBodiesPacket

BlockBodies is the network packet for block content distribution.

func (BlockBodies) Code

func (msg BlockBodies) Code() int

func (BlockBodies) ReqID

func (msg BlockBodies) ReqID() uint64

type BlockHeaders

type BlockHeaders eth.BlockHeadersPacket

func (BlockHeaders) Code

func (msg BlockHeaders) Code() int

func (BlockHeaders) ReqID

func (msg BlockHeaders) ReqID() uint64

type ByteCodes

type ByteCodes snap.ByteCodesPacket

func (ByteCodes) Code

func (msg ByteCodes) Code() int

func (ByteCodes) ReqID

func (msg ByteCodes) ReqID() uint64

type Disconnect

type Disconnect struct {
	Reason p2p.DiscReason
}

Disconnect is the RLP structure for a disconnect message.

func (Disconnect) Code

func (msg Disconnect) Code() int

func (Disconnect) ReqID

func (msg Disconnect) ReqID() uint64

type Disconnects

type Disconnects []p2p.DiscReason

Disconnects is the RLP structure for disconnect messages.

func (Disconnects) Code

func (msg Disconnects) Code() int

func (Disconnects) ReqID

func (msg Disconnects) ReqID() uint64

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Code

func (e *Error) Code() int

func (*Error) Error

func (e *Error) Error() string

func (*Error) ReqID

func (e *Error) ReqID() uint64

func (*Error) String

func (e *Error) String() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type EthProtocolOptions added in v0.1.36

type EthProtocolOptions struct {
	Context     context.Context
	Database    database.Database
	GenesisHash common.Hash
	RPC         string
	SensorID    string
	NetworkID   uint64
	Peers       chan *enode.Node
	ForkID      forkid.ID
	MsgCounter  *prometheus.CounterVec

	// Head keeps track of the current head block of the chain. This is required
	// when doing the status exchange.
	Head      *HeadBlock
	HeadMutex *sync.RWMutex
}

EthProtocolOptions is the options used when creating a new eth protocol.

type GetAccountRange

type GetAccountRange snap.GetAccountRangePacket

GetAccountRange represents an account range query.

func (GetAccountRange) Code

func (msg GetAccountRange) Code() int

func (GetAccountRange) ReqID

func (msg GetAccountRange) ReqID() uint64

type GetBlockBodies

type GetBlockBodies eth.GetBlockBodiesPacket

GetBlockBodies represents a GetBlockBodies request

func (GetBlockBodies) Code

func (msg GetBlockBodies) Code() int

func (GetBlockBodies) ReqID

func (msg GetBlockBodies) ReqID() uint64

type GetBlockHeaders

type GetBlockHeaders eth.GetBlockHeadersPacket

GetBlockHeaders represents a block header query.

func (GetBlockHeaders) Code

func (msg GetBlockHeaders) Code() int

func (GetBlockHeaders) ReqID

func (msg GetBlockHeaders) ReqID() uint64

type GetByteCodes

type GetByteCodes snap.GetByteCodesPacket

func (GetByteCodes) Code

func (msg GetByteCodes) Code() int

func (GetByteCodes) ReqID

func (msg GetByteCodes) ReqID() uint64

type GetPooledTransactions

type GetPooledTransactions eth.GetPooledTransactionsPacket

func (GetPooledTransactions) Code

func (msg GetPooledTransactions) Code() int

func (GetPooledTransactions) ReqID

func (msg GetPooledTransactions) ReqID() uint64

type GetStorageRanges

type GetStorageRanges snap.GetStorageRangesPacket

func (GetStorageRanges) Code

func (msg GetStorageRanges) Code() int

func (GetStorageRanges) ReqID

func (msg GetStorageRanges) ReqID() uint64

type GetTrieNodes

type GetTrieNodes snap.GetTrieNodesPacket

func (GetTrieNodes) Code

func (msg GetTrieNodes) Code() int

func (GetTrieNodes) ReqID

func (msg GetTrieNodes) ReqID() uint64

type HeadBlock added in v0.1.32

type HeadBlock struct {
	Hash            common.Hash
	TotalDifficulty *big.Int
	Number          uint64
	Time            uint64
}

HeadBlock contains the necessary head block data for the status message.

type Hello

type Hello struct {
	Version    uint64
	Name       string
	Caps       []p2p.Cap
	ListenPort uint64
	ID         []byte // secp256k1 public key

	// Ignore additional fields (for forward compatibility).
	Rest []rlp.RawValue `rlp:"tail"`
}

Hello is the RLP structure of the protocol handshake.

func (Hello) Code

func (msg Hello) Code() int

func (Hello) ReqID

func (msg Hello) ReqID() uint64

type Message

type Message interface {
	Code() int
	ReqID() uint64
}

type MessageCount added in v0.1.21

type MessageCount struct {
	BlockHeaders        int32 `json:",omitempty"`
	BlockBodies         int32 `json:",omitempty"`
	Blocks              int32 `json:",omitempty"`
	BlockHashes         int32 `json:",omitempty"`
	BlockHeaderRequests int32 `json:",omitempty"`
	BlockBodiesRequests int32 `json:",omitempty"`
	Transactions        int32 `json:",omitempty"`
	TransactionHashes   int32 `json:",omitempty"`
	TransactionRequests int32 `json:",omitempty"`
	Pings               int32 `json:",omitempty"`
	Errors              int32 `json:",omitempty"`
	Disconnects         int32 `json:",omitempty"`
}

MessageCount is used to help the outer goroutine to receive summary of the number and type of messages that were sent. This is used for distributed logging. It can be used to count the different types of messages received across all peer connections to provide a summary.

func (*MessageCount) Clear added in v0.1.32

func (count *MessageCount) Clear()

Clear clears all of the counts from the message counter.

func (*MessageCount) IsEmpty added in v0.1.32

func (c *MessageCount) IsEmpty() bool

IsEmpty checks whether the sum of all the counts is empty. Make sure to call Load before this method to get an accurate count.

func (*MessageCount) Load added in v0.1.32

func (count *MessageCount) Load() MessageCount

Load takes a snapshot of all the counts in a thread-safe manner. Make sure you call this and read from the returned object.

type NewBlock

type NewBlock eth.NewBlockPacket

NewBlock is the network packet for the block propagation message.

func (NewBlock) Code

func (msg NewBlock) Code() int

func (NewBlock) ReqID

func (msg NewBlock) ReqID() uint64

type NewBlockHashes

type NewBlockHashes eth.NewBlockHashesPacket

NewBlockHashes is the network packet for the block announcements.

func (NewBlockHashes) Code

func (msg NewBlockHashes) Code() int

func (NewBlockHashes) ReqID

func (msg NewBlockHashes) ReqID() uint64

type NewPooledTransactionHashes added in v0.1.21

type NewPooledTransactionHashes struct {
	Types  []byte
	Sizes  []uint32
	Hashes []common.Hash
}

NewPooledTransactionHashes is the network packet for the tx hash propagation message.

func (NewPooledTransactionHashes) Code added in v0.1.21

func (msg NewPooledTransactionHashes) Code() int

func (NewPooledTransactionHashes) ReqID added in v0.1.21

func (msg NewPooledTransactionHashes) ReqID() uint64

type NewPooledTransactionHashes66 added in v0.1.21

type NewPooledTransactionHashes66 []common.Hash

NewPooledTransactionHashes66 is the network packet for the tx hash propagation message.

func (NewPooledTransactionHashes66) Code added in v0.1.21

func (msg NewPooledTransactionHashes66) Code() int

func (NewPooledTransactionHashes66) ReqID added in v0.1.21

type NodeSet

type NodeSet map[enode.ID]string

NodeSet is the mapping of the node ID to the URL. This is used in the p2p ping, crawl, and sensor commands. When written this should be consistent with the geth/bor static-nodes.json file format which is just an JSON string array of URLs.

type Ping

type Ping struct{}

func (Ping) Code

func (msg Ping) Code() int

func (Ping) ReqID

func (msg Ping) ReqID() uint64

type Pong

type Pong struct{}

func (Pong) Code

func (msg Pong) Code() int

func (Pong) ReqID

func (msg Pong) ReqID() uint64

type PooledTransactions

type PooledTransactions eth.PooledTransactionsPacket

func (PooledTransactions) Code

func (msg PooledTransactions) Code() int

func (PooledTransactions) ReqID

func (msg PooledTransactions) ReqID() uint64

type Status

type Status eth.StatusPacket

Status is the network packet for the status message for eth/64 and later.

func (Status) Code

func (msg Status) Code() int

func (Status) ReqID

func (msg Status) ReqID() uint64

type StorageRanges

type StorageRanges snap.StorageRangesPacket

func (StorageRanges) Code

func (msg StorageRanges) Code() int

func (StorageRanges) ReqID

func (msg StorageRanges) ReqID() uint64

type Transactions

type Transactions eth.TransactionsPacket

func (Transactions) Code

func (msg Transactions) Code() int

func (Transactions) ReqID

func (msg Transactions) ReqID() uint64

type TrieNodes

type TrieNodes snap.TrieNodesPacket

func (TrieNodes) Code

func (msg TrieNodes) Code() int

func (TrieNodes) ReqID

func (msg TrieNodes) ReqID() uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL