Skip to content

Commit 68c55cf

Browse files
committed
fix: when currencyIn/currencyOut is native, even if we don't have cache entry, we'd still send the async call
1 parent 54c440d commit 68c55cf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/handlers/router-entities/route-caching/dynamo-route-caching-provider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,21 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
203203
alphaRouterConfig,
204204
swapOptions
205205
)
206+
} else if (currencyIn.isNative || currencyOut.isNative) {
207+
// Caching requests are not `optimistic`, we need to be careful of not removing this flag
208+
// This condition is protecting us against firing another caching request from inside a caching request
209+
if (optimistic) {
210+
// We send an async caching quote
211+
// we do not await on this function, it's a fire and forget
212+
this.maybeSendCachingQuoteForRoutesDb(
213+
partitionKey,
214+
amount,
215+
currentBlockNumber,
216+
[], // sending cachedRoutesRouteIds are really just for the debugging/logging purposes, async call does not use cachedRoutesRouteIds at all
217+
alphaRouterConfig,
218+
swapOptions
219+
)
220+
}
206221
} else {
207222
metric.putMetric('RoutesDbEntriesNotFound', 1, MetricLoggerUnit.Count)
208223
log.warn(`[DynamoRouteCachingProvider] No items found in the query response for ${partitionKey.toString()}`)

0 commit comments

Comments
 (0)