Documentation
¶
Overview ¶
Package chainManager provides blockchain connection management for multichain operations. This package manages connections to multiple Ethereum-compatible blockchains, providing a unified interface for interacting with different Chains in the EigenLayer multichain ecosystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChainNotFound is returned when a requested chain ID is not found in the manager ErrChainNotFound = errors.New("chain not found") )
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// RPCClient is the active Ethereum client connection for this chain
RPCClient *ethclient.Client
// contains filtered or unexported fields
}
Chain represents an active connection to a blockchain. It contains both the configuration and the active RPC client connection.
type ChainConfig ¶
type ChainConfig struct {
// ChainID is the unique identifier for the blockchain network
ChainID uint64
// RPCUrl is the URL endpoint for connecting to the blockchain RPC
RPCUrl string
}
ChainConfig holds the configuration for connecting to a blockchain. This includes the chain ID and the RPC URL for establishing connections.
type ChainManager ¶
ChainManager implements IChainManager and manages multiple blockchain connections. It maintains a registry of active Chains indexed by their chain IDs.
func NewChainManager ¶
func NewChainManager() *ChainManager
NewChainManager creates a new ChainManager instance. The manager is initialized with an empty chain registry.
Returns:
- *ChainManager: A new chain manager instance
func (*ChainManager) AddChain ¶
func (cm *ChainManager) AddChain(cfg *ChainConfig) error
AddChain adds a new blockchain connection to the manager. This method establishes a connection to the specified RPC URL and stores the resulting chain connection for future use.
Parameters:
- cfg: The chain configuration containing chain ID and RPC URL
Returns:
- error: An error if the chain already exists or connection fails
func (*ChainManager) GetChainForId ¶
func (cm *ChainManager) GetChainForId(chainId uint64) (*Chain, error)
GetChainForId retrieves a chain connection by its chain ID. This method looks up an existing chain connection in the manager's registry.
Parameters:
- chainId: The chain ID to look up
Returns:
- *Chain: The chain connection if found
- error: ErrChainNotFound if the chain ID is not registered
type IChainManager ¶
type IChainManager interface {
// AddChain adds a new blockchain connection to the manager
AddChain(cfg *ChainConfig) error
// GetChainForId retrieves a chain connection by its chain ID
GetChainForId(chainId uint64) (*Chain, error)
}
IChainManager defines the interface for managing blockchain connections. Implementations provide the ability to add new Chains and retrieve existing chain connections by their chain ID.