@ -2762,96 +2762,6 @@ struct route_hop **get_route(const tal_t *ctx, struct routing_state *rstate,
return hops ;
}
void routing_failure ( struct routing_state * rstate ,
const struct node_id * erring_node_id ,
const struct short_channel_id * scid ,
int erring_direction ,
enum onion_type failcode ,
const u8 * channel_update )
{
struct chan * * pruned = tal_arr ( tmpctx , struct chan * , 0 ) ;
status_debug ( " Received routing failure 0x%04x (%s), "
" erring node %s, "
" channel %s/%u " ,
( int ) failcode , onion_type_name ( failcode ) ,
type_to_string ( tmpctx , struct node_id , erring_node_id ) ,
type_to_string ( tmpctx , struct short_channel_id , scid ) ,
erring_direction ) ;
/* lightningd will only extract this if UPDATE is set. */
if ( channel_update ) {
u8 * err = handle_channel_update ( rstate , channel_update ,
NULL , NULL ) ;
if ( err ) {
status_unusual ( " routing_failure: "
" bad channel_update %s " ,
sanitize_error ( err , err , NULL ) ) ;
tal_free ( err ) ;
}
} else if ( failcode & UPDATE ) {
status_unusual ( " routing_failure: "
" UPDATE bit set, no channel_update. "
" failcode: 0x%04x " ,
( int ) failcode ) ;
}
/* We respond to permanent errors, ignore the rest: they're
* for the pay command to worry about . */
if ( ! ( failcode & PERM ) )
return ;
if ( failcode & NODE ) {
struct node * node = get_node ( rstate , erring_node_id ) ;
if ( ! node ) {
status_unusual ( " routing_failure: Erring node %s not in map " ,
type_to_string ( tmpctx , struct node_id ,
erring_node_id ) ) ;
} else {
struct chan_map_iter i ;
struct chan * c ;
status_debug ( " Deleting node %s " ,
type_to_string ( tmpctx ,
struct node_id ,
& node - > id ) ) ;
for ( c = first_chan ( node , & i ) ; c ; c = next_chan ( node , & i ) ) {
/* Set it up to be pruned. */
tal_arr_expand ( & pruned , c ) ;
}
}
} else {
struct chan * chan = get_channel ( rstate , scid ) ;
if ( ! chan )
status_unusual ( " routing_failure: "
" Channel %s unknown " ,
type_to_string ( tmpctx ,
struct short_channel_id ,
scid ) ) ;
else {
/* This error can be triggered by sendpay if caller
* uses the wrong key for dest . */
if ( failcode = = WIRE_INVALID_ONION_HMAC
& & ! node_id_eq ( & chan - > nodes [ ! erring_direction ] - > id ,
erring_node_id ) )
return ;
status_debug ( " Deleting channel %s " ,
type_to_string ( tmpctx ,
struct short_channel_id ,
scid ) ) ;
/* Set it up to be deleted. */
tal_arr_expand ( & pruned , chan ) ;
}
}
/* Now free all the chans and maybe even nodes. */
for ( size_t i = 0 ; i < tal_count ( pruned ) ; i + + )
free_chan ( rstate , pruned [ i ] ) ;
}
void route_prune ( struct routing_state * rstate )
{
u64 now = gossip_time_now ( rstate ) . ts . tv_sec ;