htlc: htlc_is_dead() helper.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-08-18 14:23:46 +09:30
parent 23f9c7c209
commit 7cd9272ba9
2 changed files with 9 additions and 7 deletions

View file

@ -138,4 +138,11 @@ static inline size_t htlc_map_count(const struct htlc_map *htlcs)
{ {
return htlcs->raw.elems; return htlcs->raw.elems;
} }
/* FIXME: Move these out of the hash! */
static inline bool htlc_is_dead(const struct htlc *htlc)
{
return htlc->state == RCVD_REMOVE_ACK_REVOCATION
|| htlc->state == SENT_REMOVE_ACK_REVOCATION;
}
#endif /* LIGHTNING_DAEMON_HTLC_H */ #endif /* LIGHTNING_DAEMON_HTLC_H */

View file

@ -313,11 +313,7 @@ static bool committed_to_htlcs(const struct peer *peer)
for (h = htlc_map_first(&peer->htlcs, &it); for (h = htlc_map_first(&peer->htlcs, &it);
h; h;
h = htlc_map_next(&peer->htlcs, &it)) { h = htlc_map_next(&peer->htlcs, &it)) {
/* FIXME: Move these dead ones to a separate hash (or if (htlc_is_dead(h))
* just leave in database only). */
if (h->state == RCVD_REMOVE_ACK_REVOCATION)
continue;
if (h->state == SENT_REMOVE_ACK_REVOCATION)
continue; continue;
return true; return true;
} }
@ -3156,8 +3152,7 @@ static void json_add_htlcs(struct json_result *response,
continue; continue;
/* Ignore completed HTLCs. */ /* Ignore completed HTLCs. */
if (h->state == RCVD_REMOVE_ACK_REVOCATION if (htlc_is_dead(h))
|| h->state == SENT_REMOVE_ACK_REVOCATION)
continue; continue;
json_object_start(response, NULL); json_object_start(response, NULL);