Skip to content

Commit

Permalink
Add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Sep 24, 2024
1 parent 0afd8da commit b99b90c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func newChain(id string, cfg *config.TOMLConfig, ks loop.Keystore, lggr logger.L
clientCache: map[string]*verifiedCachedClient{},
}

if cfg.MultiNodeEnabled() {
if cfg.MultiNode.MultiNodeEnabled() {
chainFamily := "solana"

mnCfg := cfg.MultiNodeConfig()
Expand Down Expand Up @@ -398,7 +398,7 @@ func (c *chain) ChainID() string {

// getClient returns a client, randomly selecting one from available and valid nodes
func (c *chain) getClient() (client.ReaderWriter, error) {
if c.cfg.MultiNodeEnabled() {
if c.cfg.MultiNode.MultiNodeEnabled() {
return c.multiNode.SelectRPC()
}

Expand Down Expand Up @@ -482,7 +482,7 @@ func (c *chain) Start(ctx context.Context) error {
c.lggr.Debug("Starting balance monitor")
var ms services.MultiStart
startAll := []services.StartClose{c.txm, c.balanceMonitor}
if c.cfg.MultiNodeEnabled() {
if c.cfg.MultiNode.MultiNodeEnabled() {
c.lggr.Debug("Starting multinode")
startAll = append(startAll, c.multiNode, c.txSender)
}
Expand All @@ -496,7 +496,7 @@ func (c *chain) Close() error {
c.lggr.Debug("Stopping txm")
c.lggr.Debug("Stopping balance monitor")
closeAll := []io.Closer{c.txm, c.balanceMonitor}
if c.cfg.MultiNodeEnabled() {
if c.cfg.MultiNode.MultiNodeEnabled() {
c.lggr.Debug("Stopping multinode")
closeAll = append(closeAll, c.multiNode, c.txSender)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/solana/config/multinode.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MultiNode struct {
}

func (c *MultiNode) MultiNodeEnabled() bool {
return *c.multiNodeEnabled
return c.multiNodeEnabled != nil && *c.multiNodeEnabled
}

func (c *MultiNode) PollFailureThreshold() uint32 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/solana/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ type TOMLConfig struct {
// Do not access directly, use [IsEnabled]
Enabled *bool
Chain
MultiNode
Nodes Nodes
MultiNode MultiNode
Nodes Nodes
}

func (c *TOMLConfig) IsEnabled() bool {
Expand Down

0 comments on commit b99b90c

Please sign in to comment.