lightningd: remove ltmp context now we have tmpctx.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-03-15 15:00:39 +10:30
parent ccc9414356
commit de5d84097e
11 changed files with 16 additions and 32 deletions

View File

@@ -254,7 +254,7 @@ void broadcast_tx(struct chain_topology *topo,
tal_add_destructor2(channel, clear_otx_channel, otx);
log_add(topo->log, " (tx %s)",
type_to_string(ltmp, struct bitcoin_txid, &otx->txid));
type_to_string(tmpctx, struct bitcoin_txid, &otx->txid));
bitcoind_sendrawtx(topo->bitcoind, otx->hextx, broadcast_done, otx);
}
@@ -407,7 +407,7 @@ static struct block *new_block(struct chain_topology *topo,
sha256_double(&b->blkid.shad, &blk->hdr, sizeof(blk->hdr));
log_debug(topo->log, "Adding block %u: %s",
height,
type_to_string(ltmp, struct bitcoin_blkid, &b->blkid));
type_to_string(tmpctx, struct bitcoin_blkid, &b->blkid));
assert(!block_map_get(&topo->block_map, &b->blkid));
b->next = NULL;
b->prev = NULL;
@@ -433,7 +433,7 @@ static void remove_tip(struct chain_topology *topo)
if (!topo->tip)
fatal("Initial block %u (%s) reorganized out!",
b->height,
type_to_string(ltmp, struct bitcoin_blkid, &b->blkid));
type_to_string(tmpctx, struct bitcoin_blkid, &b->blkid));
/* Notify that txs are kicked out. */
for (i = 0; i < n; i++)

View File

@@ -390,8 +390,8 @@ int main(int argc, char *argv[])
/* Mark ourselves live. */
log_info(ld->log, "Server started with public key %s, alias %s (color #%s) and lightningd %s",
type_to_string(ltmp, struct pubkey, &ld->id),
ld->alias, tal_hex(ltmp, ld->rgb), version());
type_to_string(tmpctx, struct pubkey, &ld->id),
ld->alias, tal_hex(tmpctx, ld->rgb), version());
/* Start the peers. */
activate_peers(ld);

View File

@@ -137,10 +137,6 @@ struct log_book *new_log_book(size_t max_mem,
lr->init_time = time_now();
list_head_init(&lr->log);
/* In case ltmp not initialized, do so now (parent is lightningd log) */
if (!ltmp)
ltmp = notleak(tal(lr, char));
return lr;
}
@@ -225,13 +221,6 @@ static void add_entry(struct log *log, struct log_entry *l)
log_debug(log, "Log pruned %zu entries (mem %zu -> %zu)",
deleted, old_mem, log->lr->mem_used);
}
/* Free up temporaries now if any */
if (tal_first(ltmp)) {
void *parent = tal_parent(ltmp);
tal_free(ltmp);
ltmp = notleak(tal(parent, char));
}
}
static struct log_entry *new_log_entry(struct log *log, enum log_level level)

View File

@@ -93,10 +93,6 @@ void crashlog_activate(const char *argv0, struct log *log);
char *arg_log_to_file(const char *arg, struct lightningd *ld);
/* Convenience parent for temporary allocations (eg. type_to_string)
* during log calls; freed after every log_*() */
const tal_t *ltmp;
/* Before the crashlog is activated, just prints to stderr. */
void NORETURN PRINTF_FMT(1,2) fatal(const char *fmt, ...);

View File

@@ -272,12 +272,12 @@ static bool guess_one_address(struct lightningd *ld,
if (!IsRoutable(addr)) {
log_debug(ld->log, "Address %s is not routable",
type_to_string(ltmp, struct wireaddr, addr));
type_to_string(tmpctx, struct wireaddr, addr));
return false;
}
log_debug(ld->log, "Public address %s",
type_to_string(ltmp, struct wireaddr, addr));
type_to_string(tmpctx, struct wireaddr, addr));
return true;
}

View File

@@ -148,7 +148,7 @@ static void handle_onchain_unwatch_tx(struct channel *channel, const u8 *msg)
txw = find_txwatch(channel->peer->ld->topology, &txid, channel);
if (!txw)
log_unusual(channel->log, "Can't unwatch txid %s",
type_to_string(ltmp, struct bitcoin_txid, &txid));
type_to_string(tmpctx, struct bitcoin_txid, &txid));
tal_free(txw);
}

View File

@@ -275,7 +275,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
goto failed;
}
log_debug(ld->log,
"%s", type_to_string(ltmp, struct pubkey,
"%s", type_to_string(tmpctx, struct pubkey,
&channel_info.remote_per_commit));
/* Generate the funding tx. */
@@ -301,7 +301,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
log_debug(fc->uc->log, "%zi: %"PRIu64" satoshi (%s) %s\n",
i, fc->utxomap[i]->amount,
fc->utxomap[i]->is_p2sh ? "P2SH" : "SEGWIT",
type_to_string(ltmp, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&fundingtx->input[i].txid));
}

View File

@@ -434,7 +434,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
log_unusual(hout->key.channel->log,
"No route_channels for htlc %s:"
" was this an old database?",
type_to_string(ltmp, struct sha256,
type_to_string(tmpctx, struct sha256,
&hout->payment_hash));
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
PAYMENT_FAILED, NULL);
@@ -463,7 +463,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
log_info(hout->key.channel->log,
"htlc %"PRIu64" failed with bad reply (%s)",
hout->key.id,
tal_hex(ltmp, hout->failuremsg));
tal_hex(tmpctx, hout->failuremsg));
/* Cannot report failure. */
fail = NULL;
failcode = WIRE_PERMANENT_NODE_FAILURE;

View File

@@ -216,7 +216,7 @@ static bool txw_fire(struct txwatch *txw,
log_debug(txw->channel->log,
"Got depth change %u->%u for %s",
txw->depth, depth,
type_to_string(ltmp, struct bitcoin_txid, &txw->txid));
type_to_string(tmpctx, struct bitcoin_txid, &txw->txid));
txw->depth = depth;
r = txw->cb(txw->channel, tx, txw->depth);
switch (r) {
@@ -254,9 +254,9 @@ void txowatch_fire(const struct txowatch *txow,
bitcoin_txid(tx, &txid);
log_debug(txow->channel->log,
"Got UTXO spend for %s:%u: %s",
type_to_string(ltmp, struct bitcoin_txid, &txow->out.txid),
type_to_string(tmpctx, struct bitcoin_txid, &txow->out.txid),
txow->out.index,
type_to_string(ltmp, struct bitcoin_txid, &txid));
type_to_string(tmpctx, struct bitcoin_txid, &txid));
r = txow->cb(txow->channel, tx, input_num, block);
switch (r) {

View File

@@ -469,7 +469,6 @@ static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx
w->db = db_open(w, filename);
ltmp = tal_tmpctx(ctx);
list_head_init(&w->unstored_payments);
w->ld = ld;
ld->wallet = w;

View File

@@ -1073,7 +1073,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx,
log_debug(w->log, "Owning output %zu %"PRIu64" (%s) txid %s",
output, tx->output[output].amount,
is_p2sh ? "P2SH" : "SEGWIT",
type_to_string(ltmp, struct bitcoin_txid,
type_to_string(tmpctx, struct bitcoin_txid,
&utxo->txid));
if (!wallet_add_utxo(w, utxo, is_p2sh ? p2sh_wpkh : our_change)) {