We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 532ce2e commit 98404dbCopy full SHA for 98404db
1 file changed
ocp/rpc/currency/historical_data.go
@@ -259,11 +259,15 @@ func (s *currencyServer) getCachedExchangeRateHistory(
259
260
// findClosestExchangeRate finds the exchange rate closest to the given time.
261
func findClosestExchangeRate(t time.Time, history []*currency.ExchangeRateRecord) (float64, bool) {
262
- // Find the closest preceding exchange rate
+ // Find the closest exchange rate
263
var closestRate float64
264
var found bool
265
for _, record := range history {
266
if record.Time.After(t) {
267
+ if !found {
268
+ closestRate = record.Rate
269
+ found = true
270
+ }
271
break
272
}
273
closestRate = record.Rate
0 commit comments