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

Function json_add_events

plugins/bkpr/bookkeeper.c:732–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

730}
731
732static void json_add_events(struct json_stream *res,
733 const struct bkpr *bkpr,
734 struct channel_event **channel_events,
735 struct chain_event **chain_events,
736 struct onchain_fee **onchain_fees)
737{
738 for (size_t i = 0, j = 0, k = 0;
739 i < tal_count(chain_events)
740 || j < tal_count(channel_events)
741 || k < tal_count(onchain_fees);
742 /* Incrementing happens inside loop */) {
743 struct channel_event *chan;
744 struct chain_event *chain;
745 struct onchain_fee *fee;
746 u64 lowest = 0;
747
748 if (i < tal_count(chain_events))
749 chain = chain_events[i];
750 else
751 chain = NULL;
752 if (j < tal_count(channel_events))
753 chan = channel_events[j];
754 else
755 chan = NULL;
756 if (k < tal_count(onchain_fees))
757 fee = onchain_fees[k];
758 else
759 fee = NULL;
760
761 if (chain)
762 lowest = chain->timestamp;
763
764 if (chan
765 && (lowest == 0 || lowest > chan->timestamp))
766 lowest = chan->timestamp;
767
768 if (fee
769 && (lowest == 0 || lowest > fee->timestamp))
770 lowest = fee->timestamp;
771
772 /* chain events first, then channel events, then fees. */
773 if (chain && chain->timestamp == lowest) {
774 json_add_chain_event(res, bkpr, chain);
775 i++;
776 continue;
777 }
778
779 if (chan && chan->timestamp == lowest) {
780 json_add_channel_event(res, bkpr, chan);
781 j++;
782 continue;
783 }
784
785 /* Last thing left is the fee */
786 json_add_onchain_fee(res, bkpr, fee);
787 k++;
788 }
789}

Callers 3

do_account_eventsFunction · 0.85
do_edit_descFunction · 0.85
do_edit_desc_paymentFunction · 0.85

Calls 3

json_add_chain_eventFunction · 0.70
json_add_channel_eventFunction · 0.70
json_add_onchain_feeFunction · 0.70

Tested by

no test coverage detected