rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package rpc provides RPC-based transaction target functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigRequired is returned when config is nil
	ErrConfigRequired = errors.New("config is required")
	// ErrRPCEndpointsRequired is returned when rpcEndpoints is empty
	ErrRPCEndpointsRequired = errors.New("rpcEndpoints is required")
)
View Source
var (
	// ErrAllTransactionsFailed is returned when all transactions fail to send
	ErrAllTransactionsFailed = errors.New("all transactions failed to send")
)

Functions

This section is empty.

Types

type Coordinator

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

Coordinator manages multiple RPC peer connections for sending transactions

func NewCoordinator

func NewCoordinator(config *target.Config, log logrus.FieldLogger) (*Coordinator, error)

NewCoordinator creates a new RPC target coordinator

func (*Coordinator) SendTransactionsToPeers

func (c *Coordinator) SendTransactionsToPeers(ctx context.Context, transactions *mimicry.Transactions) error

SendTransactionsToPeers sends transactions to all connected RPC peers

func (*Coordinator) Start

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

Start begins the RPC coordinator

func (*Coordinator) Stop

func (c *Coordinator) Stop(_ context.Context) error

Stop stops the RPC coordinator

type CoordinatorStatus

type CoordinatorStatus struct {
	ConnectedPeers    int
	DisconnectedPeers int
}

CoordinatorStatus represents the status of the RPC coordinator

type Peer

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

Peer represents an RPC connection to an Ethereum node for sending transactions

func NewPeer

func NewPeer(_ context.Context, log logrus.FieldLogger, rpcEndpoint string, sendConcurrency int) (*Peer, error)

NewPeer creates a new RPC target peer

func (*Peer) SendTransactions

func (p *Peer) SendTransactions(ctx context.Context, transactions *mimicry.Transactions) (*SendResult, error)

SendTransactions sends transactions via RPC concurrently

func (*Peer) Start

func (p *Peer) Start(ctx context.Context) (<-chan error, error)

Start initializes the RPC connection

func (*Peer) Stop

func (p *Peer) Stop(_ context.Context) error

Stop closes the RPC connection

type SendResult

type SendResult struct {
	AcceptedByType map[uint8]int // Count of truly accepted transactions by type (not AlreadyKnown)
	TotalSent      int
}

SendResult contains the results of sending transactions

Jump to

Keyboard shortcuts

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