| 939 | } |
| 940 | |
| 941 | void layer_apply_biases(const struct layer *layer, |
| 942 | const struct gossmap *gossmap, |
| 943 | s8 *biases) |
| 944 | { |
| 945 | struct bias *bias; |
| 946 | struct bias_hash_iter it; |
| 947 | struct node_bias *node_bias; |
| 948 | struct node_bias_hash_iter node_it; |
| 949 | |
| 950 | /* We assume bias from individual channels and their node are additive, |
| 951 | * this is completely arbitrary. */ |
| 952 | for (node_bias = node_bias_hash_first(layer->node_biases, &node_it); |
| 953 | node_bias; |
| 954 | node_bias = node_bias_hash_next(layer->node_biases, &node_it)) { |
| 955 | struct gossmap_node *n; |
| 956 | struct gossmap_chan *c; |
| 957 | int dir; |
| 958 | u32 idx; |
| 959 | |
| 960 | n = gossmap_find_node(gossmap, &node_bias->node); |
| 961 | if (!n) |
| 962 | continue; |
| 963 | for (size_t i = 0; i < n->num_chans; i++) { |
| 964 | c = gossmap_nth_chan(gossmap, n, i, &dir); |
| 965 | idx = (gossmap_chan_idx(gossmap, c) << 1) | dir; |
| 966 | |
| 967 | biases[idx] += node_bias->out_bias; |
| 968 | biases[idx ^ 1] += node_bias->in_bias; |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | for (bias = bias_hash_first(layer->biases, &it); |
| 973 | bias; |
| 974 | bias = bias_hash_next(layer->biases, &it)) { |
| 975 | struct gossmap_chan *c; |
| 976 | |
| 977 | c = gossmap_find_chan(gossmap, &bias->scidd.scid); |
| 978 | if (!c) |
| 979 | continue; |
| 980 | biases[(gossmap_chan_idx(gossmap, c) << 1) | bias->scidd.dir] |
| 981 | += bias->bias; |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | struct amount_msat local_channel_capacity(const struct local_channel *lc) |
| 986 | { |
no test coverage detected