Skip to content

Commit

Permalink
prevent overflow on MaxRetries
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 17, 2024
1 parent 38db8e1 commit 3258424
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/solana/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var defaultConfigSet = configSet{
TxConfirmTimeout: 30 * time.Second, // duration before discarding tx as unconfirmed
SkipPreflight: true, // to enable or disable preflight checks
Commitment: rpc.CommitmentConfirmed,
MaxRetries: new(uint), // max number of retries, when nil - rpc node will do a reasonable number of retries
MaxRetries: new(uint), // max number of retries (default = *new(uint) = 0). when config.MaxRetries < 0, interpreted as MaxRetries = nil and rpc node will do a reasonable number of retries

// fee estimator
FeeEstimatorMode: "fixed",
Expand Down
3 changes: 3 additions & 0 deletions pkg/solana/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ func (c *TOMLConfig) MaxRetries() *uint {
if c.Chain.MaxRetries == nil {
return nil
}
if *c.Chain.MaxRetries < 0 {
return nil // interpret negative numbers as nil (prevents unlikely case of overflow)
}
mr := uint(*c.Chain.MaxRetries)
return &mr
}
Expand Down

0 comments on commit 3258424

Please sign in to comment.