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

Documentation

Overview

Package p2p provides P2P-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")
	// 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 target peers.

func NewCoordinator

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

NewCoordinator creates a new P2P target coordinator.

func (*Coordinator) SendTransactionsToPeers

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

SendTransactionsToPeers sends transactions to all connected P2P target peers.

func (*Coordinator) Start

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

Start starts all configured P2P target 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 target connection to a single node.

func NewPeer

func NewPeer(ctx context.Context, log logrus.FieldLogger, nodeRecord string) (*Peer, error)

NewPeer creates a new P2P target peer.

func (*Peer) SendTransactions

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

SendTransactions sends transactions to the peer.

func (*Peer) Start

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

Start starts the peer connection.

func (*Peer) Stop

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

Stop stops the peer and cleans up resources.

Jump to

Keyboard shortcuts

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