create_routes_for_payment: fix 'we atomically loop'
Before this commit, partial results were yielded before we had examined the whole split configuration. I think the correct behaviour is to create all the routes for the current configuration, then to yield them. If there is an exception, we should try the next one.
This commit is contained in:
@@ -1736,12 +1736,12 @@ class LNWallet(LNWorker):
|
|||||||
exclude_single_part_payments=True,
|
exclude_single_part_payments=True,
|
||||||
)
|
)
|
||||||
# We atomically loop through a split configuration. If there was
|
# We atomically loop through a split configuration. If there was
|
||||||
# a failure to find a path for a single part, we give back control
|
# a failure to find a path for a single part, we try the next configuration.
|
||||||
# after exhausting the split configuration.
|
|
||||||
yielded_from_split_configuration = False
|
|
||||||
self.logger.info(f'suggest_split {amount_msat} returned {len(split_configurations)} configurations')
|
self.logger.info(f'suggest_split {amount_msat} returned {len(split_configurations)} configurations')
|
||||||
for sc in split_configurations:
|
for sc in split_configurations:
|
||||||
self.logger.info(f"trying split configuration: {list(sc.config.values())} rating: {sc.rating}")
|
self.logger.info(f"trying split configuration: {list(sc.config.values())} rating: {sc.rating}")
|
||||||
|
sc_routes = []
|
||||||
|
sc_success = True
|
||||||
for (chan_id, _), part_amounts_msat in sc.config.items():
|
for (chan_id, _), part_amounts_msat in sc.config.items():
|
||||||
for part_amount_msat in part_amounts_msat:
|
for part_amount_msat in part_amounts_msat:
|
||||||
channel = self.channels[chan_id]
|
channel = self.channels[chan_id]
|
||||||
@@ -1758,12 +1758,16 @@ class LNWallet(LNWorker):
|
|||||||
full_path=None
|
full_path=None
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
yield route, part_amount_msat, final_total_msat, part_amount_msat, min_cltv_expiry, payment_secret, fwd_trampoline_onion, None
|
sc_routes.append((route, part_amount_msat, final_total_msat, part_amount_msat, min_cltv_expiry, payment_secret, fwd_trampoline_onion, None))
|
||||||
yielded_from_split_configuration = True
|
|
||||||
except NoPathFound:
|
except NoPathFound:
|
||||||
continue
|
sc_success = False
|
||||||
if yielded_from_split_configuration:
|
break
|
||||||
|
if sc_success:
|
||||||
|
for r in sc_routes:
|
||||||
|
yield r
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
continue
|
||||||
raise NoPathFound()
|
raise NoPathFound()
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
|
|||||||
Reference in New Issue
Block a user