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

Function populate_layer

plugins/askrene/layer.c:759–805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757}
758
759static void populate_layer(struct askrene *askrene,
760 const char *layername TAKES,
761 const u8 *data)
762{
763 struct layer *layer;
764 size_t len = tal_bytelen(data);
765
766 layer = add_layer(askrene, layername, true);
767 plugin_log(askrene->plugin, LOG_DBG,
768 "Loaded level %s (%zu bytes)",
769 layer->name, len);
770
771 while (len != 0) {
772 enum dstore_layer_type type;
773 type = fromwire_peektypen(data, len);
774
775 switch (type) {
776 case DSTORE_CHANNEL:
777 load_channel(askrene->plugin, layer, &data, &len);
778 continue;
779 case DSTORE_CHANNEL_UPDATE:
780 load_channel_update(askrene->plugin, layer, &data, &len);
781 continue;
782 case DSTORE_CHANNEL_CONSTRAINT:
783 load_channel_constraint(askrene->plugin, layer, &data, &len);
784 continue;
785 case DSTORE_CHANNEL_BIAS:
786 load_channel_bias(askrene->plugin, layer, &data, &len);
787 continue;
788 case DSTORE_CHANNEL_BIAS_V2:
789 load_channel_bias_v2(askrene->plugin, layer, &data, &len);
790 continue;
791 case DSTORE_DISABLED_NODE:
792 load_disabled_node(askrene->plugin, layer, &data, &len);
793 continue;
794 case DSTORE_NODE_BIAS:
795 load_node_bias(askrene->plugin, layer, &data, &len);
796 continue;
797 }
798 plugin_err(askrene->plugin, "Invalid type %i in datastore: layer %s %s",
799 type, layer->name, tal_hexstr(tmpctx, data, len));
800 }
801 if (!data)
802 plugin_log(askrene->plugin, LOG_BROKEN,
803 "%s: invalid data in datastore",
804 layer->name);
805}
806
807void load_layers(struct askrene *askrene, struct command *init_cmd)
808{

Callers 1

load_layersFunction · 0.85

Calls 13

tal_bytelenFunction · 0.85
fromwire_peektypenFunction · 0.85
load_channelFunction · 0.85
load_channel_updateFunction · 0.85
load_channel_constraintFunction · 0.85
load_channel_biasFunction · 0.85
load_channel_bias_v2Function · 0.85
load_disabled_nodeFunction · 0.85
load_node_biasFunction · 0.85
tal_hexstrFunction · 0.85
add_layerFunction · 0.70
plugin_logFunction · 0.50

Tested by

no test coverage detected