mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-07 08:04:23 +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:
@@ -7,6 +7,7 @@
|
||||
#include "bitcoin/script.h"
|
||||
#include "bitcoin/shadouble.h"
|
||||
#include "channel.h"
|
||||
#include "htlc.h"
|
||||
#include "lightning.pb-c.h"
|
||||
#include "netaddr.h"
|
||||
#include "protobuf_convert.h"
|
||||
@@ -24,18 +25,18 @@ enum htlc_stage_type {
|
||||
|
||||
struct htlc_add {
|
||||
enum htlc_stage_type add;
|
||||
struct channel_htlc htlc;
|
||||
struct htlc *htlc;
|
||||
};
|
||||
|
||||
struct htlc_fulfill {
|
||||
enum htlc_stage_type fulfill;
|
||||
u64 id;
|
||||
struct htlc *htlc;
|
||||
struct rval r;
|
||||
};
|
||||
|
||||
struct htlc_fail {
|
||||
enum htlc_stage_type fail;
|
||||
u64 id;
|
||||
struct htlc *htlc;
|
||||
};
|
||||
|
||||
union htlc_staging {
|
||||
@@ -95,6 +96,9 @@ struct peer_visible_state {
|
||||
|
||||
/* cstate to generate next commitment tx. */
|
||||
struct channel_state *staging_cstate;
|
||||
|
||||
/* HTLCs offered by this side */
|
||||
struct htlc_map htlcs;
|
||||
};
|
||||
|
||||
struct out_pkt {
|
||||
@@ -240,6 +244,16 @@ void add_acked_changes(union htlc_staging **acked,
|
||||
void peer_both_committed_to(struct peer *peer,
|
||||
const union htlc_staging *changes, enum channel_side side);
|
||||
|
||||
/* Freeing removes from map, too */
|
||||
struct htlc *peer_new_htlc(struct peer *peer,
|
||||
u64 id,
|
||||
u64 msatoshis,
|
||||
const struct sha256 *rhash,
|
||||
u32 expiry,
|
||||
const u8 *route,
|
||||
size_t route_len,
|
||||
enum channel_side side);
|
||||
|
||||
/* Peer has recieved revocation. */
|
||||
void peer_update_complete(struct peer *peer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user