From 85c9179f77b25f4b859a846619a6c3729da9b973 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 16 Feb 2026 17:34:33 +1030 Subject: [PATCH] askrene: expose additional_costs htable so child can access it. Signed-off-by: Rusty Russell --- plugins/askrene/Makefile | 2 +- plugins/askrene/askrene.c | 26 +------------------ plugins/askrene/child/additional_costs.h | 32 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 plugins/askrene/child/additional_costs.h diff --git a/plugins/askrene/Makefile b/plugins/askrene/Makefile index fd8e9f516..d870b0a5b 100644 --- a/plugins/askrene/Makefile +++ b/plugins/askrene/Makefile @@ -17,7 +17,7 @@ PLUGIN_ASKRENE_CHILD_SRC := \ plugins/askrene/child/child_log.c \ PLUGIN_ASKRENE_SRC := $(PLUGIN_ASKRENE_PARENT_SRC) $(PLUGIN_ASKRENE_CHILD_SRC) -PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h) +PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h) plugins/askrene/child/additional_costs.h PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o) diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c index b1384299c..ef6d3a712 100644 --- a/plugins/askrene/askrene.c +++ b/plugins/askrene/askrene.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,31 +30,6 @@ #include #include -/* "spendable" for a channel assumes a single HTLC: for additional HTLCs, - * the need to pay for fees (if we're the owner) reduces it */ -struct per_htlc_cost { - struct short_channel_id_dir scidd; - struct amount_msat per_htlc_cost; -}; - -static const struct short_channel_id_dir * -per_htlc_cost_key(const struct per_htlc_cost *phc) -{ - return &phc->scidd; -} - -static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc, - const struct short_channel_id_dir *scidd) -{ - return short_channel_id_dir_eq(scidd, &phc->scidd); -} - -HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost, - per_htlc_cost_key, - hash_scidd, - per_htlc_cost_eq_key, - additional_cost_htable); - static bool have_layer(const char **layers, const char *name) { for (size_t i = 0; i < tal_count(layers); i++) { diff --git a/plugins/askrene/child/additional_costs.h b/plugins/askrene/child/additional_costs.h new file mode 100644 index 000000000..44eb0971f --- /dev/null +++ b/plugins/askrene/child/additional_costs.h @@ -0,0 +1,32 @@ +#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H +#define LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H +#include "config.h" +#include +#include + +/* "spendable" for a channel assumes a single HTLC: for additional HTLCs, + * the need to pay for fees (if we're the owner) reduces it */ +struct per_htlc_cost { + struct short_channel_id_dir scidd; + struct amount_msat per_htlc_cost; +}; + +static inline const struct short_channel_id_dir * +per_htlc_cost_key(const struct per_htlc_cost *phc) +{ + return &phc->scidd; +} + +static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc, + const struct short_channel_id_dir *scidd) +{ + return short_channel_id_dir_eq(scidd, &phc->scidd); +} + +HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost, + per_htlc_cost_key, + hash_scidd, + per_htlc_cost_eq_key, + additional_cost_htable); + +#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H */