|
|
@ -265,7 +265,6 @@ static void init_half_chan(struct routing_state *rstate, |
|
|
|
struct half_chan *c = &chan->half[channel_idx]; |
|
|
|
|
|
|
|
c->channel_update = NULL; |
|
|
|
c->unroutable_until = 0; |
|
|
|
|
|
|
|
/* Set the channel direction */ |
|
|
|
c->channel_flags = channel_idx; |
|
|
@ -438,11 +437,10 @@ static void bfg_one_edge(struct node *node, |
|
|
|
} |
|
|
|
|
|
|
|
/* Determine if the given half_chan is routable */ |
|
|
|
static bool hc_is_routable(const struct chan *chan, int idx, time_t now) |
|
|
|
static bool hc_is_routable(const struct chan *chan, int idx) |
|
|
|
{ |
|
|
|
return !chan->local_disabled |
|
|
|
&& is_halfchan_enabled(&chan->half[idx]) |
|
|
|
&& chan->half[idx].unroutable_until < now; |
|
|
|
&& is_halfchan_enabled(&chan->half[idx]); |
|
|
|
} |
|
|
|
|
|
|
|
/* riskfactor is already scaled to per-block amount */ |
|
|
@ -458,10 +456,6 @@ find_route(const tal_t *ctx, struct routing_state *rstate, |
|
|
|
struct node *n, *src, *dst; |
|
|
|
struct node_map_iter it; |
|
|
|
int runs, i, best; |
|
|
|
/* Call time_now() once at the start, so that our tight loop
|
|
|
|
* does not keep calling into operating system for the |
|
|
|
* current time */ |
|
|
|
time_t now = time_now().ts.tv_sec; |
|
|
|
|
|
|
|
/* Note: we map backwards, since we know the amount of satoshi we want
|
|
|
|
* at the end, and need to derive how much we need to send. */ |
|
|
@ -518,7 +512,7 @@ find_route(const tal_t *ctx, struct routing_state *rstate, |
|
|
|
&n->id), |
|
|
|
i, num_edges); |
|
|
|
|
|
|
|
if (!hc_is_routable(chan, idx, now)) { |
|
|
|
if (!hc_is_routable(chan, idx)) { |
|
|
|
SUPERVERBOSE("...unroutable (local_disabled = %i, is_halfchan_enabled = %i, unroutable_until = %i", |
|
|
|
chan->local_disabled, |
|
|
|
is_halfchan_enabled(&chan->half[idx]), |
|
|
@ -1040,9 +1034,6 @@ static void set_connection_values(struct chan *chan, |
|
|
|
c->last_timestamp = timestamp; |
|
|
|
assert((c->channel_flags & ROUTING_FLAGS_DIRECTION) == idx); |
|
|
|
|
|
|
|
/* If it was temporarily unroutable, re-enable */ |
|
|
|
c->unroutable_until = 0; |
|
|
|
|
|
|
|
SUPERVERBOSE("Channel %s/%d was updated.", |
|
|
|
type_to_string(tmpctx, struct short_channel_id, &chan->scid), |
|
|
|
idx); |
|
|
@ -1583,17 +1574,12 @@ static void routing_failure_channel_out(const tal_t *disposal_context, |
|
|
|
struct chan *chan, |
|
|
|
time_t now) |
|
|
|
{ |
|
|
|
struct half_chan *hc = half_chan_from(node, chan); |
|
|
|
|
|
|
|
/* BOLT #4:
|
|
|
|
* |
|
|
|
* - if the PERM bit is NOT set: |
|
|
|
* - SHOULD restore the channels as it receives new `channel_update`s. |
|
|
|
*/ |
|
|
|
if (!(failcode & PERM)) |
|
|
|
/* Prevent it for 20 seconds. */ |
|
|
|
hc->unroutable_until = now + 20; |
|
|
|
else |
|
|
|
if (failcode & PERM) |
|
|
|
/* Set it up to be pruned. */ |
|
|
|
tal_steal(disposal_context, chan); |
|
|
|
} |
|
|
@ -1692,27 +1678,6 @@ void routing_failure(struct routing_state *rstate, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void mark_channel_unroutable(struct routing_state *rstate, |
|
|
|
const struct short_channel_id *channel) |
|
|
|
{ |
|
|
|
struct chan *chan; |
|
|
|
time_t now = time_now().ts.tv_sec; |
|
|
|
const char *scid = type_to_string(tmpctx, struct short_channel_id, |
|
|
|
channel); |
|
|
|
|
|
|
|
status_trace("Received mark_channel_unroutable channel %s", |
|
|
|
scid); |
|
|
|
|
|
|
|
chan = get_channel(rstate, channel); |
|
|
|
if (!chan) { |
|
|
|
status_unusual("mark_channel_unroutable: " |
|
|
|
"channel %s not in routemap", |
|
|
|
scid); |
|
|
|
return; |
|
|
|
} |
|
|
|
chan->half[0].unroutable_until = now + 20; |
|
|
|
chan->half[1].unroutable_until = now + 20; |
|
|
|
} |
|
|
|
|
|
|
|
void route_prune(struct routing_state *rstate) |
|
|
|
{ |
|
|
|