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

Function destroy_hout_subd_died

lightningd/peer_htlcs.c:459–486  ·  view source on GitHub ↗

* A catchall in case outgoing peer disconnects before getting fwd. * * We could queue this and wait for it to come back, but this is simple. */

Source from the content-addressed store, hash-verified

457 * We could queue this and wait for it to come back, but this is simple.
458 */
459static void destroy_hout_subd_died(struct htlc_out *hout)
460{
461 struct db *db = hout->key.channel->peer->ld->wallet->db;
462 /* Under some circumstances we may need to start a DB
463 * transaction and commit it here again. This is the case when
464 * we're getting called from the destructor chain. */
465 bool have_tx =
466 db_in_transaction(db);
467 log_debug(hout->key.channel->log,
468 "Failing HTLC %"PRIu64" due to peer death",
469 hout->key.id);
470
471 hout->failmsg = towire_temporary_channel_failure(hout,
472 get_channel_update(hout->key.channel));
473
474 /* Assign a temporary state (we're about to free it!) so checks
475 * are happy that it has a failure message */
476 assert(hout->hstate == SENT_ADD_HTLC);
477 hout->hstate = RCVD_REMOVE_HTLC;
478
479 if (!have_tx)
480 db_begin_transaction(db);
481
482 fail_out_htlc(hout, "Outgoing subdaemon died");
483
484 if (!have_tx)
485 db_commit_transaction(db);
486}
487
488/* This is where channeld gives us the HTLC id, and also reports if it
489 * failed immediately. */

Callers

nothing calls this directly

Calls 5

fail_out_htlcFunction · 0.85
get_channel_updateFunction · 0.70
db_in_transactionFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected