Skip to content

Commit a871ce7

Browse files
committed
askrene: add askrene-bias-node rpc
Changelog-Added: askrene-bias-node: an RPC command to set a bias on node's outgoing or incoming channels. Signed-off-by: Lagrang3 <[email protected]>
1 parent 9e77e52 commit a871ce7

File tree

8 files changed

+576
-3
lines changed

8 files changed

+576
-3
lines changed

doc/schemas/askrene-bias-channel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
}
105105
},
106106
"see_also": [
107+
"lightning-askrene-bias-node(7)",
107108
"lightning-getroutes(7)",
108109
"lightning-askrene-disable-node(7)",
109110
"lightning-askrene-create-channel(7)",

doc/schemas/askrene-bias-node.json

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
{
2+
"$schema": "../rpc-schema-draft.json",
3+
"type": "object",
4+
"rpc": "askrene-bias-node",
5+
"title": "Command to apply a manual bias to a node in a layer",
6+
"added": "v25.12",
7+
"description": [
8+
"The **askrene-bias-node** RPC command tells askrene to favor or disfavor all outgoing or incoming channels of a node when considering them for routing."
9+
],
10+
"request": {
11+
"required": [
12+
"layer",
13+
"node",
14+
"bias"
15+
],
16+
"additionalProperties": false,
17+
"properties": {
18+
"layer": {
19+
"type": "string",
20+
"description": [
21+
"The name of the layer to apply this bias to."
22+
]
23+
},
24+
"node": {
25+
"type": "pubkey",
26+
"description": [
27+
"The node to which this bias applies. It does not need to exist."
28+
]
29+
},
30+
"bias": {
31+
"type": "integer",
32+
"description": [
33+
"The bias, positive being good and negative being bad (0 being no bias). Useful values are +/-1 through +/-10, though -100 through +100 are possible values."
34+
]
35+
},
36+
"description": {
37+
"type": "string",
38+
"description": [
39+
"Description/annotation to display in askrene-listlayers(7)"
40+
]
41+
},
42+
"relative": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": [
46+
"The bias will be added to the previous value."
47+
]
48+
},
49+
"out_direction": {
50+
"type": "boolean",
51+
"default": true,
52+
"description": [
53+
"If true the bias applies to outgoing channels otherwise it applies to incoming channels."
54+
]
55+
}
56+
}
57+
},
58+
"response": {
59+
"required": [
60+
"node_biases"
61+
],
62+
"additionalProperties": false,
63+
"properties": {
64+
"node_biases": {
65+
"type": "array",
66+
"items": {
67+
"type": "object",
68+
"required": [
69+
"layer",
70+
"node",
71+
"in_bias",
72+
"out_bias",
73+
"timestamp"
74+
],
75+
"additionalProperties": false,
76+
"properties": {
77+
"layer": {
78+
"type": "string",
79+
"description": [
80+
"The name of the layer this bias applies to."
81+
]
82+
},
83+
"node": {
84+
"type": "pubkey",
85+
"description": [
86+
"The id of the biased node."
87+
]
88+
},
89+
"in_bias": {
90+
"type": "integer",
91+
"description": [
92+
"The bias (-100 to +100) on incoming channels."
93+
]
94+
},
95+
"out_bias": {
96+
"type": "integer",
97+
"description": [
98+
"The bias (-100 to +100) on outgoing channels."
99+
]
100+
},
101+
"description": {
102+
"type": "string",
103+
"description": [
104+
"A human readable annotation."
105+
]
106+
},
107+
"timestamp": {
108+
"type": "u64",
109+
"description": [
110+
"The UNIX timestamp when this bias was created or last updated."
111+
]
112+
}
113+
}
114+
}
115+
}
116+
}
117+
},
118+
"see_also": [
119+
"lightning-askrene-bias-channel(7)",
120+
"lightning-getroutes(7)",
121+
"lightning-askrene-disable-node(7)",
122+
"lightning-askrene-create-channel(7)",
123+
"lightning-askrene-listlayers(7)",
124+
"lightning-askrene-age(7)"
125+
],
126+
"author": [
127+
"Lagrange <<[email protected]>> is mainly responsible."
128+
],
129+
"resources": [
130+
"Main web site: <https://github.com/ElementsProject/lightning>"
131+
],
132+
"examples": [
133+
{
134+
"request": {
135+
"id": "example:askrene-bias-node#1",
136+
"method": "askrene-bias-node",
137+
"params": {
138+
"layer": "test_layers",
139+
"node": "nodeid030303030303030303030303030303030303030303030303030303030303",
140+
"bias": 1
141+
}
142+
},
143+
"response": {
144+
"node_biases": [
145+
{
146+
"layer": "test_layers",
147+
"node": "nodeid030303030303030303030303030303030303030303030303030303030303",
148+
"in_bias": 0,
149+
"out_bias": 1
150+
}
151+
]
152+
}
153+
},
154+
{
155+
"request": {
156+
"id": "example:askrene-bias-node#2",
157+
"method": "askrene-bias-node",
158+
"params": [
159+
"test_layers",
160+
"nodeid030303030303030303030303030303030303030303030303030303030303",
161+
-5,
162+
"this node is unreliable"
163+
]
164+
},
165+
"response": {
166+
"node_biases": [
167+
{
168+
"layer": "test_layers",
169+
"node": "nodeid030303030303030303030303030303030303030303030303030303030303",
170+
"description": "this is node is unreliable",
171+
"in_bias": 0,
172+
"out_bias": -5
173+
}
174+
]
175+
}
176+
}
177+
]
178+
}
179+

doc/schemas/askrene-create-layer.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,52 @@
234234
}
235235
}
236236
}
237+
},
238+
"node_biases": {
239+
"added": "v25.12",
240+
"type": "array",
241+
"items": {
242+
"type": "object",
243+
"required": [
244+
"node",
245+
"in_bias",
246+
"out_bias",
247+
"timestamp"
248+
],
249+
"additionalProperties": false,
250+
"properties": {
251+
"node": {
252+
"type": "pubkey",
253+
"description": [
254+
"The id of the biased node."
255+
]
256+
},
257+
"in_bias": {
258+
"type": "integer",
259+
"description": [
260+
"The bias (-100 to +100) on incoming channels."
261+
]
262+
},
263+
"out_bias": {
264+
"type": "integer",
265+
"description": [
266+
"The bias (-100 to +100) on outgoing channels."
267+
]
268+
},
269+
"description": {
270+
"type": "string",
271+
"description": [
272+
"A human readable annotation."
273+
]
274+
},
275+
"timestamp": {
276+
"type": "u64",
277+
"description": [
278+
"The UNIX timestamp when this bias was created or last updated."
279+
]
280+
}
281+
}
282+
}
237283
}
238284
}
239285
}
@@ -272,7 +318,8 @@
272318
"created_channels": [],
273319
"channel_updates": [],
274320
"constraints": [],
275-
"biases": []
321+
"biases": [],
322+
"node_biases": []
276323
}
277324
]
278325
}

doc/schemas/askrene-listlayers.json

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,52 @@
236236
}
237237
}
238238
}
239+
},
240+
"node_biases": {
241+
"added": "v25.12",
242+
"type": "array",
243+
"items": {
244+
"type": "object",
245+
"required": [
246+
"node",
247+
"in_bias",
248+
"out_bias",
249+
"timestamp"
250+
],
251+
"additionalProperties": false,
252+
"properties": {
253+
"node": {
254+
"type": "pubkey",
255+
"description": [
256+
"The id of the biased node."
257+
]
258+
},
259+
"in_bias": {
260+
"type": "integer",
261+
"description": [
262+
"The bias (-100 to +100) on incoming channels."
263+
]
264+
},
265+
"out_bias": {
266+
"type": "integer",
267+
"description": [
268+
"The bias (-100 to +100) on outgoing channels."
269+
]
270+
},
271+
"description": {
272+
"type": "string",
273+
"description": [
274+
"A human readable annotation."
275+
]
276+
},
277+
"timestamp": {
278+
"type": "u64",
279+
"description": [
280+
"The UNIX timestamp when this bias was created or last updated."
281+
]
282+
}
283+
}
284+
}
239285
}
240286
}
241287
}
@@ -248,6 +294,7 @@
248294
"lightning-askrene-create-channel(7)",
249295
"lightning-askrene-inform-channel(7)",
250296
"lightning-askrene-bias-channel(7)",
297+
"lightning-askrene-bias-node(7)",
251298
"lightning-askrene-age(7)"
252299
],
253300
"author": [
@@ -304,6 +351,14 @@
304351
"description": "bigger bias",
305352
"bias": -5
306353
}
354+
],
355+
"node_biases": [
356+
{
357+
"node": "nodeid030303030303030303030303030303030303030303030303030303030303",
358+
"description": "this node is unreliable",
359+
"in_bias": 0,
360+
"out_bias": -5
361+
}
307362
]
308363
}
309364
]
@@ -354,6 +409,14 @@
354409
"description": "bigger bias",
355410
"bias": -5
356411
}
412+
],
413+
"node_biases": [
414+
{
415+
"node": "nodeid030303030303030303030303030303030303030303030303030303030303",
416+
"description": "this node is unreliable",
417+
"in_bias": 0,
418+
"out_bias": -5
419+
}
357420
]
358421
},
359422
{
@@ -363,7 +426,8 @@
363426
"created_channels": [],
364427
"channel_updates": [],
365428
"constraints": [],
366-
"biases": []
429+
"biases": [],
430+
"node_biases": []
367431
}
368432
]
369433
}

0 commit comments

Comments
 (0)