Skip to content

Commit 402b85f

Browse files
committed
Calculate hold_time for attribution data
We initialise time of creating htlc_out and calculate the time when this htlc_out is failed. Key Changes: - Add 'send_timestamp' to htlc_out. - Calculate hold_time when htlc_out is failed.
1 parent fa8c1b3 commit 402b85f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lightningd/htlc_end.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
269269
struct amount_msat final_msat,
270270
u64 partid,
271271
u64 groupid,
272-
struct htlc_in *in)
272+
struct htlc_in *in,
273+
struct timeabs send_timestamp)
273274
{
274275
struct htlc_out *hout = tal(ctx, struct htlc_out);
275276

@@ -305,6 +306,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
305306

306307
}
307308
hout->in = NULL;
309+
hout->send_timestamp = send_timestamp;
308310
if (in) {
309311
htlc_out_connect_htlc_in(hout, in);
310312

lightningd/htlc_end.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ struct htlc_out {
106106

107107
/* Timer we use in case they don't add an HTLC in a timely manner. */
108108
struct oneshot *timeout;
109+
110+
struct timeabs send_timestamp;
109111
};
110112

111113
static inline const struct htlc_key *keyof_htlc_in(const struct htlc_in *in)
@@ -172,7 +174,8 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
172174
struct amount_msat final_msat,
173175
u64 partid,
174176
u64 groupid,
175-
struct htlc_in *in);
177+
struct htlc_in *in,
178+
struct timeabs send_timestamp);
176179

177180
void connect_htlc_in(struct htlc_in_map *map, struct htlc_in *hin);
178181
void connect_htlc_out(struct htlc_out_map *map, struct htlc_out *hout);

lightningd/peer_htlcs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ static void fail_out_htlc(struct htlc_out *hout, const char *localfail)
313313
hout->failmsg,
314314
localfail);
315315
} else if (hout->in) {
316-
const struct onionreply *failonion;
317-
316+
const u32 hold_times = time_between(time_now(), hout->send_timestamp).ts.tv_nsec/1000000;
318317
/* If we have an onion, simply copy it. */
319318
if (hout->failonion)
320319
failonion = hout->failonion;
@@ -731,7 +730,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
731730
payment_hash, onion_routing_packet,
732731
path_key, in == NULL,
733732
final_msat,
734-
partid, groupid, in);
733+
partid, groupid, in, time_now());
735734
tal_add_destructor(*houtp, destroy_hout_subd_died);
736735

737736
/* Give channel 30 seconds to commit this htlc. */
@@ -1074,7 +1073,7 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
10741073
" Ignoring 'failure_message'.");
10751074

10761075
fail_in_htlc(hin, take(new_onionreply(NULL,
1077-
failonion)));
1076+
failonion, NULL, NULL)));
10781077
return false;
10791078
}
10801079
if (!failmsgtok) {

0 commit comments

Comments
 (0)