askrene: expose additional_costs htable so child can access it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2026-02-16 17:34:33 +10:30
parent 0f575ac85a
commit 85c9179f77
3 changed files with 34 additions and 26 deletions

View File

@@ -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)

View File

@@ -22,6 +22,7 @@
#include <inttypes.h>
#include <math.h>
#include <plugins/askrene/askrene.h>
#include <plugins/askrene/child/additional_costs.h>
#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/entry.h>
#include <plugins/askrene/layer.h>
@@ -29,31 +30,6 @@
#include <sys/wait.h>
#include <wire/wire_sync.h>
/* "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++) {

View File

@@ -0,0 +1,32 @@
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
#include "config.h"
#include <ccan/htable/htable_type.h>
#include <ccan/tal/tal.h>
/* "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 */