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

Function forwarding_first

wallet/wallet.c:5613–5757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5611}
5612
5613struct db_stmt *forwarding_first(struct wallet *w,
5614 enum forward_status status,
5615 const struct short_channel_id *chan_in,
5616 const struct short_channel_id *chan_out,
5617 const enum wait_index *listindex,
5618 u64 liststart,
5619 const u32 *listlimit)
5620{
5621 struct db_stmt *stmt;
5622
5623 // placeholder for any parameter, the value doesn't matter because it's discarded by sql
5624 const int any = -1;
5625
5626 /* We don't support start/limits with this */
5627 if (chan_in || chan_out) {
5628 stmt = db_prepare_v2(
5629 w->db,
5630 SQL("SELECT"
5631 " state"
5632 ", in_msatoshi"
5633 ", out_msatoshi"
5634 ", in_channel_scid"
5635 ", out_channel_scid"
5636 ", in_htlc_id"
5637 ", out_htlc_id"
5638 ", received_time"
5639 ", resolved_time"
5640 ", failcode "
5641 ", forward_style "
5642 ", rowid "
5643 ", updated_index "
5644 "FROM forwards "
5645 "WHERE (1 = ? OR state = ?) AND "
5646 "(1 = ? OR in_channel_scid = ?) AND "
5647 "(1 = ? OR out_channel_scid = ?)"));
5648
5649 if (status == FORWARD_ANY) {
5650 // any status
5651 db_bind_int(stmt, 1);
5652 db_bind_int(stmt, any);
5653 } else {
5654 // specific forward status
5655 db_bind_int(stmt, 0);
5656 db_bind_int(stmt, status);
5657 }
5658
5659 if (chan_in) {
5660 // specific in_channel
5661 db_bind_int(stmt, 0);
5662 db_bind_short_channel_id(stmt, *chan_in);
5663 } else {
5664 // any in_channel
5665 db_bind_int(stmt, 1);
5666 db_bind_int(stmt, any);
5667 }
5668
5669 if (chan_out) {
5670 // specific out_channel

Callers 1

Calls 5

db_bind_intFunction · 0.85
db_bind_short_channel_idFunction · 0.85
db_bind_u64Function · 0.85
db_query_preparedFunction · 0.85
forwarding_nextFunction · 0.85

Tested by

no test coverage detected