Skip to content

Commit

Permalink
ChainName -> ChainType
Browse files Browse the repository at this point in the history
  • Loading branch information
bap2pecs committed Oct 9, 2024
1 parent dfa7e25 commit da460af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions clientcontroller/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
babylonConsumerChainName = "babylon"
babylonConsumerChainType = "babylon"
)

type ClientController interface {
Expand Down Expand Up @@ -71,14 +71,14 @@ type ClientController interface {
Close() error
}

func NewClientController(chainName string, bbnConfig *fpcfg.BBNConfig, netParams *chaincfg.Params, logger *zap.Logger) (ClientController, error) {
func NewClientController(chainType string, bbnConfig *fpcfg.BBNConfig, netParams *chaincfg.Params, logger *zap.Logger) (ClientController, error) {
var (
cc ClientController
err error
)

switch chainName {
case babylonConsumerChainName:
switch chainType {
case babylonConsumerChainType:
cc, err = NewBabylonController(bbnConfig, netParams, logger)
if err != nil {
return nil, fmt.Errorf("failed to create Babylon rpc client: %w", err)
Expand Down
8 changes: 4 additions & 4 deletions finality-provider/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
defaultChainName = "babylon"
defaultChainType = "babylon"
defaultLogLevel = zapcore.InfoLevel
defaultLogDirname = "logs"
defaultLogFilename = "fpd.log"
Expand Down Expand Up @@ -56,8 +56,8 @@ var (
// Config is the main config for the fpd cli command
type Config struct {
LogLevel string `long:"loglevel" description:"Logging level for all subsystems" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error" choice:"fatal"`
// ChainName and ChainID (if any) of the chain config identify a consumer chain
ChainName string `long:"chainname" description:"the name of the consumer chain" choice:"babylon"`
// ChainType and ChainID (if any) of the chain config identify a consumer chain
ChainType string `long:"chaintype" description:"the type of the consumer chain" choice:"babylon"`
NumPubRand uint32 `long:"numPubRand" description:"The number of Schnorr public randomness for each commitment"`
NumPubRandMax uint32 `long:"numpubrandmax" description:"The upper bound of the number of Schnorr public randomness for each commitment"`
MinRandHeightGap uint32 `long:"minrandheightgap" description:"The minimum gap between the last committed rand height and the current Babylon block height"`
Expand Down Expand Up @@ -93,7 +93,7 @@ func DefaultConfigWithHome(homePath string) Config {
bbnCfg.KeyDirectory = homePath
pollerCfg := DefaultChainPollerConfig()
cfg := Config{
ChainName: defaultChainName,
ChainType: defaultChainType,
LogLevel: defaultLogLevel.String(),
DatabaseConfig: DefaultDBConfigWithHomePath(homePath),
BabylonConfig: &bbnCfg,
Expand Down
4 changes: 2 additions & 2 deletions finality-provider/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func NewFinalityProviderAppFromConfig(
db kvdb.Backend,
logger *zap.Logger,
) (*FinalityProviderApp, error) {
cc, err := clientcontroller.NewClientController(cfg.ChainName, cfg.BabylonConfig, &cfg.BTCNetParams, logger)
cc, err := clientcontroller.NewClientController(cfg.ChainType, cfg.BabylonConfig, &cfg.BTCNetParams, logger)
if err != nil {
return nil, fmt.Errorf("failed to create rpc client for the consumer chain %s: %v", cfg.ChainName, err)
return nil, fmt.Errorf("failed to create rpc client for the consumer chain %s: %v", cfg.ChainType, err)
}

// if the EOTSManagerAddress is empty, run a local EOTS manager;
Expand Down
4 changes: 2 additions & 2 deletions itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func StartManagerWithFinalityProvider(t *testing.T, n int) (*TestManager, []*ser
fpBbnKeyInfo, err := service.CreateChainKey(cfg.BabylonConfig.KeyDirectory, cfg.BabylonConfig.ChainID, cfg.BabylonConfig.Key, cfg.BabylonConfig.KeyringBackend, passphrase, hdPath, "")
require.NoError(t, err)

cc, err := clientcontroller.NewClientController(cfg.ChainName, cfg.BabylonConfig, &cfg.BTCNetParams, zap.NewNop())
cc, err := clientcontroller.NewClientController(cfg.ChainType, cfg.BabylonConfig, &cfg.BTCNetParams, zap.NewNop())
require.NoError(t, err)
app.UpdateClientController(cc)

Expand Down Expand Up @@ -246,7 +246,7 @@ func StartManagerWithFinalityProvider(t *testing.T, n int) (*TestManager, []*ser

// goes back to old key in app
cfg.BabylonConfig.Key = oldKey
cc, err := clientcontroller.NewClientController(cfg.ChainName, cfg.BabylonConfig, &cfg.BTCNetParams, zap.NewNop())
cc, err := clientcontroller.NewClientController(cfg.ChainType, cfg.BabylonConfig, &cfg.BTCNetParams, zap.NewNop())
require.NoError(t, err)
app.UpdateClientController(cc)

Expand Down

0 comments on commit da460af

Please sign in to comment.