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

Function save_complete_layer

plugins/askrene/layer.c:710–770  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

708}
709
710static void save_complete_layer(struct layer *layer)
711{
712 struct local_channel_hash_iter lcit;
713 const struct local_channel *lc;
714 const struct local_update *lu;
715 struct local_update_hash_iter luit;
716 struct constraint_hash_iter conit;
717 const struct constraint *c;
718 struct bias_hash_iter biasit;
719 const struct bias *b;
720 struct node_bias_hash_iter nbiasit;
721 const struct node_bias *nb;
722 struct out_req *req;
723 u8 *data;
724
725 if (!layer->persistent)
726 return;
727
728 data = tal_arr(tmpctx, u8, 0);
729 for (size_t i = 0; i < tal_count(layer->disabled_nodes); i++)
730 towire_dstore_disabled_node(&data, &layer->disabled_nodes[i]);
731
732 for (lc = local_channel_hash_first(layer->local_channels, &lcit);
733 lc;
734 lc = local_channel_hash_next(layer->local_channels, &lcit)) {
735 towire_save_channel(&data, lc);
736 }
737 for (lu = local_update_hash_first(layer->local_updates, &luit);
738 lu;
739 lu = local_update_hash_next(layer->local_updates, &luit)) {
740 towire_save_channel_update(&data, lu);
741 }
742 for (c = constraint_hash_first(layer->constraints, &conit);
743 c;
744 c = constraint_hash_next(layer->constraints, &conit)) {
745 /* Don't save ones we generated internally */
746 if (c->timestamp == UINT64_MAX)
747 continue;
748 towire_save_channel_constraint(&data, c);
749 }
750 for (b = bias_hash_first(layer->biases, &biasit);
751 b;
752 b = bias_hash_next(layer->biases, &biasit)) {
753 towire_save_channel_bias(&data, b);
754 }
755 for (nb = node_bias_hash_first(layer->node_biases, &nbiasit); nb;
756 nb = node_bias_hash_next(layer->node_biases, &nbiasit)) {
757 towire_save_node_bias(&data, nb);
758 }
759
760 /* Wholesale replacement */
761 req = jsonrpc_request_start(layer->askrene->layer_cmd,
762 "datastore",
763 ignore_result,
764 plugin_broken_cb,
765 NULL);
766 json_add_layer_key(req->js, "key", layer);
767 json_add_hex_talarr(req->js, "hex", data);

Callers 2

new_layerFunction · 0.85
layer_trim_constraintsFunction · 0.85

Calls 10

towire_save_channelFunction · 0.85
towire_save_channel_biasFunction · 0.85
towire_save_node_biasFunction · 0.85
json_add_layer_keyFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_add_stringFunction · 0.50
send_outreqFunction · 0.50

Tested by

no test coverage detected