-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BE-687 | Cache for different swap methods #614
Conversation
Update cache to accept swap method to avoid collisions
Caution Review failedThe pull request is closed. WalkthroughThis pull request updates the caching mechanism within the router use case. The cache keys are now structured with an additional parameter representing the token swap method. In the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
router/usecase/router_usecase.go (1)
424-424
: Consider adding a comment explaining the swap method choice.While the implementation is correct, it would be helpful to add a comment explaining why
TokenSwapMethodExactIn
is used here and how it relates to the overall caching strategy.+ // Use TokenSwapMethodExactIn for ranked route caching as this is the primary swap method. + // The cache key includes the method to prevent collisions with other swap methods. r.rankedRouteCache.Set(formatRankedRouteCacheKey(domain.TokenSwapMethodExactIn, tokenIn.Denom, tokenOutDenom, tokenInOrderOfMagnitude), convertedCandidateRoutes, time.Duration(routingOptions.RankedRouteCacheExpirySeconds)*time.Second)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
router/usecase/export_test.go
is excluded by!**/*_test.go
router/usecase/optimized_routes_test.go
is excluded by!**/*_test.go
router/usecase/router_usecase_test.go
is excluded by!**/*_test.go
📒 Files selected for processing (2)
router/usecase/optimized_routes.go
(2 hunks)router/usecase/router_usecase.go
(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
🔇 Additional comments (6)
router/usecase/optimized_routes.go (2)
62-64
: LGTM! Cache invalidation updated to include swap method.The cache invalidation logic has been correctly updated to include
domain.TokenSwapMethodExactIn
for the exact-in swap method.
127-129
: LGTM! Cache invalidation updated to include swap method.The cache invalidation logic has been correctly updated to include
domain.TokenSwapMethodExactOut
for the exact-out swap method.router/usecase/router_usecase.go (4)
779-791
: LGTM! Cache key formatting functions updated to include swap method.The cache key formatting functions have been correctly updated to include the swap method as part of the key, which will prevent cache collisions between different swap methods.
384-390
: LGTM! Cache operations updated to include swap method.Cache operations in
computeAndRankRoutesByDirectQuote
have been correctly updated to usedomain.TokenSwapMethodExactIn
when caching routes.
710-710
: LGTM! Cache operation updated to include swap method.Cache operation in
handleCandidateRoutes
has been correctly updated to usedomain.TokenSwapMethodExactIn
when caching candidate routes.
616-616
: LGTM! Cache retrieval operations updated to include swap method.Cache retrieval operations in
GetCachedCandidateRoutes
andGetCachedRankedRoutes
have been correctly updated to usedomain.TokenSwapMethodExactIn
when retrieving cached routes.Also applies to: 649-649
|
This PR is a follow up from discussion on previous PR.
Proposed solution updates cache to accept swap method to avoid collisions caching different types swap routes.
Considered alternatives:
Summary by CodeRabbit