Skip to content

Commit 7f51753

Browse files
committed
xpay: penalize nodes that have failing channels
Changelog-None Signed-off-by: Lagrang3 <[email protected]>
1 parent 26a76bf commit 7f51753

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

plugins/xpay/xpay.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,14 +843,40 @@ static void update_knowledge_from_error(struct command *aux_cmd,
843843
describe_scidd(attempt, index));
844844

845845
disable_channel:
846-
/* We only do this for the current payment */
846+
/* We disable this channel for the current payment */
847847
req = payment_ignored_req(aux_cmd, attempt, "askrene-update-channel");
848848
json_add_string(req->js, "layer", attempt->payment->private_layer);
849849
json_add_short_channel_id_dir(req->js,
850850
"short_channel_id_dir",
851851
attempt->hops[index].scidd);
852852
json_add_bool(req->js, "enabled", false);
853853
send_payment_req(aux_cmd, attempt->payment, req);
854+
855+
/* We add a negative bias to this channel to penalize it for other
856+
* payments.
857+
* Biases are nice way to penalize or encourage the use of
858+
* channels. But it has some limitations. For example the bias would
859+
* have no effect if the channel already provides 0 cost routing. */
860+
req = payment_ignored_req(aux_cmd, attempt, "askrene-bias-channel");
861+
json_add_string(req->js, "layer", XPAY_GLOBAL_LAYER);
862+
json_add_short_channel_id_dir(req->js, "short_channel_id_dir",
863+
attempt->hops[index].scidd);
864+
json_add_s32(req->js, "bias", -5);
865+
json_add_bool(req->js, "relative", true);
866+
send_payment_req(aux_cmd, attempt->payment, req);
867+
868+
/* We add a negative bias to the node that owns this half channel. */
869+
if (index) {
870+
req =
871+
payment_ignored_req(aux_cmd, attempt, "askrene-bias-node");
872+
json_add_string(req->js, "layer", XPAY_GLOBAL_LAYER);
873+
json_add_pubkey(req->js, "node",
874+
&attempt->hops[index - 1].next_node);
875+
json_add_s32(req->js, "bias", -1);
876+
json_add_bool(req->js, "relative", true);
877+
json_add_bool(req->js, "out_direction", true);
878+
send_payment_req(aux_cmd, attempt->payment, req);
879+
}
854880
goto check_previous_success;
855881

856882
channel_capacity:

0 commit comments

Comments
 (0)