fix_: native token not found error when generating a new route issue fixed
This commit fixes `native token not found` issue that occurs only when the input params of an already successfully generated route for a fast chain (refers to a chain that generates new block very fast, like optimism, arbitrum) are updated. The reason of the issue was that active route remains the same until the resolving of a new route for updated input parameters gets generated, for fast chains that was enough time to generate a new block and send fees update for the previously active route. This commit fixes that possibility by aborting updates in a better way.
This commit is contained in:
parent
97db14083a
commit
6ed10bce81
|
@ -202,25 +202,35 @@ func (r *Router) SuggestedRoutesAsync(input *requests.RouteInputParams) {
|
|||
})
|
||||
}
|
||||
|
||||
func (r *Router) clearActiveRoute() {
|
||||
r.activeRoutesMutex.Lock()
|
||||
r.activeRoutes = nil
|
||||
r.activeRoutesMutex.Unlock()
|
||||
}
|
||||
|
||||
func (r *Router) markRouteCanceled(value bool) {
|
||||
r.routeCanceledMutex.Lock()
|
||||
r.routeCanceled = value
|
||||
r.routeCanceledMutex.Unlock()
|
||||
}
|
||||
|
||||
func (r *Router) StopSuggestedRoutesAsyncCalculation() {
|
||||
func (r *Router) abortUpdates() {
|
||||
r.markRouteCanceled(true)
|
||||
r.unsubscribeFeesUpdateAccrossAllChains()
|
||||
}
|
||||
|
||||
func (r *Router) StopSuggestedRoutesAsyncCalculation() {
|
||||
r.abortUpdates()
|
||||
r.scheduler.Stop()
|
||||
}
|
||||
|
||||
func (r *Router) StopSuggestedRoutesCalculation() {
|
||||
r.unsubscribeFeesUpdateAccrossAllChains()
|
||||
r.abortUpdates()
|
||||
}
|
||||
|
||||
func (r *Router) SuggestedRoutes(ctx context.Context, input *requests.RouteInputParams) (suggestedRoutes *SuggestedRoutes, err error) {
|
||||
// unsubscribe from updates
|
||||
r.unsubscribeFeesUpdateAccrossAllChains()
|
||||
r.clearActiveRoute()
|
||||
r.abortUpdates()
|
||||
r.markRouteCanceled(false)
|
||||
|
||||
// clear all processors
|
||||
|
|
Loading…
Reference in New Issue