From 940053d00002355174e29c1b9be67cae263e6fa7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 2 Feb 2017 14:35:45 +1030 Subject: [PATCH] htlc: move enum side crom daemon/channel.h to daemon/htlc.h lightningd wants htlcs, but not the old struct channel. Signed-off-by: Rusty Russell --- daemon/channel.h | 26 +------------------------- daemon/commit_tx.h | 1 + daemon/htlc.h | 27 ++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/daemon/channel.h b/daemon/channel.h index 22d049139..ca199389d 100644 --- a/daemon/channel.h +++ b/daemon/channel.h @@ -2,19 +2,12 @@ #define LIGHTNING_DAEMON_CHANNEL_H #include "config.h" #include "bitcoin/locktime.h" +#include "daemon/htlc.h" #include #include -#include #include #include -struct htlc; - -enum side { - LOCAL, - REMOTE -}; - struct channel_oneside { /* Payment and fee is in millisatoshi. */ uint32_t pay_msat, fee_msat; @@ -144,21 +137,4 @@ void force_add_htlc(struct channel_state *cstate, const struct htlc *htlc); void force_fail_htlc(struct channel_state *cstate, const struct htlc *htlc); void force_fulfill_htlc(struct channel_state *cstate, const struct htlc *htlc); bool balance_after_force(struct channel_state *cstate); - -static inline const char *side_to_str(enum side side) -{ - switch (side) { - case LOCAL: return "LOCAL"; - case REMOTE: return "REMOTE"; - } - abort(); -} - -static inline enum side str_to_side(const char *str) -{ - if (streq(str, "LOCAL")) - return LOCAL; - assert(streq(str, "REMOTE")); - return REMOTE; -} #endif /* LIGHTNING_DAEMON_CHANNEL_H */ diff --git a/daemon/commit_tx.h b/daemon/commit_tx.h index 33ef97509..c1ab61db1 100644 --- a/daemon/commit_tx.h +++ b/daemon/commit_tx.h @@ -2,6 +2,7 @@ #define LIGHTNING_COMMIT_TX_H #include "config.h" #include "htlc.h" +#include struct channel_state; struct sha256; diff --git a/daemon/htlc.h b/daemon/htlc.h index 513c245b5..7a6e959a1 100644 --- a/daemon/htlc.h +++ b/daemon/htlc.h @@ -2,7 +2,6 @@ #define LIGHTNING_DAEMON_HTLC_H #include "config.h" #include "bitcoin/locktime.h" -#include "channel.h" #include "htlc_state.h" #include "pseudorand.h" #include @@ -10,6 +9,13 @@ #include #include #include +#include + +enum side { + LOCAL, + REMOTE, + NUM_SIDES +}; /* What are we doing: adding or removing? */ #define HTLC_ADDING 0x400 @@ -143,4 +149,23 @@ static inline bool htlc_is_dead(const struct htlc *htlc) return htlc->state == RCVD_REMOVE_ACK_REVOCATION || htlc->state == SENT_REMOVE_ACK_REVOCATION; } + + +static inline const char *side_to_str(enum side side) +{ + switch (side) { + case LOCAL: return "LOCAL"; + case REMOTE: return "REMOTE"; + case NUM_SIDES: break; + } + abort(); +} + +static inline enum side str_to_side(const char *str) +{ + if (streq(str, "LOCAL")) + return LOCAL; + assert(streq(str, "REMOTE")); + return REMOTE; +} #endif /* LIGHTNING_DAEMON_HTLC_H */