mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
lightningd: complete plugin state machine.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1145,6 +1145,7 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
|||||||
plugin_manifest_cb, p);
|
plugin_manifest_cb, p);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(p, req);
|
plugin_request_send(p, req);
|
||||||
|
p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;
|
||||||
|
|
||||||
plugins->pending_manifests++;
|
plugins->pending_manifests++;
|
||||||
/* Don't timeout if they're running a debugger. */
|
/* Don't timeout if they're running a debugger. */
|
||||||
@@ -1232,6 +1233,7 @@ plugin_config(struct plugin *plugin)
|
|||||||
plugin_populate_init_request(plugin, req);
|
plugin_populate_init_request(plugin, req);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(plugin, req);
|
plugin_request_send(plugin, req);
|
||||||
|
plugin->plugin_state = AWAITING_INIT_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugins_config(struct plugins *plugins)
|
void plugins_config(struct plugins *plugins)
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
enum plugin_state {
|
enum plugin_state {
|
||||||
/* We have to ask getmanifest */
|
/* We have to ask getmanifest */
|
||||||
UNCONFIGURED,
|
UNCONFIGURED,
|
||||||
|
/* We sent getmanifest, need response. */
|
||||||
|
AWAITING_GETMANIFEST_RESPONSE,
|
||||||
/* Got `getmanifest` reply, now we need to send `init`. */
|
/* Got `getmanifest` reply, now we need to send `init`. */
|
||||||
NEEDS_INIT,
|
NEEDS_INIT,
|
||||||
/* We have to get `init` response */
|
/* We have to get `init` response */
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ static void plugin_dynamic_config(struct dynamic_plugin *dp)
|
|||||||
plugin_dynamic_config_callback, dp);
|
plugin_dynamic_config_callback, dp);
|
||||||
plugin_populate_init_request(dp->plugin, req);
|
plugin_populate_init_request(dp->plugin, req);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
|
dp->plugin->plugin_state = AWAITING_INIT_RESPONSE;
|
||||||
plugin_request_send(dp->plugin, req);
|
plugin_request_send(dp->plugin, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +113,7 @@ static void plugin_dynamic_manifest_callback(const char *buffer,
|
|||||||
return was_pending(plugin_dynamic_error(dp, "Not a dynamic plugin"));
|
return was_pending(plugin_dynamic_error(dp, "Not a dynamic plugin"));
|
||||||
|
|
||||||
/* We got the manifest, now send the init message */
|
/* We got the manifest, now send the init message */
|
||||||
|
dp->plugin->plugin_state = NEEDS_INIT;
|
||||||
plugin_dynamic_config(dp);
|
plugin_dynamic_config(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +169,7 @@ static struct command_result *plugin_start(struct dynamic_plugin *dp)
|
|||||||
plugin_dynamic_manifest_callback, dp);
|
plugin_dynamic_manifest_callback, dp);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(p, req);
|
plugin_request_send(p, req);
|
||||||
|
p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;
|
||||||
return command_still_pending(dp->cmd);
|
return command_still_pending(dp->cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user