diff --git a/plugins/askrene/layer.c b/plugins/askrene/layer.c index 7850079dbf05..f83dfb0f4876 100644 --- a/plugins/askrene/layer.c +++ b/plugins/askrene/layer.c @@ -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);