db_bind_scid: rename to db_bind_short_channel_id

We used to have a text version, so this was named 'scid'.  Fix it now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-03-20 10:47:35 +10:30
parent ae861d1793
commit d9e274cee2
4 changed files with 32 additions and 32 deletions

View file

@ -159,7 +159,7 @@ void db_bind_pubkey(struct db_stmt *stmt, int pos, const struct pubkey *pk)
db_bind_blob(stmt, pos, der, PUBKEY_CMPR_LEN); db_bind_blob(stmt, pos, der, PUBKEY_CMPR_LEN);
} }
void db_bind_scid(struct db_stmt *stmt, int col, void db_bind_short_channel_id(struct db_stmt *stmt, int col,
const struct short_channel_id *id) const struct short_channel_id *id)
{ {
db_bind_u64(stmt, col, id->u64); db_bind_u64(stmt, col, id->u64);
@ -361,7 +361,7 @@ void db_col_pubkey(struct db_stmt *stmt,
assert(ok); assert(ok);
} }
void db_col_scid(struct db_stmt *stmt, const char *colname, void db_col_short_channel_id(struct db_stmt *stmt, const char *colname,
struct short_channel_id *dest) struct short_channel_id *dest)
{ {
dest->u64 = db_col_u64(stmt, colname); dest->u64 = db_col_u64(stmt, colname);

View file

@ -37,7 +37,7 @@ void db_bind_node_id(struct db_stmt *stmt, int pos, const struct node_id *ni);
void db_bind_node_id_arr(struct db_stmt *stmt, int col, void db_bind_node_id_arr(struct db_stmt *stmt, int col,
const struct node_id *ids); const struct node_id *ids);
void db_bind_pubkey(struct db_stmt *stmt, int pos, const struct pubkey *p); void db_bind_pubkey(struct db_stmt *stmt, int pos, const struct pubkey *p);
void db_bind_scid(struct db_stmt *stmt, int col, void db_bind_short_channel_id(struct db_stmt *stmt, int col,
const struct short_channel_id *id); const struct short_channel_id *id);
void db_bind_short_channel_id_arr(struct db_stmt *stmt, int col, void db_bind_short_channel_id_arr(struct db_stmt *stmt, int col,
const struct short_channel_id *id); const struct short_channel_id *id);
@ -83,7 +83,7 @@ struct node_id *db_col_node_id_arr(const tal_t *ctx, struct db_stmt *stmt,
const char *colname); const char *colname);
void db_col_pubkey(struct db_stmt *stmt, const char *colname, void db_col_pubkey(struct db_stmt *stmt, const char *colname,
struct pubkey *p); struct pubkey *p);
void db_col_scid(struct db_stmt *stmt, const char *colname, void db_col_short_channel_id(struct db_stmt *stmt, const char *colname,
struct short_channel_id *dest); struct short_channel_id *dest);
struct short_channel_id * struct short_channel_id *
db_col_short_channel_id_arr(const tal_t *ctx, struct db_stmt *stmt, const char *colname); db_col_short_channel_id_arr(const tal_t *ctx, struct db_stmt *stmt, const char *colname);

View file

@ -1485,7 +1485,7 @@ static void migrate_channels_scids_as_integers(struct lightningd *ld,
stmt = db_prepare_v2(db, SQL("UPDATE channels" stmt = db_prepare_v2(db, SQL("UPDATE channels"
" SET scid = ?" " SET scid = ?"
" WHERE short_channel_id = ?")); " WHERE short_channel_id = ?"));
db_bind_scid(stmt, 0, &scid); db_bind_short_channel_id(stmt, 0, &scid);
db_bind_text(stmt, 1, scids[i]); db_bind_text(stmt, 1, scids[i]);
db_exec_prepared_v2(stmt); db_exec_prepared_v2(stmt);
@ -1540,7 +1540,7 @@ static void migrate_payments_scids_as_integers(struct lightningd *ld,
update_stmt = db_prepare_v2(db, SQL("UPDATE payments SET" update_stmt = db_prepare_v2(db, SQL("UPDATE payments SET"
" failscid = ?" " failscid = ?"
" WHERE id = ?")); " WHERE id = ?"));
db_bind_scid(update_stmt, 0, &scid); db_bind_short_channel_id(update_stmt, 0, &scid);
db_bind_u64(update_stmt, 1, db_col_u64(stmt, "id")); db_bind_u64(update_stmt, 1, db_col_u64(stmt, "id"));
db_exec_prepared_v2(update_stmt); db_exec_prepared_v2(update_stmt);
tal_free(update_stmt); tal_free(update_stmt);

View file

@ -1317,21 +1317,21 @@ static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stm
if (!db_col_is_null(stmt, "scid")) { if (!db_col_is_null(stmt, "scid")) {
scid = tal(tmpctx, struct short_channel_id); scid = tal(tmpctx, struct short_channel_id);
db_col_scid(stmt, "scid", scid); db_col_short_channel_id(stmt, "scid", scid);
} else { } else {
scid = NULL; scid = NULL;
} }
if (!db_col_is_null(stmt, "alias_local")) { if (!db_col_is_null(stmt, "alias_local")) {
alias[LOCAL] = tal(tmpctx, struct short_channel_id); alias[LOCAL] = tal(tmpctx, struct short_channel_id);
db_col_scid(stmt, "alias_local", alias[LOCAL]); db_col_short_channel_id(stmt, "alias_local", alias[LOCAL]);
} else { } else {
alias[LOCAL] = NULL; alias[LOCAL] = NULL;
} }
if (!db_col_is_null(stmt, "alias_remote")) { if (!db_col_is_null(stmt, "alias_remote")) {
alias[REMOTE] = tal(tmpctx, struct short_channel_id); alias[REMOTE] = tal(tmpctx, struct short_channel_id);
db_col_scid(stmt, "alias_remote", alias[REMOTE]); db_col_short_channel_id(stmt, "alias_remote", alias[REMOTE]);
} else { } else {
alias[REMOTE] = NULL; alias[REMOTE] = NULL;
} }
@ -1928,7 +1928,7 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
" WHERE id=?")); // 46 " WHERE id=?")); // 46
db_bind_u64(stmt, 0, chan->their_shachain.id); db_bind_u64(stmt, 0, chan->their_shachain.id);
if (chan->scid) if (chan->scid)
db_bind_scid(stmt, 1, chan->scid); db_bind_short_channel_id(stmt, 1, chan->scid);
else else
db_bind_null(stmt, 1); db_bind_null(stmt, 1);
@ -1995,12 +1995,12 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
db_bind_amount_msat(stmt, 43, &chan->htlc_maximum_msat); db_bind_amount_msat(stmt, 43, &chan->htlc_maximum_msat);
if (chan->alias[LOCAL] != NULL) if (chan->alias[LOCAL] != NULL)
db_bind_scid(stmt, 44, chan->alias[LOCAL]); db_bind_short_channel_id(stmt, 44, chan->alias[LOCAL]);
else else
db_bind_null(stmt, 44); db_bind_null(stmt, 44);
if (chan->alias[REMOTE] != NULL) if (chan->alias[REMOTE] != NULL)
db_bind_scid(stmt, 45, chan->alias[REMOTE]); db_bind_short_channel_id(stmt, 45, chan->alias[REMOTE]);
else else
db_bind_null(stmt, 45); db_bind_null(stmt, 45);
@ -3482,7 +3482,7 @@ void wallet_payment_get_failinfo(const tal_t *ctx,
*failchannel = NULL; *failchannel = NULL;
} else { } else {
*failchannel = tal(ctx, struct short_channel_id); *failchannel = tal(ctx, struct short_channel_id);
db_col_scid(stmt, "failscid", *failchannel); db_col_short_channel_id(stmt, "failscid", *failchannel);
/* For pre-0.6.2 dbs, direction will be 0 */ /* For pre-0.6.2 dbs, direction will be 0 */
*faildirection = db_col_int(stmt, "faildirection"); *faildirection = db_col_int(stmt, "faildirection");
@ -3541,7 +3541,7 @@ void wallet_payment_set_failinfo(struct wallet *wallet,
db_bind_null(stmt, 4); db_bind_null(stmt, 4);
if (failchannel) { if (failchannel) {
db_bind_scid(stmt, 5, failchannel); db_bind_short_channel_id(stmt, 5, failchannel);
db_bind_int(stmt, 8, faildirection); db_bind_int(stmt, 8, faildirection);
} else { } else {
db_bind_null(stmt, 5); db_bind_null(stmt, 5);
@ -4379,7 +4379,7 @@ static bool wallet_forwarded_payment_update(struct wallet *w,
else else
db_bind_int(stmt, 5, forward_style_in_db(forward_style)); db_bind_int(stmt, 5, forward_style_in_db(forward_style));
db_bind_u64(stmt, 6, in->key.id); db_bind_u64(stmt, 6, in->key.id);
db_bind_scid(stmt, 7, channel_scid_or_local_alias(in->key.channel)); db_bind_short_channel_id(stmt, 7, channel_scid_or_local_alias(in->key.channel));
db_exec_prepared_v2(stmt); db_exec_prepared_v2(stmt);
changed = db_count_changes(stmt) != 0; changed = db_count_changes(stmt) != 0;
tal_free(stmt); tal_free(stmt);
@ -4439,10 +4439,10 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
* the sender used to specify the channel, but that's under * the sender used to specify the channel, but that's under
* control of the remote end. */ * control of the remote end. */
assert(in->key.channel->scid != NULL || in->key.channel->alias[LOCAL]); assert(in->key.channel->scid != NULL || in->key.channel->alias[LOCAL]);
db_bind_scid(stmt, 2, channel_scid_or_local_alias(in->key.channel)); db_bind_short_channel_id(stmt, 2, channel_scid_or_local_alias(in->key.channel));
if (scid_out) if (scid_out)
db_bind_scid(stmt, 3, scid_out); db_bind_short_channel_id(stmt, 3, scid_out);
else else
db_bind_null(stmt, 3); db_bind_null(stmt, 3);
db_bind_amount_msat(stmt, 4, &in->msat); db_bind_amount_msat(stmt, 4, &in->msat);
@ -4571,7 +4571,7 @@ const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
if (chan_in) { if (chan_in) {
// specific in_channel // specific in_channel
db_bind_int(stmt, 2, 0); db_bind_int(stmt, 2, 0);
db_bind_scid(stmt, 3, chan_in); db_bind_short_channel_id(stmt, 3, chan_in);
} else { } else {
// any in_channel // any in_channel
db_bind_int(stmt, 2, 1); db_bind_int(stmt, 2, 1);
@ -4581,7 +4581,7 @@ const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
if (chan_out) { if (chan_out) {
// specific out_channel // specific out_channel
db_bind_int(stmt, 4, 0); db_bind_int(stmt, 4, 0);
db_bind_scid(stmt, 5, chan_out); db_bind_short_channel_id(stmt, 5, chan_out);
} else { } else {
// any out_channel // any out_channel
db_bind_int(stmt, 4, 1); db_bind_int(stmt, 4, 1);
@ -4615,7 +4615,7 @@ const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
cur->fee = AMOUNT_MSAT(0); cur->fee = AMOUNT_MSAT(0);
} }
db_col_scid(stmt, "in_channel_scid", &cur->channel_in); db_col_short_channel_id(stmt, "in_channel_scid", &cur->channel_in);
#ifdef COMPAT_V0121 #ifdef COMPAT_V0121
/* This can happen due to migration! */ /* This can happen due to migration! */
@ -4628,7 +4628,7 @@ const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
#endif #endif
if (!db_col_is_null(stmt, "out_channel_scid")) { if (!db_col_is_null(stmt, "out_channel_scid")) {
db_col_scid(stmt, "out_channel_scid", &cur->channel_out); db_col_short_channel_id(stmt, "out_channel_scid", &cur->channel_out);
} else { } else {
assert(cur->status == FORWARD_LOCAL_FAILED); assert(cur->status == FORWARD_LOCAL_FAILED);
cur->channel_out.u64 = 0; cur->channel_out.u64 = 0;
@ -4685,7 +4685,7 @@ bool wallet_forward_delete(struct wallet *w,
" WHERE in_channel_scid = ?" " WHERE in_channel_scid = ?"
" AND in_htlc_id = ?" " AND in_htlc_id = ?"
" AND state = ?;")); " AND state = ?;"));
db_bind_scid(stmt, 0, chan_in); db_bind_short_channel_id(stmt, 0, chan_in);
db_bind_u64(stmt, 1, *htlc_id); db_bind_u64(stmt, 1, *htlc_id);
db_bind_int(stmt, 2, wallet_forward_status_in_db(FORWARD_SETTLED)); db_bind_int(stmt, 2, wallet_forward_status_in_db(FORWARD_SETTLED));
} else { } else {
@ -4695,7 +4695,7 @@ bool wallet_forward_delete(struct wallet *w,
" WHERE in_channel_scid = ?" " WHERE in_channel_scid = ?"
" AND in_htlc_id IS NULL" " AND in_htlc_id IS NULL"
" AND state = ?;")); " AND state = ?;"));
db_bind_scid(stmt, 0, chan_in); db_bind_short_channel_id(stmt, 0, chan_in);
db_bind_int(stmt, 1, wallet_forward_status_in_db(FORWARD_SETTLED)); db_bind_int(stmt, 1, wallet_forward_status_in_db(FORWARD_SETTLED));
} }
db_query_prepared(stmt); db_query_prepared(stmt);
@ -4718,7 +4718,7 @@ bool wallet_forward_delete(struct wallet *w,
" WHERE in_channel_scid = ?" " WHERE in_channel_scid = ?"
" AND in_htlc_id = ?" " AND in_htlc_id = ?"
" AND state = ?")); " AND state = ?"));
db_bind_scid(stmt, 0, chan_in); db_bind_short_channel_id(stmt, 0, chan_in);
db_bind_u64(stmt, 1, *htlc_id); db_bind_u64(stmt, 1, *htlc_id);
db_bind_int(stmt, 2, wallet_forward_status_in_db(state)); db_bind_int(stmt, 2, wallet_forward_status_in_db(state));
} else { } else {
@ -4727,7 +4727,7 @@ bool wallet_forward_delete(struct wallet *w,
" WHERE in_channel_scid = ?" " WHERE in_channel_scid = ?"
" AND in_htlc_id IS NULL" " AND in_htlc_id IS NULL"
" AND state = ?")); " AND state = ?"));
db_bind_scid(stmt, 0, chan_in); db_bind_short_channel_id(stmt, 0, chan_in);
db_bind_int(stmt, 1, wallet_forward_status_in_db(state)); db_bind_int(stmt, 1, wallet_forward_status_in_db(state));
} }
db_exec_prepared_v2(stmt); db_exec_prepared_v2(stmt);
@ -4822,7 +4822,7 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t
got_ann: got_ann:
ann->type = db_col_int(stmt, "annotation_type"); ann->type = db_col_int(stmt, "annotation_type");
if (!db_col_is_null(stmt, "c.scid")) if (!db_col_is_null(stmt, "c.scid"))
db_col_scid(stmt, "c.scid", &ann->channel); db_col_short_channel_id(stmt, "c.scid", &ann->channel);
else else
ann->channel.u64 = 0; ann->channel.u64 = 0;
} else { } else {
@ -5453,9 +5453,9 @@ struct wallet_htlc_iter *wallet_htlcs_next(struct wallet *w,
*scid = iter->scid; *scid = iter->scid;
else { else {
if (db_col_is_null(iter->stmt, "channels.scid")) if (db_col_is_null(iter->stmt, "channels.scid"))
db_col_scid(iter->stmt, "channels.alias_local", scid); db_col_short_channel_id(iter->stmt, "channels.alias_local", scid);
else { else {
db_col_scid(iter->stmt, "channels.scid", scid); db_col_short_channel_id(iter->stmt, "channels.scid", scid);
db_col_ignore(iter->stmt, "channels.alias_local"); db_col_ignore(iter->stmt, "channels.alias_local");
} }
} }