MCPcopy Create free account
hub / github.com/ElementsProject/lightning / set_bias

Function set_bias

plugins/askrene/layer.c:319–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319static const struct bias *set_bias(struct layer *layer,
320 const struct short_channel_id_dir *scidd,
321 const char *description TAKES,
322 s8 bias_factor,
323 bool relative,
324 u64 timestamp)
325{
326 struct bias *bias;
327
328 bias = bias_hash_get(layer->biases, scidd);
329 if (!bias) {
330 bias = tal(layer, struct bias);
331 bias->scidd = *scidd;
332 bias_hash_add(layer->biases, bias);
333 bias->bias = 0;
334 } else {
335 tal_free(bias->description);
336 }
337 int bias_new = relative ? bias->bias + bias_factor : bias_factor;
338 bias_new = MIN(100, bias_new);
339 bias_new = MAX(-100, bias_new);
340 bias->bias = bias_new;
341 bias->description = tal_strdup_or_null(bias, description);
342 bias->timestamp = timestamp;
343
344 /* Don't bother keeping around zero biases */
345 if (bias->bias == 0) {
346 bias_hash_del(layer->biases, bias);
347 bias = tal_free(bias);
348 }
349 return bias;
350}
351
352static const struct node_bias *set_node_bias(struct layer *layer,
353 const struct node_id *node,

Callers 3

load_channel_biasFunction · 0.85
load_channel_bias_v2Function · 0.85
layer_set_biasFunction · 0.85

Calls 2

tal_freeFunction · 0.85
tal_strdup_or_nullFunction · 0.85

Tested by

no test coverage detected