p2p

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: 15 Imported by: 0

Documentation

Overview

Package p2p provides P2P-based transaction source functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigRequired is returned when config is nil
	ErrConfigRequired = errors.New("config is required")
	// ErrPeerDisconnected is returned when peer disconnects
	ErrPeerDisconnected = errors.New("disconnected from peer")
)

Functions

This section is empty.

Types

type Coordinator

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

Coordinator manages multiple P2P source peers.

func NewCoordinator

func NewCoordinator(config *source.Config, broadcast func(ctx context.Context, transactions *mimicry.Transactions) error, log logrus.FieldLogger) (*Coordinator, error)

NewCoordinator creates a new P2P coordinator.

func (*Coordinator) Start

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

Start starts all configured P2P source peers.

func (*Coordinator) Stop

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

Stop stops the coordinator and all peers.

type CoordinatorStatus

type CoordinatorStatus struct {
	ConnectedPeers    int
	DisconnectedPeers int
}

CoordinatorStatus tracks peer connection status.

type Peer

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

Peer represents a P2P source connection to a single node.

func NewPeer

func NewPeer(ctx context.Context, log logrus.FieldLogger, nodeRecord string, handler func(ctx context.Context, transactions *mimicry.Transactions) error, sharedCache *cache.SharedCache, txFilterConfig *source.TransactionFilterConfig, metrics *source.Metrics) (*Peer, error)

NewPeer creates a new P2P source peer.

func (*Peer) ExportBlobTransactions

func (p *Peer) ExportBlobTransactions(ctx context.Context, items []*common.Hash) error

ExportBlobTransactions handles blob transactions with priority

func (*Peer) ExportNormalTransactions

func (p *Peer) ExportNormalTransactions(ctx context.Context, items []*common.Hash) error

ExportNormalTransactions handles non-blob transactions

func (*Peer) Start

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

Start begins the P2P peer connection and subscribes to transaction events

func (*Peer) Stop

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

Stop stops the peer and cleans up resources.

type TransactionExporter

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

TransactionExporter exports batched transaction hashes for processing.

func NewTransactionExporter

func NewTransactionExporter(log logrus.FieldLogger, handler func(ctx context.Context, items []*common.Hash) error) (TransactionExporter, error)

NewTransactionExporter creates a new transaction exporter.

func (TransactionExporter) ExportItems

func (t TransactionExporter) ExportItems(ctx context.Context, items []*common.Hash) error

ExportItems exports a batch of transaction hashes.

func (TransactionExporter) Shutdown

func (t TransactionExporter) Shutdown(_ context.Context) error

Shutdown handles cleanup for the exporter.

type TransactionTypeHash

type TransactionTypeHash struct {
	Hash common.Hash
	Type byte
}

TransactionTypeHash maps a transaction hash to its type.

Jump to

Keyboard shortcuts

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