lnworker: improve route creation
- Separates the trampoline and local routing multi-part payment cases. - Ask only for splits that don't send over a single channel (those have been tried already in the single-part case). - Makes sure that create_routes_for_payment only yields partial routes that belong to a single split configuration. - Tracks trampoline fee levels on a per node basis, previously, in the case of having two channels with a trampoline forwarder, the global fee level would have increased by two levels upon first try.
This commit is contained in:
@@ -86,6 +86,16 @@ def remove_single_part_configs(configs: List[SplitConfig]) -> List[SplitConfig]:
|
||||
return [config for config in configs if number_parts(config) != 1]
|
||||
|
||||
|
||||
def remove_single_channel_splits(configs: List[SplitConfig]) -> List[SplitConfig]:
|
||||
filtered = []
|
||||
for config in configs:
|
||||
for v in config.values():
|
||||
if len(v) > 1:
|
||||
continue
|
||||
filtered.append(config)
|
||||
return filtered
|
||||
|
||||
|
||||
def rate_config(
|
||||
config: SplitConfig,
|
||||
channels_with_funds: ChannelsFundsInfo) -> float:
|
||||
@@ -113,7 +123,8 @@ def rate_config(
|
||||
def suggest_splits(
|
||||
amount_msat: int, channels_with_funds: ChannelsFundsInfo,
|
||||
exclude_single_part_payments=False,
|
||||
exclude_multinode_payments=False
|
||||
exclude_multinode_payments=False,
|
||||
exclude_single_channel_splits=False
|
||||
) -> List[SplitConfigRating]:
|
||||
"""Breaks amount_msat into smaller pieces and distributes them over the
|
||||
channels according to the funds they can send.
|
||||
@@ -172,6 +183,9 @@ def suggest_splits(
|
||||
if exclude_single_part_payments:
|
||||
configs = remove_single_part_configs(configs)
|
||||
|
||||
if exclude_single_channel_splits:
|
||||
configs = remove_single_channel_splits(configs)
|
||||
|
||||
rated_configs = [SplitConfigRating(
|
||||
config=c,
|
||||
rating=rate_config(c, channels_with_funds)
|
||||
|
||||
Reference in New Issue
Block a user