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

Function inject_gossip

gossipd/gossipd.c:871–910  ·  view source on GitHub ↗

~ lightningd tells us when about a gossip message directly, when told to by * the addgossip RPC call. That's usually used when a plugin gets an update * returned in an payment error. */

Source from the content-addressed store, hash-verified

869 * the addgossip RPC call. That's usually used when a plugin gets an update
870 * returned in an payment error. */
871static void inject_gossip(struct daemon *daemon, const u8 *msg)
872{
873 u8 *goss;
874 const u8 *errmsg;
875 const char *err;
876
877 if (!fromwire_gossipd_addgossip(msg, msg, &goss))
878 master_badmsg(WIRE_GOSSIPD_ADDGOSSIP, msg);
879
880 switch (fromwire_peektype(goss)) {
881 case WIRE_CHANNEL_ANNOUNCEMENT:
882 errmsg = handle_channel_announcement_msg(daemon, NULL, goss);
883 break;
884 case WIRE_NODE_ANNOUNCEMENT:
885 errmsg = handle_node_announcement(daemon->rstate, goss,
886 NULL, NULL);
887 break;
888 case WIRE_CHANNEL_UPDATE:
889 errmsg = handle_channel_update(daemon->rstate, goss,
890 NULL, NULL, true);
891 break;
892 default:
893 err = tal_fmt(tmpctx, "unknown gossip type %i",
894 fromwire_peektype(goss));
895 goto err_extracted;
896 }
897
898 /* The APIs above are designed to send error messages back to peers:
899 * we extract the raw string instead. */
900 if (errmsg) {
901 err = sanitize_error(tmpctx, errmsg, NULL);
902 tal_free(errmsg);
903 } else
904 /* Send empty string if no error. */
905 err = "";
906
907err_extracted:
908 daemon_conn_send(daemon->master,
909 take(towire_gossipd_addgossip_reply(NULL, err)));
910}
911
912static void handle_new_lease_rates(struct daemon *daemon, const u8 *msg)
913{

Callers 1

recv_reqFunction · 0.85

Calls 8

tal_freeFunction · 0.85
handle_node_announcementFunction · 0.70
handle_channel_updateFunction · 0.70
master_badmsgFunction · 0.50
fromwire_peektypeFunction · 0.50
sanitize_errorFunction · 0.50
daemon_conn_sendFunction · 0.50

Tested by

no test coverage detected