bridge

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

Documentation

Overview

Package bridge coordinates transaction bridging between source and target networks.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMode is returned when an invalid mode is specified
	ErrInvalidMode = errors.New("mode must be either 'p2p' or 'rpc'")
)
View Source
var (
	// ErrUnknownMode is returned when an unsupported mode is provided
	ErrUnknownMode = errors.New("unknown mode")
)

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Cfg Config
	// contains filtered or unexported fields
}

Bridge coordinates transaction flow from source to target networks.

func New

func New(log *logrus.Logger, conf *Config) *Bridge

New creates a new Bridge instance with the given logger and configuration.

func (*Bridge) ServeMetrics

func (b *Bridge) ServeMetrics(_ context.Context) error

ServeMetrics starts the metrics HTTP server.

func (*Bridge) Start

func (b *Bridge) Start(ctx context.Context) error

Start initializes and starts all bridge components.

type Config

type Config struct {
	LoggingLevel string        `yaml:"logging" default:"info"`
	MetricsAddr  string        `yaml:"metricsAddr" default:":9090"`
	Mode         Mode          `yaml:"mode" default:"p2p"`
	Source       source.Config `yaml:"source"`
	Target       target.Config `yaml:"target"`
}

Config holds the bridge configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the bridge configuration.

type Metrics

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

Metrics provides Prometheus metrics for the bridge.

func NewMetrics

func NewMetrics(namespace string) *Metrics

NewMetrics creates a new Metrics instance.

func NewMetricsWithRegisterer added in v0.2.0

func NewMetricsWithRegisterer(namespace string, registerer prometheus.Registerer) *Metrics

NewMetricsWithRegisterer creates a new Metrics instance with a custom registerer. Pass nil to skip metrics registration (useful for tests).

func (*Metrics) AddTransactions

func (m *Metrics) AddTransactions(count int)

AddTransactions increments the transaction counter by the given count.

type Mode added in v0.2.0

type Mode string

Mode defines the bridge operation mode

const (
	// ModeP2P uses devp2p protocol for transaction bridging
	ModeP2P Mode = "p2p"
	// ModeRPC uses JSON-RPC for transaction bridging
	ModeRPC Mode = "rpc"
)

type SourceCoordinator added in v0.2.0

type SourceCoordinator interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

SourceCoordinator defines the interface for source coordinators

type TargetCoordinator added in v0.2.0

type TargetCoordinator interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	SendTransactionsToPeers(ctx context.Context, transactions *mimicry.Transactions) error
}

TargetCoordinator defines the interface for target coordinators

Directories

Path Synopsis
Package source provides transaction source implementations for the bridge.
Package source provides transaction source implementations for the bridge.
cache
Package cache provides caching mechanisms for transaction deduplication and tracking.
Package cache provides caching mechanisms for transaction deduplication and tracking.
p2p
Package p2p provides P2P-based transaction source functionality.
Package p2p provides P2P-based transaction source functionality.
rpc
Package rpc provides RPC-based transaction source functionality.
Package rpc provides RPC-based transaction source functionality.
Package target provides transaction target implementations for the bridge.
Package target provides transaction target implementations for the bridge.
p2p
Package p2p provides P2P-based transaction target functionality.
Package p2p provides P2P-based transaction target functionality.
rpc
Package rpc provides RPC-based transaction target functionality.
Package rpc provides RPC-based transaction target functionality.

Jump to

Keyboard shortcuts

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