Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Mar 7, 2024
1 parent 2d255a5 commit 92ff8fb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion app/sidecar_query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func NewSideCarQueryServer(appCodec codec.Codec, config domain.Config, logger lo
poolsUseCase := poolsUseCase.NewPoolsUsecase(timeoutContext, poolsRepository, redisTxManager, config.Pools, config.ChainGRPCGatewayEndpoint)

// Initialize router repository, usecase
routerRepository := routerredisrepo.New(redisTxManager)
routerRepository := routerredisrepo.New(redisTxManager, 0)
routerUsecase := routerUseCase.WithOverwriteRoutesPath(routerUseCase.NewRouterUsecase(timeoutContext, routerRepository, poolsUseCase, *config.Router, logger, cache.New(), cache.New()), overwriteRoutesPath)

// Initialize system handler
Expand Down
6 changes: 0 additions & 6 deletions router/usecase/router_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (r *routerUseCaseImpl) GetOptimalQuote(ctx context.Context, tokenIn sdk.Coi
// - fails to estimate direct quotes for ranked routes
// - fails to retrieve candidate routes
func (r *routerUseCaseImpl) GetOptimalQuoteFromConfig(ctx context.Context, tokenIn sdk.Coin, tokenOutDenom string, config domain.RouterConfig) (domain.Quote, error) {

// Get an order of magnitude for the token in amount
// This is used for caching ranked routes as these might differ depending on the amount swapped in.
tokenInOrderOfMagnitude := osmomath.OrderOfMagnitude(tokenIn.Amount.ToLegacyDec())
Expand Down Expand Up @@ -192,7 +191,6 @@ func (r *routerUseCaseImpl) GetOptimalQuoteFromConfig(ctx context.Context, token
rankedRoutes = filterOutGeneralizedCosmWasmPoolRoutes(rankedRoutes)

if len(rankedRoutes) > 0 {

cacheWrite.WithLabelValues(requestURLPath, rankedRouteCacheLabel, tokenIn.Denom, tokenOutDenom, strconv.FormatInt(int64(tokenInOrderOfMagnitude), 10)).Inc()

r.rankedRouteCache.Set(formatRankedRouteCacheKey(tokenIn.Denom, tokenOutDenom, tokenInOrderOfMagnitude), candidateRoutes, time.Duration(config.RankedRouteCacheExpirySeconds)*time.Second)
Expand Down Expand Up @@ -552,15 +550,13 @@ func (r *routerUseCaseImpl) GetCachedCandidateRoutes(ctx context.Context, tokenI

cachedCandidateRoutes, found := r.candidateRouteCache.Get(formatCandidateRouteCacheKey(tokenInDenom, tokenOutDenom))
if !found {

// Increase cache misses
cacheMisses.WithLabelValues(requestURLPath, candidateRouteCacheLabel, tokenInDenom, tokenOutDenom, noOrderOfMagnitude).Inc()

return sqsdomain.CandidateRoutes{
Routes: []sqsdomain.CandidateRoute{},
UniquePoolIDs: map[uint64]struct{}{},
}, nil

}

cacheHits.WithLabelValues(requestURLPath, candidateRouteCacheLabel, tokenInDenom, tokenOutDenom, noOrderOfMagnitude).Inc()
Expand All @@ -587,12 +583,10 @@ func (r *routerUseCaseImpl) GetCachedRankedRoutes(ctx context.Context, tokenInDe

cachedRankedRoutes, found := r.rankedRouteCache.Get(formatRankedRouteCacheKey(tokenInDenom, tokenOutDenom, tokenInOrderOfMagnitude))
if !found {

// Increase cache misses
cacheMisses.WithLabelValues(requestURLPath, rankedRouteCacheLabel, tokenInDenom, tokenOutDenom, strconv.FormatInt(int64(tokenInOrderOfMagnitude), 10)).Inc()

return sqsdomain.CandidateRoutes{}, nil

}

cacheHits.WithLabelValues(requestURLPath, rankedRouteCacheLabel, tokenInDenom, tokenOutDenom, strconv.FormatInt(int64(tokenInOrderOfMagnitude), 10)).Inc()
Expand Down

0 comments on commit 92ff8fb

Please sign in to comment.