Browse Source

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>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
a668cb4f2b
  1. 13
      lightningd/peer_control.c

13
lightningd/peer_control.c

@ -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…
Cancel
Save