Skip to content

Commit

Permalink
add auto rounding option to client config
Browse files Browse the repository at this point in the history
  • Loading branch information
samotarnik committed Jul 17, 2021
1 parent 74293da commit b0e6754
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type apiClientConfig struct {
apiSecret string
nonceGenerator func() string
timestampGenerator func() string
// have client implicitly round input prices/amounts to correct number of decimal places.
// used solely for consumers' convenience and will probably be removed at some point.
autoRounding bool
}

func defaultApiClientConfig() *apiClientConfig {
Expand Down Expand Up @@ -58,6 +61,12 @@ func NonceGenerator(nonceGen func() string) ApiOption {
}
}

func AutoRoundingEnabled() ApiOption {
return func(config *apiClientConfig) {
config.autoRounding = true
}
}

// 10x slower the than previous `fmt.Sprintf("%d", time.Now().UnixNano())`, should i worry?
func defaultNonce() string {
return uuid.NewString()
Expand Down

0 comments on commit b0e6754

Please sign in to comment.