MCPcopy Create free account
hub / github.com/ElementsProject/lightning / plugin_response_handle

Function plugin_response_handle

lightningd/plugin.c:563–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561 WARN_UNUSED_RESULT;
562
563static const char *plugin_response_handle(struct plugin *plugin,
564 const jsmntok_t *toks,
565 const jsmntok_t *idtok)
566{
567 struct plugin_destroyed *pd;
568 struct jsonrpc_request *request;
569
570 request = strmap_getn(&plugin->plugins->pending_requests,
571 plugin->buffer + idtok->start,
572 idtok->end - idtok->start);
573 if (!request) {
574 return tal_fmt(
575 plugin,
576 "Received a JSON-RPC response for non-existent request");
577 }
578
579 /* We expect the request->cb to copy if needed */
580 pd = plugin_detect_destruction(plugin);
581 request->response_cb(plugin->buffer, toks, idtok, request->response_cb_arg);
582
583 /* Note that in the case of 'plugin stop' this can free request (since
584 * plugin is parent), so detect that case */
585 if (!was_plugin_destroyed(pd))
586 tal_free(request);
587
588 return NULL;
589}
590
591/**
592 * Try to parse a complete message from the plugin's buffer.

Callers 1

plugin_read_json_oneFunction · 0.85

Calls 3

was_plugin_destroyedFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected