Skip to content

Commit

Permalink
patch debug.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyrussell committed Feb 10, 2024
1 parent 3f80fb4 commit 9b47e74
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions gossipd/gossmap_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ static void remove_channel(struct gossmap_manage *gm,
/* Delete from store */
gossip_store_del(gm->daemon->gs, chan->cann_off, WIRE_CHANNEL_ANNOUNCEMENT);
for (int dir = 0; dir < 2; dir++) {
if (gossmap_chan_set(chan, dir))
if (gossmap_chan_set(chan, dir)) {
status_debug("gossmap: marking channel_update dying at %u",
chan->cupdate_off[dir]);
gossip_store_del(gm->daemon->gs, chan->cupdate_off[dir], WIRE_CHANNEL_UPDATE);
}
}

/* Check for node_announcements which should no longer be there */
Expand Down Expand Up @@ -304,10 +307,13 @@ static void remove_channel(struct gossmap_manage *gm,

/* Be sure to set DYING flag when we move (ignore current
* channel, we haven't reloaded gossmap yet!) */
if (all_node_channels_dying(gossmap, node, chan))
if (all_node_channels_dying(gossmap, node, chan)) {
status_debug("gossmap: moving node_announcement (dying) at %"PRIu64, offset);
gossip_store_set_flag(gm->daemon->gs, offset,
GOSSIP_STORE_DYING_BIT,
WIRE_NODE_ANNOUNCEMENT);
} else
status_debug("gossmap: moving node_announcement not dying at %"PRIu64, offset);
}
}

Expand Down Expand Up @@ -747,11 +753,13 @@ static const char *process_channel_update(const tal_t *ctx,

/* If channel is dying, make sure update is also marked dying! */
if (gossmap_chan_is_dying(gossmap, chan)) {
status_debug("gossmap: adding channel_update (dying) at %"PRIu64, offset);
gossip_store_set_flag(gm->daemon->gs,
offset,
GOSSIP_STORE_DYING_BIT,
WIRE_CHANNEL_UPDATE);
}
} else
status_debug("gossmap: adding channel_update (not dying) at %"PRIu64, offset);

/* Now delete old */
if (gossmap_chan_set(chan, dir))
Expand Down Expand Up @@ -898,10 +906,12 @@ static void process_node_announcement(struct gossmap_manage *gm,
offset = gossip_store_add(gm->daemon->gs, nannounce, timestamp);
/* If all channels are dying, make sure this is marked too. */
if (all_node_channels_dying(gossmap, node, NULL)) {
status_debug("gossmap: adding node_announcement (dying) at %"PRIu64, offset);
gossip_store_set_flag(gm->daemon->gs, offset,
GOSSIP_STORE_DYING_BIT,
WIRE_NODE_ANNOUNCEMENT);
}
} else
status_debug("gossmap: adding node_announcement (not dying) at %"PRIu64, offset);

/* Now delete old */
if (gossmap_node_announced(node))
Expand Down Expand Up @@ -1250,11 +1260,15 @@ void gossmap_manage_channel_spent(struct gossmap_manage *gm,

/* Are all (other) channels dying? */
if (all_node_channels_dying(gossmap, n, chan)) {
status_debug("gossmap: setting node_announcement dying (channel spent) at %u",
n->nann_off);
gossip_store_set_flag(gm->daemon->gs,
n->nann_off,
GOSSIP_STORE_DYING_BIT,
WIRE_NODE_ANNOUNCEMENT);
}
} else
status_debug("gossmap: NOT setting node_announcement dying (channel spent) at %u",
n->nann_off);
}
}

Expand Down Expand Up @@ -1455,6 +1469,15 @@ void gossmap_check_dying(struct gossmap_manage *gm)
for (size_t i = 0; i < n->num_chans; i++) {
struct gossmap_chan *c = gossmap_nth_chan(gossmap, n, i, NULL);
bool chan_dying = gossmap_chan_is_dying(gossmap, c);
struct node_id node_id;
struct short_channel_id scid = gossmap_chan_scid(gossmap, c);

gossmap_node_get_id(gossmap, n, &node_id);
status_debug("node %s @%u: chan %s is %s",
type_to_string(tmpctx, struct node_id, &node_id),
n->nann_off,
type_to_string(tmpctx, struct short_channel_id, &scid),
chan_dying ? "dying" : "not dying");

if (!chan_dying)
all_chans_dying = false;
Expand Down

0 comments on commit 9b47e74

Please sign in to comment.