Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
add rpc flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikey committed Jan 29, 2024
1 parent e60ce29 commit 290f3dc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions cmd/node/appchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func createClient(ctx context.Context, ap AppChain) (cosmosclient.Client, error)
}

DefaultNodeHome := filepath.Join(userHomeDir, ".uptd")
client, _ = cosmosclient.New(ctx, cosmosclient.WithAddressPrefix(ap.Config.AddressPrefix), cosmosclient.WithHome(DefaultNodeHome))
client, _ = cosmosclient.New(ctx,
cosmosclient.WithAddressPrefix(ap.Config.AddressPrefix),
cosmosclient.WithHome(DefaultNodeHome),
// cosmosclient.WithNodeAddress(ap.Config.NodeRPCAddress),
)

// this is terrible, no isConnected as part of this code path
if(len(client.Context().ChainID) < 1) {
Expand Down Expand Up @@ -131,15 +135,13 @@ func (ap *AppChain) startClient(ctx context.Context, config AppChainConfig) err
return nil
}

func NewAppChain(config AppChainConfig, logger zerolog.Logger) (*AppChain, error) {
func NewAppChain(ctx context.Context, config AppChainConfig, logger zerolog.Logger) (*AppChain, error) {

ap := &AppChain{
Logger: logger,
Config: config,
}

ctx := context.Background()

client, err := createClient(ctx, *ap);

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/node/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func parseFlags() *alloraCfg {
pflag.StringVarP(&cfg.AppChainConfig.AddressKeyName, "allora-chain-key-name", "", "", "The name of a key stored in the Allora Blockchain Wallet")
pflag.StringVarP(&cfg.AppChainConfig.AddressRestoreMnemonic, "allora-chain-restore-mnemonic", "", "", "The restore mnemonic for an Allora Blockchain Wallet")
pflag.StringVarP(&cfg.AppChainConfig.AddressAccountPassphrase, "allora-chain-account-password", "", "", "The password for an Allora Blockchain Wallet Key")
pflag.StringVarP(&cfg.AppChainConfig.NodeRPCAddress, "allora-node-rpc-address", "", "127.0.0.1:26656", "The address for the client to connect to a node.")

pflag.CommandLine.SortFlags = false

Expand Down
6 changes: 3 additions & 3 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ func run() int {
cfg.AppChainConfig.AddressPrefix = "upt"
cfg.AppChainConfig.LibP2PKey = host.ID().String()

appchain, err := NewAppChain(cfg.AppChainConfig, log)
if err != nil {
appchain.init(ctx)
appchain, err := NewAppChain(context.Background(), cfg.AppChainConfig, log)
if err == nil {
appchain.init(context.Background())
}

// Start node main loop in a separate goroutine.
Expand Down
1 change: 1 addition & 0 deletions cmd/node/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type AppChain struct {
}

type AppChainConfig struct {
NodeRPCAddress string // rpc node to attach to
AddressPrefix string // prefix for the cosmos addresses
AddressKeyName string // load a address by key from the keystore
AddressRestoreMnemonic string
Expand Down

0 comments on commit 290f3dc

Please sign in to comment.