gossipd: fix gossip_store calling delete.

Now we handle node_announcements properly, we have a failure case where we
try to move them when a channel is deleted while loading the store.

We're going to remove this soon, in favor of in-place delete, so
workaround this for now to avoid an assert() when we try to write to
the store while loading.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-05-29 14:05:47 +09:30 committed by neil saitug
parent 21fe518513
commit 763697eb4c
3 changed files with 15 additions and 0 deletions

View File

@ -645,3 +645,9 @@ out:
gs->len);
gs->writable = true;
}
/* FIXME: Remove */
bool gossip_store_loading(const struct gossip_store *gs)
{
return !gs->writable;
}

View File

@ -74,4 +74,7 @@ bool gossip_store_compact(struct gossip_store *gs,
*/
int gossip_store_readonly_fd(struct gossip_store *gs);
/* FIXME: Remove */
bool gossip_store_loading(const struct gossip_store *gs);
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */

View File

@ -337,6 +337,12 @@ static void remove_chan_from_node(struct routing_state *rstate,
if (!node->bcast.index)
return;
/* FIXME: Remove when we get rid of WIRE_GOSSIP_STORE_CHANNEL_DELETE.
* For the moment, it can cause us to try to write to the store. */
(void)WIRE_GOSSIP_STORE_CHANNEL_DELETE;
if (gossip_store_loading(rstate->broadcasts->gs))
return;
/* Removed only public channel? Remove node announcement. */
if (!node_has_broadcastable_channels(node)) {
broadcast_del(rstate->broadcasts, &node->bcast);