mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
daemon: use htlc pointers everywhere.
No more copies! I tried changing the cstate->side[].htlcs to htlc_map rather than a simple pointer array, but we rely on those array indices heavily for permutation mapping, and it turned into a major rewrite (especially for the steal case). Eventually, we're going to want to reconstruct the commit info for older commit txs rather than keeping all the permutation and per-commit-info HTLC information in memory, so we can do the work then. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
static bool add_htlc(struct bitcoin_tx *tx, size_t n,
|
||||
const struct channel_htlc *h,
|
||||
const struct htlc *h,
|
||||
const struct pubkey *ourkey,
|
||||
const struct pubkey *theirkey,
|
||||
const struct sha256 *rhash,
|
||||
@@ -96,7 +96,7 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx,
|
||||
|
||||
/* HTLCs this side sent. */
|
||||
for (i = 0; i < tal_count(cstate->side[side].htlcs); i++) {
|
||||
if (!add_htlc(tx, num, &cstate->side[side].htlcs[i],
|
||||
if (!add_htlc(tx, num, cstate->side[side].htlcs[i],
|
||||
self, other, rhash, locktime,
|
||||
bitcoin_redeem_htlc_send))
|
||||
return tal_free(tx);
|
||||
@@ -104,7 +104,7 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx,
|
||||
}
|
||||
/* HTLCs this side has received. */
|
||||
for (i = 0; i < tal_count(cstate->side[!side].htlcs); i++) {
|
||||
if (!add_htlc(tx, num, &cstate->side[!side].htlcs[i],
|
||||
if (!add_htlc(tx, num, cstate->side[!side].htlcs[i],
|
||||
self, other, rhash, locktime,
|
||||
bitcoin_redeem_htlc_recv))
|
||||
return tal_free(tx);
|
||||
|
||||
Reference in New Issue
Block a user