feat(router-core): add batch route scoring#699
Merged
Maki-Zeninn merged 2 commits intoJun 27, 2026
Conversation
|
@Yasir-TechGuy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Author
|
Hi @Maki-Zeninn Please check it out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses #635 by introducing a batch score-updating mechanism in
router-core.Previously, updating scores sequentially triggered a full$O(n)$ best-route recomputation via
recompute_best_route()on every single update, causing massive CPU overhead during multi-route administrative updates.This change adds
set_route_scores_batch(), allowing administrators to submit multiple route score updates in a single transaction. The expensiverecompute_best_route()function is now executed exactly once at the end of the entire batch process.Key Changes
Types & Interfaces
RouteScoreInput: A new#[contracttype]struct to facilitate safe input handling for batch configurations.set_route_scores_batch(): The core batch entry point requiring admin authentication.🛡️ Fail-Fast & Atomic Execution
RouterError::RouteNotFound.recompute_best_routeis called exactly once.Bug Fixes & Refactoring
RouterError(InvalidAddresschanged from 10 to 12;RouteExpiredchanged from 10 to 13).Self::recompute_best_route(&env).Test Coverage
Added comprehensive unit tests within
mod tests:test_set_route_scores_batch: Verifies successful batch updates across multiple legitimate routes.test_set_route_scores_batch_fails_if_route_missing: Assures atomicity by checking that if a single route name is missing, the transaction fails completely and leaves prior scores untouched.Fixes
Fixes #635
closes #635