Skip to content

Commit 30b8179

Browse files
committed
askrene: move routines only accessed by the child process into child/.
We want to make it clear when future generations edit the code, which routines are called in the child (i.e. all the routing), and which in the parent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent edc5ead commit 30b8179

27 files changed

+72
-79
lines changed

plugins/askrene/Makefile

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
PLUGIN_ASKRENE_SRC := \
1+
PLUGIN_ASKRENE_PARENT_SRC := \
22
plugins/askrene/askrene.c \
33
plugins/askrene/datastore_wire.c \
44
plugins/askrene/layer.c \
55
plugins/askrene/reserve.c \
6-
plugins/askrene/mcf.c \
7-
plugins/askrene/dijkstra.c \
8-
plugins/askrene/flow.c \
9-
plugins/askrene/refine.c \
10-
plugins/askrene/explain_failure.c \
11-
plugins/askrene/graph.c \
12-
plugins/askrene/priorityqueue.c \
13-
plugins/askrene/algorithm.c \
6+
7+
PLUGIN_ASKRENE_CHILD_SRC := \
8+
plugins/askrene/child/mcf.c \
9+
plugins/askrene/child/dijkstra.c \
10+
plugins/askrene/child/flow.c \
11+
plugins/askrene/child/refine.c \
12+
plugins/askrene/child/explain_failure.c \
13+
plugins/askrene/child/graph.c \
14+
plugins/askrene/child/priorityqueue.c \
15+
plugins/askrene/child/algorithm.c \
1416
plugins/askrene/child/child_log.c \
1517

16-
PLUGIN_ASKRENE_HEADER := \
17-
plugins/askrene/askrene.h \
18-
plugins/askrene/datastore_wire.h \
19-
plugins/askrene/layer.h \
20-
plugins/askrene/reserve.h \
21-
plugins/askrene/mcf.h \
22-
plugins/askrene/dijkstra.h \
23-
plugins/askrene/flow.h \
24-
plugins/askrene/refine.h \
25-
plugins/askrene/explain_failure.h \
26-
plugins/askrene/graph.h \
27-
plugins/askrene/priorityqueue.h \
28-
plugins/askrene/algorithm.h \
29-
plugins/askrene/child/child_log.h \
18+
PLUGIN_ASKRENE_SRC := $(PLUGIN_ASKRENE_PARENT_SRC) $(PLUGIN_ASKRENE_CHILD_SRC)
19+
PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h)
3020

3121
PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o)
3222

plugins/askrene/askrene.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include <math.h>
2727
#include <plugins/askrene/askrene.h>
2828
#include <plugins/askrene/child/child_log.h>
29-
#include <plugins/askrene/flow.h>
29+
#include <plugins/askrene/child/flow.h>
30+
#include <plugins/askrene/child/mcf.h>
3031
#include <plugins/askrene/layer.h>
31-
#include <plugins/askrene/mcf.h>
3232
#include <plugins/askrene/reserve.h>
3333
#include <sys/wait.h>
3434
#include <unistd.h>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "config.h"
22
#include <ccan/bitmap/bitmap.h>
33
#include <ccan/tal/tal.h>
4-
#include <plugins/askrene/algorithm.h>
5-
#include <plugins/askrene/priorityqueue.h>
4+
#include <plugins/askrene/child/algorithm.h>
5+
#include <plugins/askrene/child/priorityqueue.h>
66

77
static const s64 INFINITE = INT64_MAX;
88

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#ifndef LIGHTNING_PLUGINS_ASKRENE_ALGORITHM_H
2-
#define LIGHTNING_PLUGINS_ASKRENE_ALGORITHM_H
1+
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_ALGORITHM_H
2+
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_ALGORITHM_H
33

44
/* Implementation of network algorithms: shortests path, minimum cost flow, etc.
55
*/
66

77
#include "config.h"
8-
#include <plugins/askrene/graph.h>
8+
#include <plugins/askrene/child/graph.h>
99

1010
/* Search any path from source to destination using Breadth First Search.
1111
*
@@ -176,4 +176,4 @@ bool mcf_refinement(const tal_t *ctx,
176176
const s64 *cost,
177177
s64 *potential);
178178

179-
#endif /* LIGHTNING_PLUGINS_ASKRENE_ALGORITHM_H */
179+
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_ALGORITHM_H */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define NDEBUG 1
22
#include "config.h"
3-
#include <plugins/askrene/dijkstra.h>
3+
#include <plugins/askrene/child/dijkstra.h>
44

55
/* In the heap we keep node idx, but in this structure we keep the distance
66
* value associated to every node, and their position in the heap as a pointer
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNING_PLUGINS_ASKRENE_DIJKSTRA_H
2-
#define LIGHTNING_PLUGINS_ASKRENE_DIJKSTRA_H
1+
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_DIJKSTRA_H
2+
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_DIJKSTRA_H
33
#include "config.h"
44
#include <ccan/short_types/short_types.h>
55
#include <ccan/tal/tal.h>
@@ -27,4 +27,4 @@ size_t dijkstra_size(const struct dijkstra *dijkstra);
2727
/* Maximum number of elements the heap can host */
2828
size_t dijkstra_maxsize(const struct dijkstra *dijkstra);
2929

30-
#endif /* LIGHTNING_PLUGINS_ASKRENE_DIJKSTRA_H */
30+
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_DIJKSTRA_H */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <common/gossmap.h>
55
#include <common/route.h>
66
#include <plugins/askrene/askrene.h>
7-
#include <plugins/askrene/explain_failure.h>
7+
#include <plugins/askrene/child/explain_failure.h>
88
#include <plugins/askrene/layer.h>
99
#include <plugins/askrene/reserve.h>
1010

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNING_PLUGINS_ASKRENE_EXPLAIN_FAILURE_H
2-
#define LIGHTNING_PLUGINS_ASKRENE_EXPLAIN_FAILURE_H
1+
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_EXPLAIN_FAILURE_H
2+
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_EXPLAIN_FAILURE_H
33
#include "config.h"
44
#include <common/amount.h>
55

@@ -13,4 +13,4 @@ const char *explain_failure(const tal_t *ctx,
1313
const struct gossmap_node *dstnode,
1414
struct amount_msat amount);
1515

16-
#endif /* LIGHTNING_PLUGINS_ASKRENE_EXPLAIN_FAILURE_H */
16+
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_EXPLAIN_FAILURE_H */
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <common/overflows.h>
77
#include <math.h>
88
#include <plugins/askrene/askrene.h>
9-
#include <plugins/askrene/flow.h>
9+
#include <plugins/askrene/child/flow.h>
1010
#include <plugins/libplugin.h>
1111
#include <stdio.h>
1212

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNING_PLUGINS_ASKRENE_FLOW_H
2-
#define LIGHTNING_PLUGINS_ASKRENE_FLOW_H
1+
#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_FLOW_H
2+
#define LIGHTNING_PLUGINS_ASKRENE_CHILD_FLOW_H
33
#include "config.h"
44
#include <bitcoin/short_channel_id.h>
55
#include <common/amount.h>
@@ -66,4 +66,4 @@ const char *fmt_flows_step_scid(const tal_t *ctx,
6666
const char *fmt_flow_full(const tal_t *ctx,
6767
const struct route_query *rq,
6868
const struct flow *flow);
69-
#endif /* LIGHTNING_PLUGINS_ASKRENE_FLOW_H */
69+
#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_FLOW_H */

0 commit comments

Comments
 (0)