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