mimicry

package
v0.0.0-...-be891b9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 23 Imported by: 8

Documentation

Overview

eth protocol block bodies https://github.com/ethereum/devp2p/blob/master/caps/eth.md#blockbodies-0x06

eth protocol block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#blockheaders-0x04

eth protocol block receipts https://github.com/ethereum/devp2p/blob/master/caps/eth.md#blockreceipts-0x06

RLPx disconnect https://github.com/ethereum/devp2p/blob/master/rlpx.md#disconnect-0x01

eth protocol get get block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockbodies-0x05

eth protocol get get block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockheaders-0x03

eth protocol get get block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockheaders-0x03

eth protocol get get block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockreceipts-0x05

RLPx hello https://github.com/ethereum/devp2p/blob/master/rlpx.md#hello-0x00

eth protocol new pooled transaction hashes https://github.com/ethereum/devp2p/blob/master/caps/eth.md#newpooledtransactionhashes-0x08

RLPx ping https://github.com/ethereum/devp2p/blob/master/rlpx.md#ping-0x02

RLPx pong https://github.com/ethereum/devp2p/blob/master/rlpx.md#pong-0x03

eth protocol get get block headers https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockheaders-0x03

eth protocol block receipts https://github.com/ethereum/devp2p/blob/master/caps/eth.md#blockreceipts-0x06

eth protocol status https://github.com/ethereum/devp2p/blob/master/caps/eth.md#status-0x00

eth protocol transactions https://github.com/ethereum/devp2p/blob/master/caps/eth.md#transactions-0x02

Index

Constants

View Source
const (
	HelloCode          = 0x00
	P2PProtocolVersion = 5

	ETHCapName = "eth"
)
View Source
const (
	BlockBodiesCode = RLPXOffset + eth.BlockBodiesMsg
)
View Source
const (
	BlockHeadersCode = RLPXOffset + eth.BlockHeadersMsg
)
View Source
const (
	BlockRangeUpdateCode = RLPXOffset + eth.BlockRangeUpdateMsg
)
View Source
const (
	DisconnectCode = 0x01
)
View Source
const (
	GetBlockBodiesCode = RLPXOffset + eth.GetBlockBodiesMsg
)
View Source
const (
	GetBlockHeadersCode = RLPXOffset + eth.GetBlockHeadersMsg
)
View Source
const (
	GetPooledTransactionsCode = RLPXOffset + eth.GetPooledTransactionsMsg
)
View Source
const (
	GetReceiptsCode = RLPXOffset + eth.GetReceiptsMsg
)
View Source
const (
	NewPooledTransactionHashesCode = RLPXOffset + eth.NewPooledTransactionHashesMsg
)
View Source
const (
	PingCode = 0x02
)
View Source
const (
	PongCode = 0x03
)
View Source
const (
	PooledTransactionsCode = RLPXOffset + eth.PooledTransactionsMsg
)
View Source
const (
	ReceiptsCode = RLPXOffset + eth.ReceiptsMsg
)
View Source
const (
	StatusCode = RLPXOffset + eth.StatusMsg
)
View Source
const (
	TransactionsCode = RLPXOffset + eth.TransactionsMsg
)

Variables

This section is empty.

Functions

func SupportedEthCaps

func SupportedEthCaps() []p2p.Cap

Types

type BlockBodies

type BlockBodies eth.BlockBodiesPacket

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 BlockRangeUpdate

type BlockRangeUpdate eth.BlockRangeUpdatePacket

func (*BlockRangeUpdate) Code

func (msg *BlockRangeUpdate) Code() int

type BodyProvider

type BodyProvider func(ctx context.Context, hashes []common.Hash) ([]eth.BlockBody, error)

type Client

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

func New

func New(ctx context.Context, log logrus.FieldLogger, record, name string, opts ...Option) (*Client, error)

func (*Client) GetPooledTransactions

func (c *Client) GetPooledTransactions(ctx context.Context, hashes []common.Hash) (*PooledTransactions, error)

func (*Client) OnDisconnect

func (c *Client) OnDisconnect(ctx context.Context, handler func(ctx context.Context, reason *Disconnect) error)

func (*Client) OnHello

func (c *Client) OnHello(ctx context.Context, handler func(ctx context.Context, status *Hello) error)

func (*Client) OnNewPooledTransactionHashes

func (c *Client) OnNewPooledTransactionHashes(ctx context.Context, handler func(ctx context.Context, hashes *NewPooledTransactionHashes) error)

func (*Client) OnStatus

func (c *Client) OnStatus(ctx context.Context, handler func(ctx context.Context, status Status) error)

func (*Client) OnTransactions

func (c *Client) OnTransactions(ctx context.Context, handler func(ctx context.Context, transactions *Transactions) error)

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

func (*Client) Stop

func (c *Client) Stop(ctx context.Context) error

func (*Client) Transactions

func (c *Client) Transactions(ctx context.Context, transactions *Transactions) error

type Disconnect

type Disconnect struct {
	Reason p2p.DiscReason
}

func (*Disconnect) Code

func (h *Disconnect) Code() int

func (*Disconnect) ReqID

func (h *Disconnect) ReqID() uint64

type GetBlockBodies

type GetBlockBodies eth.GetBlockBodiesPacket

func (*GetBlockBodies) Code

func (msg *GetBlockBodies) Code() int

func (*GetBlockBodies) ReqID

func (msg *GetBlockBodies) ReqID() uint64

type GetBlockHeaders

type GetBlockHeaders eth.GetBlockHeadersPacket

func (*GetBlockHeaders) Code

func (msg *GetBlockHeaders) Code() int

func (*GetBlockHeaders) ReqID

func (msg *GetBlockHeaders) 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 GetReceipts

type GetReceipts eth.GetReceiptsPacket

func (*GetReceipts) Code

func (msg *GetReceipts) Code() int

func (*GetReceipts) ReceiptRequest

func (msg *GetReceipts) ReceiptRequest() ReceiptRequest

func (*GetReceipts) ReqID

func (msg *GetReceipts) ReqID() uint64

type GetReceipts70

type GetReceipts70 struct {
	GetReceipts70Packet
}

func (*GetReceipts70) Code

func (msg *GetReceipts70) Code() int

func (*GetReceipts70) ReceiptRequest

func (msg *GetReceipts70) ReceiptRequest() ReceiptRequest

func (*GetReceipts70) ReqID

func (msg *GetReceipts70) ReqID() uint64

type GetReceipts70Packet

type GetReceipts70Packet struct {
	RequestId              uint64
	FirstBlockReceiptIndex uint64
	eth.GetReceiptsRequest
}

type GetReceiptsMessage

type GetReceiptsMessage interface {
	Code() int
	ReqID() uint64
	ReceiptRequest() ReceiptRequest
}

type HeaderProvider

type HeaderProvider func(ctx context.Context, request *eth.GetBlockHeadersRequest) ([]*types.Header, error)

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"`
}

https://github.com/ethereum/go-ethereum/blob/master/cmd/devp2p/internal/ethtest/types.go

func (*Hello) Code

func (h *Hello) Code() int

func (*Hello) ETHCap

func (h *Hello) ETHCap() *p2p.Cap

func (*Hello) ETHProtocolVersion

func (h *Hello) ETHProtocolVersion() uint

func (*Hello) ReqID

func (h *Hello) ReqID() uint64

func (*Hello) Validate

func (h *Hello) Validate() error

type NewPooledTransactionHashes

type NewPooledTransactionHashes eth.NewPooledTransactionHashesPacket

func (*NewPooledTransactionHashes) Code

func (msg *NewPooledTransactionHashes) Code() int

func (*NewPooledTransactionHashes) ReqID

func (msg *NewPooledTransactionHashes) ReqID() uint64

type Option

type Option func(*Client)

func WithBodyProvider

func WithBodyProvider(provider BodyProvider) Option

func WithHeaderProvider

func WithHeaderProvider(provider HeaderProvider) Option

func WithPrivateKey

func WithPrivateKey(privateKey *ecdsa.PrivateKey) Option

func WithReceiptProvider

func WithReceiptProvider(provider ReceiptProvider) Option

func WithStatusProvider

func WithStatusProvider(provider StatusProvider) Option

type Ping

type Ping struct{}

func (*Ping) Code

func (h *Ping) Code() int

func (*Ping) ReqID

func (h *Ping) ReqID() uint64

type Pong

type Pong struct{}

func (*Pong) Code

func (h *Pong) Code() int

func (*Pong) ReqID

func (h *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 ReceiptProvider

type ReceiptProvider func(ctx context.Context, request ReceiptRequest) ([]*eth.ReceiptList, error)

type ReceiptRequest

type ReceiptRequest struct {
	Hashes                 []common.Hash
	FirstBlockReceiptIndex uint64
}

type Receipts

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

Receipts is a wrapper interface for ReceiptsPacket.

type Receipts69

type Receipts69 struct {
	eth.ReceiptsPacket
}

func (*Receipts69) Code

func (msg *Receipts69) Code() int

func (*Receipts69) ReqID

func (msg *Receipts69) ReqID() uint64

type Receipts70

type Receipts70 struct {
	Receipts70Packet
}

func (*Receipts70) Code

func (msg *Receipts70) Code() int

func (*Receipts70) ReqID

func (msg *Receipts70) ReqID() uint64

type Receipts70Packet

type Receipts70Packet struct {
	RequestId           uint64
	LastBlockIncomplete bool
	List                rlp.RawList[*eth.ReceiptList]
}

type Status

type Status interface {
	Code() int
	ReqID() uint64
	GetProtocolVersion() uint32
	GetGenesis() []byte
	GetHead() []byte
	GetNetworkID() uint64
	GetForkIDHash() []byte
	GetForkIDNext() uint64
}

Status is a wrapper interface for the StatusPacket.

type Status68

type Status68 struct {
	Status68Packet
}

func (*Status68) Code

func (msg *Status68) Code() int

func (*Status68) GetForkIDHash

func (msg *Status68) GetForkIDHash() []byte

func (*Status68) GetForkIDNext

func (msg *Status68) GetForkIDNext() uint64

func (*Status68) GetGenesis

func (msg *Status68) GetGenesis() []byte

func (*Status68) GetHead

func (msg *Status68) GetHead() []byte

func (*Status68) GetNetworkID

func (msg *Status68) GetNetworkID() uint64

func (*Status68) GetProtocolVersion

func (msg *Status68) GetProtocolVersion() uint32

func (*Status68) ReqID

func (msg *Status68) ReqID() uint64

type Status68Packet

type Status68Packet struct {
	ProtocolVersion uint32
	NetworkID       uint64
	TD              *big.Int
	Head            common.Hash
	Genesis         common.Hash
	ForkID          forkid.ID
}

type Status69

type Status69 struct {
	eth.StatusPacket
}

func (*Status69) Code

func (msg *Status69) Code() int

func (*Status69) GetForkIDHash

func (msg *Status69) GetForkIDHash() []byte

func (*Status69) GetForkIDNext

func (msg *Status69) GetForkIDNext() uint64

func (*Status69) GetGenesis

func (msg *Status69) GetGenesis() []byte

func (*Status69) GetHead

func (msg *Status69) GetHead() []byte

func (*Status69) GetNetworkID

func (msg *Status69) GetNetworkID() uint64

func (*Status69) GetProtocolVersion

func (msg *Status69) GetProtocolVersion() uint32

func (*Status69) ReqID

func (msg *Status69) ReqID() uint64

type StatusProvider

type StatusProvider func(ctx context.Context, protocolVersion uint, peerStatus Status) (Status, error)

type Transactions

type Transactions eth.TransactionsPacket

func (*Transactions) Code

func (msg *Transactions) Code() int

func (*Transactions) ReqID

func (msg *Transactions) ReqID() uint64

Jump to

Keyboard shortcuts

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