Skip to content

Commit

Permalink
wallet: cleanup the tal context in wallet_channels_load_active() and …
Browse files Browse the repository at this point in the history
…wallet_stmt2channel()

The original idea is to "tal" channel on the "ctx"(In fact, we'd like to set ctx as "ld").
But we already tal channel on "ld" in new_channel(), so "ctx" is unused.
  • Loading branch information
trueptolemy authored and rustyrussell committed May 18, 2019
1 parent 6ee2cd8 commit 0f42985
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ void load_channels_from_wallet(struct lightningd *ld)
struct peer *peer;

/* Load peers from database */
if (!wallet_channels_load_active(ld, ld->wallet))
if (!wallet_channels_load_active(ld->wallet))
fatal("Could not load channels from the database");

/* This is a poor-man's db join :( */
Expand Down
2 changes: 1 addition & 1 deletion lightningd/test/run-invoice-select-inchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void wallet_channel_delete(struct wallet *w UNNEEDED, u64 wallet_id UNNEEDED)
void wallet_channel_save(struct wallet *w UNNEEDED, struct channel *chan UNNEEDED)
{ fprintf(stderr, "wallet_channel_save called!\n"); abort(); }
/* Generated stub for wallet_channels_load_active */
bool wallet_channels_load_active(const tal_t *ctx UNNEEDED, struct wallet *w UNNEEDED)
bool wallet_channels_load_active(struct wallet *w UNNEEDED)
{ fprintf(stderr, "wallet_channels_load_active called!\n"); abort(); }
/* Generated stub for wallet_channel_stats_load */
void wallet_channel_stats_load(struct wallet *w UNNEEDED, u64 cdbid UNNEEDED, struct channel_stats *stats UNNEEDED)
Expand Down
2 changes: 1 addition & 1 deletion wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ static struct channel *wallet_channel_load(struct wallet *w, const u64 dbid)
struct channel *channel;

/* We expect only one peer, but reuse same code */
if (!wallet_channels_load_active(w, w))
if (!wallet_channels_load_active(w))
return NULL;
peer = list_top(&w->ld->peers, struct peer, list);
CHECK(peer);
Expand Down
6 changes: 3 additions & 3 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ wallet_htlc_sigs_load(const tal_t *ctx, struct wallet *w, u64 channelid)
/**
* wallet_stmt2channel - Helper to populate a wallet_channel from a sqlite3_stmt
*/
static struct channel *wallet_stmt2channel(const tal_t *ctx, struct wallet *w, sqlite3_stmt *stmt)
static struct channel *wallet_stmt2channel(struct wallet *w, sqlite3_stmt *stmt)
{
bool ok = true;
struct channel_info channel_info;
Expand Down Expand Up @@ -767,7 +767,7 @@ static const char *channel_fields =
/*41*/ "last_sent_commit, "
/*42*/ "feerate_base, feerate_ppm, remote_upfront_shutdown_script";

bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w)
bool wallet_channels_load_active(struct wallet *w)
{
bool ok = true;
sqlite3_stmt *stmt;
Expand All @@ -779,7 +779,7 @@ bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w)

int count = 0;
while (db_select_step(w->db, stmt)) {
struct channel *c = wallet_stmt2channel(ctx, w, stmt);
struct channel *c = wallet_stmt2channel(w, stmt);
if (!c) {
ok = false;
db_stmt_done(stmt);
Expand Down
3 changes: 1 addition & 2 deletions wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,12 @@ bool wallet_channel_config_load(struct wallet *w, const u64 id,
/**
* wlalet_channels_load_active -- Load persisted active channels into the peers
*
* @ctx: context to allocate peers from
* @w: wallet to load from
*
* Be sure to call this only once on startup since it'll append peers
* loaded from the database to the list without checking.
*/
bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w);
bool wallet_channels_load_active(struct wallet *w);

/**
* wallet_channel_stats_incr_* - Increase channel statistics.
Expand Down

0 comments on commit 0f42985

Please sign in to comment.