Skip to content

Commit 3606cb1

Browse files
committed
askrene: expose additional_costs htable so child can access it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent ce0a752 commit 3606cb1

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

plugins/askrene/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PLUGIN_ASKRENE_CHILD_SRC := \
1717
plugins/askrene/child/child_log.c \
1818

1919
PLUGIN_ASKRENE_SRC := $(PLUGIN_ASKRENE_PARENT_SRC) $(PLUGIN_ASKRENE_CHILD_SRC)
20-
PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h)
20+
PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h) plugins/askrene/child/additional_costs.h
2121

2222
PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o)
2323

plugins/askrene/askrene.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,14 @@
2222
#include <inttypes.h>
2323
#include <math.h>
2424
#include <plugins/askrene/askrene.h>
25+
#include <plugins/askrene/child/additional_costs.h>
2526
#include <plugins/askrene/child/child_log.h>
2627
#include <plugins/askrene/child/entry.h>
2728
#include <plugins/askrene/layer.h>
2829
#include <plugins/askrene/reserve.h>
2930
#include <sys/wait.h>
3031
#include <wire/wire_sync.h>
3132

32-
/* "spendable" for a channel assumes a single HTLC: for additional HTLCs,
33-
* the need to pay for fees (if we're the owner) reduces it */
34-
struct per_htlc_cost {
35-
struct short_channel_id_dir scidd;
36-
struct amount_msat per_htlc_cost;
37-
};
38-
39-
static const struct short_channel_id_dir *
40-
per_htlc_cost_key(const struct per_htlc_cost *phc)
41-
{
42-
return &phc->scidd;
43-
}
44-
45-
static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc,
46-
const struct short_channel_id_dir *scidd)
47-
{
48-
return short_channel_id_dir_eq(scidd, &phc->scidd);
49-
}
50-
51-
HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost,
52-
per_htlc_cost_key,
53-
hash_scidd,
54-
per_htlc_cost_eq_key,
55-
additional_cost_htable);
56-
5733
static bool have_layer(const char **layers, const char *name)
5834
{
5935
for (size_t i = 0; i < tal_count(layers); i++) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
2+
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
3+
#include "config.h"
4+
#include <ccan/htable/htable_type.h>
5+
#include <ccan/tal/tal.h>
6+
7+
/* "spendable" for a channel assumes a single HTLC: for additional HTLCs,
8+
* the need to pay for fees (if we're the owner) reduces it */
9+
struct per_htlc_cost {
10+
struct short_channel_id_dir scidd;
11+
struct amount_msat per_htlc_cost;
12+
};
13+
14+
static inline const struct short_channel_id_dir *
15+
per_htlc_cost_key(const struct per_htlc_cost *phc)
16+
{
17+
return &phc->scidd;
18+
}
19+
20+
static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc,
21+
const struct short_channel_id_dir *scidd)
22+
{
23+
return short_channel_id_dir_eq(scidd, &phc->scidd);
24+
}
25+
26+
HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost,
27+
per_htlc_cost_key,
28+
hash_scidd,
29+
per_htlc_cost_eq_key,
30+
additional_cost_htable);
31+
32+
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H */

0 commit comments

Comments
 (0)