renepay: clean up ARC_ADDITIONAL_BITS.

It's expressed in bits, but really it's clearer as a quantity, given
how it's used.

Suggested-by: @Lagrang3
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-08-02 07:07:55 +09:30
parent 15c8a6f6fe
commit 67e43ea868

View file

@ -189,10 +189,6 @@
// cost function arcs. // cost function arcs.
static const double CHANNEL_PIVOTS[]={0,0.5,0.8,0.95}; static const double CHANNEL_PIVOTS[]={0,0.5,0.8,0.95};
// how many bits for linearization parts plus 1 bit for the direction of the
// channel plus 1 bit for the dual representation.
static const size_t ARC_ADDITIONAL_BITS = PARTS_BITS + 2;
static const s64 INFINITE = INT64_MAX; static const s64 INFINITE = INT64_MAX;
static const u32 INVALID_INDEX=0xffffffff; static const u32 INVALID_INDEX=0xffffffff;
static const s64 MU_MAX = 128; static const s64 MU_MAX = 128;
@ -275,6 +271,10 @@ struct arc {
#define ARC_CHANIDX_BITOFF (1 + PARTS_BITS + 1) #define ARC_CHANIDX_BITOFF (1 + PARTS_BITS + 1)
#define ARC_CHANIDX_BITS (32 - ARC_CHANIDX_BITOFF) #define ARC_CHANIDX_BITS (32 - ARC_CHANIDX_BITOFF)
/* How many arcs can we have for a single channel?
* linearization parts, both directions, and dual */
#define ARCS_PER_CHANNEL ((size_t)1 << (PARTS_BITS + 1 + 1))
static inline void arc_to_parts(struct arc arc, static inline void arc_to_parts(struct arc arc,
u32 *chanidx, u32 *chanidx,
int *chandir, int *chandir,
@ -575,7 +575,7 @@ static void init_linear_network(
struct linear_network *linear_network) struct linear_network *linear_network)
{ {
const size_t max_num_chans = gossmap_max_chan_idx(params->gossmap); const size_t max_num_chans = gossmap_max_chan_idx(params->gossmap);
const size_t max_num_arcs = max_num_chans << ARC_ADDITIONAL_BITS; const size_t max_num_arcs = max_num_chans * ARCS_PER_CHANNEL;
const size_t max_num_nodes = gossmap_max_node_idx(params->gossmap); const size_t max_num_nodes = gossmap_max_node_idx(params->gossmap);
linear_network->max_num_arcs = max_num_arcs; linear_network->max_num_arcs = max_num_arcs;