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

Function json_add_events

plugins/bkpr/bookkeeper.c:708–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708static void json_add_events(struct json_stream *res,
709 const struct bkpr *bkpr,
710 struct channel_event **channel_events,
711 struct chain_event **chain_events,
712 struct onchain_fee **onchain_fees)
713{
714 for (size_t i = 0, j = 0, k = 0;
715 i < tal_count(chain_events)
716 || j < tal_count(channel_events)
717 || k < tal_count(onchain_fees);
718 /* Incrementing happens inside loop */) {
719 struct channel_event *chan;
720 struct chain_event *chain;
721 struct onchain_fee *fee;
722 u64 lowest = 0;
723
724 if (i < tal_count(chain_events))
725 chain = chain_events[i];
726 else
727 chain = NULL;
728 if (j < tal_count(channel_events))
729 chan = channel_events[j];
730 else
731 chan = NULL;
732 if (k < tal_count(onchain_fees))
733 fee = onchain_fees[k];
734 else
735 fee = NULL;
736
737 if (chain)
738 lowest = chain->timestamp;
739
740 if (chan
741 && (lowest == 0 || lowest > chan->timestamp))
742 lowest = chan->timestamp;
743
744 if (fee
745 && (lowest == 0 || lowest > fee->timestamp))
746 lowest = fee->timestamp;
747
748 /* chain events first, then channel events, then fees. */
749 if (chain && chain->timestamp == lowest) {
750 json_add_chain_event(res, bkpr, chain);
751 i++;
752 continue;
753 }
754
755 if (chan && chan->timestamp == lowest) {
756 json_add_channel_event(res, bkpr, chan);
757 j++;
758 continue;
759 }
760
761 /* Last thing left is the fee */
762 json_add_onchain_fee(res, bkpr, fee);
763 k++;
764 }
765}

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