From 7cd9272ba9fdfde278b25c1ed33cb9cf3142694e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Aug 2016 14:23:46 +0930 Subject: [PATCH] htlc: htlc_is_dead() helper. Signed-off-by: Rusty Russell --- daemon/htlc.h | 7 +++++++ daemon/peer.c | 9 ++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/daemon/htlc.h b/daemon/htlc.h index 89ec29e14..e4f76e52d 100644 --- a/daemon/htlc.h +++ b/daemon/htlc.h @@ -138,4 +138,11 @@ static inline size_t htlc_map_count(const struct htlc_map *htlcs) { 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 */ diff --git a/daemon/peer.c b/daemon/peer.c index ed4c0486b..5d93877db 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -313,11 +313,7 @@ static bool committed_to_htlcs(const struct peer *peer) for (h = htlc_map_first(&peer->htlcs, &it); h; h = htlc_map_next(&peer->htlcs, &it)) { - /* FIXME: Move these dead ones to a separate hash (or - * just leave in database only). */ - if (h->state == RCVD_REMOVE_ACK_REVOCATION) - continue; - if (h->state == SENT_REMOVE_ACK_REVOCATION) + if (htlc_is_dead(h)) continue; return true; } @@ -3156,8 +3152,7 @@ static void json_add_htlcs(struct json_result *response, continue; /* Ignore completed HTLCs. */ - if (h->state == RCVD_REMOVE_ACK_REVOCATION - || h->state == SENT_REMOVE_ACK_REVOCATION) + if (htlc_is_dead(h)) continue; json_object_start(response, NULL);