mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 02:39:28 +01:00
onchain: Load HTLC stubs upon starting onchaind
This wires in the loading of `struct htlc_stub`s on-demand when starting `onchaind` so that we don't need to keep them in memory. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
49ed7c9ab0
commit
a668cb4f2b
1 changed files with 10 additions and 3 deletions
|
@ -1400,6 +1400,7 @@ static enum watch_result funding_spent(struct peer *peer,
|
|||
struct sha256_double our_last_txid;
|
||||
s64 keyindex;
|
||||
struct pubkey ourkey;
|
||||
struct htlc_stub *stubs;
|
||||
|
||||
peer_fail_permanent_str(peer, "Funding transaction spent");
|
||||
|
||||
|
@ -1419,6 +1420,12 @@ static enum watch_result funding_spent(struct peer *peer,
|
|||
return KEEP_WATCHING;
|
||||
}
|
||||
|
||||
stubs = wallet_htlc_stubs(peer, peer->ld->wallet, peer->channel);
|
||||
if (!stubs) {
|
||||
log_broken(peer->log, "Could not load htlc_stubs");
|
||||
return KEEP_WATCHING;
|
||||
}
|
||||
|
||||
/* We re-use this key to send other outputs to. */
|
||||
if (peer->local_shutdown_idx >= 0)
|
||||
keyindex = peer->local_shutdown_idx;
|
||||
|
@ -1469,14 +1476,14 @@ static enum watch_result funding_spent(struct peer *peer,
|
|||
/* FIXME: config for 'reasonable depth' */
|
||||
3,
|
||||
peer->last_htlc_sigs,
|
||||
tal_count(peer->htlcs));
|
||||
tal_count(stubs));
|
||||
subd_send_msg(peer->owner, take(msg));
|
||||
|
||||
/* FIXME: Don't queue all at once, use an empty cb... */
|
||||
for (size_t i = 0; i < tal_count(peer->htlcs); i++) {
|
||||
for (size_t i = 0; i < tal_count(stubs); i++) {
|
||||
bool tell_immediate;
|
||||
bool tell = tell_if_missing(peer, i, &tell_immediate);
|
||||
msg = towire_onchain_htlc(peer, peer->htlcs+i,
|
||||
msg = towire_onchain_htlc(peer, &stubs[i],
|
||||
tell, tell_immediate);
|
||||
subd_send_msg(peer->owner, take(msg));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue