Skip to content

Commit

Permalink
askrene: don't create duplicate layers if xpay creates layer before w…
Browse files Browse the repository at this point in the history
…e load them.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Nov 19, 2024
1 parent 1380d36 commit 1b2d5ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugins/askrene/layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,19 @@ static void populate_layer(struct askrene *askrene,
const char *layername TAKES,
const u8 *data)
{
struct layer *layer = new_layer(askrene, layername, true);
struct layer *layer;
size_t len = tal_bytelen(data);

/* FIXME: They can race us, creating a layer while we're loading! */
layer = find_layer(askrene, layername);
if (layer) {
/* We promised to take this! */
if (taken(layername))
tal_free(layername);
} else {
layer = new_layer(askrene, layername, true);
}

plugin_log(askrene->plugin, LOG_DBG,
"Loaded level %s (%zu bytes)",
layer->name, len);
Expand Down

0 comments on commit 1b2d5ac

Please sign in to comment.