relayer

package
v0.0.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Log    *zap.Logger
	Debug  bool
	Config *config.Config
	Store  store.Store

	TargetChains chains.ChainProviders
	BandClient   band.Client
	Passphrase   string
}

App is the main application struct.

func NewApp

func NewApp(
	log *zap.Logger,
	debug bool,
	config *config.Config,
	passphrase string,
	store store.Store,
) *App

NewApp creates a new App instance.

func (*App) AddChainConfig

func (a *App) AddChainConfig(chainName string, filePath string) error

AddChainConfig adds a new chain configuration to the config file.

func (*App) AddKeyByMnemonic

func (a *App) AddKeyByMnemonic(
	chainName string,
	keyName string,
	mnemonic string,
	coinType uint32,
	account uint,
	index uint,
) (*chainstypes.Key, error)

AddKeyByMnemonic adds a new key to the chain provider using a mnemonic phrase.

func (*App) AddKeyByPrivateKey

func (a *App) AddKeyByPrivateKey(chainName string, keyName string, privateKey string) (*chainstypes.Key, error)

AddKeyByPrivateKey adds a new key to the chain provider using a private key.

func (*App) DeleteChainConfig

func (a *App) DeleteChainConfig(chainName string) error

DeleteChainConfig deletes the chain configuration from the config file.

func (*App) DeleteKey

func (a *App) DeleteKey(chainName string, keyName string) error

DeleteKey deletes the key from the chain provider.

func (*App) ExportKey

func (a *App) ExportKey(chainName string, keyName string) (string, error)

ExportKey exports the private key from the chain provider.

func (*App) GetChainConfig

func (a *App) GetChainConfig(chainName string) (chains.ChainProviderConfig, error)

GetChainConfig retrieves the chain configuration by given chain name.

func (*App) Init

func (a *App) Init(ctx context.Context) error

Init initialize the application.

func (*App) ListKeys

func (a *App) ListKeys(chainName string) ([]*chainstypes.Key, error)

ListKeys retrieves the list of keys from the chain provider.

func (*App) QueryBalance

func (a *App) QueryBalance(ctx context.Context, chainName string, keyName string) (*big.Int, error)

QueryBalance retrieves the balance of the key from the chain provider.

func (*App) QueryTunnelInfo

func (a *App) QueryTunnelInfo(ctx context.Context, tunnelID uint64) (*types.Tunnel, error)

QueryTunnelInfo queries tunnel information by given tunnel ID

func (*App) QueryTunnelPacketInfo

func (a *App) QueryTunnelPacketInfo(ctx context.Context, tunnelID uint64, sequence uint64) (*bandtypes.Packet, error)

QueryTunnelPacketInfo queries tunnel packet information by given tunnel ID

func (*App) Relay

func (a *App) Relay(ctx context.Context, tunnelID uint64) error

Relay relays the packet from the source chain to the destination chain.

func (*App) SaveConfig

func (a *App) SaveConfig(cfg *config.Config) error

SaveConfig saves the configuration into the application's store.

func (*App) SavePassphrase

func (a *App) SavePassphrase(passphrase string) error

SavePassphrase hash the provided passphrase and save it into the application's store.

func (*App) ShowKey

func (a *App) ShowKey(chainName string, keyName string) (string, error)

ShowKey retrieves the key information from the chain provider.

func (*App) Start

func (a *App) Start(ctx context.Context, tunnelIDs []uint64) error

Start starts the tunnel relayer program.

type Scheduler

type Scheduler struct {
	Log                    *zap.Logger
	CheckingPacketInterval time.Duration
	SyncTunnelsInterval    time.Duration
	PenaltySkipRounds      uint

	BandClient     band.Client
	ChainProviders chains.ChainProviders
	// contains filtered or unexported fields
}

Scheduler is a struct to manage all tunnel relayers

func NewScheduler

func NewScheduler(
	log *zap.Logger,
	checkingPacketInterval time.Duration,
	syncTunnelsInterval time.Duration,
	penaltySkipRounds uint,
	bandClient band.Client,
	chainProviders chains.ChainProviders,
) *Scheduler

NewScheduler creates a new Scheduler

func (*Scheduler) Execute

func (s *Scheduler) Execute(ctx context.Context)

Execute executes the task for the tunnel relayer

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context, tunnelIds []uint64) error

Start starts all tunnel relayers

func (*Scheduler) SyncTunnels

func (s *Scheduler) SyncTunnels(ctx context.Context, tunnelIds []uint64)

SyncTunnels synchronizes the Bandchain's tunnels with the latest tunnels.

func (*Scheduler) TriggerTunnelRelayer

func (s *Scheduler) TriggerTunnelRelayer(ctx context.Context, task Task)

TriggerTunnelRelayer triggers the tunnel relayer to check and relay the packet

type Task

type Task struct {
	RelayerID       int
	WaitingInterval time.Duration
}

Task is a struct to manage the task for the tunnel relayer

func NewTask

func NewTask(relayerID int, waitingInterval time.Duration) Task

NewTask creates a new Task

type TunnelRelayer

type TunnelRelayer struct {
	Log                    *zap.Logger
	TunnelID               uint64
	CheckingPacketInterval time.Duration
	BandClient             band.Client
	TargetChainProvider    chains.ChainProvider
	// contains filtered or unexported fields
}

TunnelRelayer is a relayer that listens to the tunnel and relays the packet

func NewTunnelRelayer

func NewTunnelRelayer(
	log *zap.Logger,
	tunnelID uint64,
	checkingPacketInterval time.Duration,
	bandClient band.Client,
	targetChainProvider chains.ChainProvider,
) TunnelRelayer

NewTunnelRelayer creates a new TunnelRelayer

func (*TunnelRelayer) CheckAndRelay

func (t *TunnelRelayer) CheckAndRelay(ctx context.Context) (isExecuting bool, err error)

CheckAndRelay checks the tunnel and relays the packet

Directories

Path Synopsis
evm

Jump to

Keyboard shortcuts

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