mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
gossipd: routine to get route_info for known incoming channels.
For routeboost, we want to select from all our enabled channels with sufficient incoming capacity. Gossipd knows which are enabled (ie. we have received a `channel_update` from the peer), but doesn't know the current incoming capacity. So we get gossipd to give us all the candidates, and lightningd selects from those. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
f64eee717d
commit
2f667c5227
@@ -165,3 +165,13 @@ gossip_outpoint_spent,,short_channel_id,struct short_channel_id
|
||||
|
||||
# master -> gossipd: stop gossip timers.
|
||||
gossip_dev_suppress,3032
|
||||
|
||||
#include <common/bolt11.h>
|
||||
|
||||
# master -> gossipd: get route_info for our incoming channels
|
||||
gossip_get_incoming_channels,3025
|
||||
|
||||
# gossipd -> master: here they are.
|
||||
gossip_get_incoming_channels_reply,3125
|
||||
gossip_get_incoming_channels_reply,,num,u16
|
||||
gossip_get_incoming_channels_reply,,route_info,num*struct route_info
|
||||
|
||||
|
@@ -1492,6 +1492,43 @@ out:
|
||||
return daemon_conn_read_next(conn, &daemon->master);
|
||||
}
|
||||
|
||||
static struct io_plan *get_incoming_channels(struct io_conn *conn,
|
||||
struct daemon *daemon,
|
||||
const u8 *msg)
|
||||
{
|
||||
struct node *node;
|
||||
struct route_info *r = tal_arr(tmpctx, struct route_info, 0);
|
||||
|
||||
if (!fromwire_gossip_get_incoming_channels(msg))
|
||||
master_badmsg(WIRE_GOSSIP_GET_INCOMING_CHANNELS, msg);
|
||||
|
||||
node = get_node(daemon->rstate, &daemon->rstate->local_id);
|
||||
if (node) {
|
||||
for (size_t i = 0; i < tal_count(node->chans); i++) {
|
||||
const struct chan *c = node->chans[i];
|
||||
const struct half_chan *hc;
|
||||
struct route_info *ri;
|
||||
|
||||
hc = &c->half[half_chan_to(node, c)];
|
||||
|
||||
if (!is_halfchan_enabled(hc))
|
||||
continue;
|
||||
|
||||
ri = tal_arr_expand(&r);
|
||||
ri->pubkey = other_node(node, c)->id;
|
||||
ri->short_channel_id = c->scid;
|
||||
ri->fee_base_msat = hc->base_fee;
|
||||
ri->fee_proportional_millionths = hc->proportional_fee;
|
||||
ri->cltv_expiry_delta = hc->delay;
|
||||
}
|
||||
}
|
||||
|
||||
msg = towire_gossip_get_incoming_channels_reply(NULL, r);
|
||||
daemon_conn_send(&daemon->master, take(msg));
|
||||
|
||||
return daemon_conn_read_next(conn, &daemon->master);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static struct io_plan *query_scids_req(struct io_conn *conn,
|
||||
struct daemon *daemon,
|
||||
@@ -1948,6 +1985,10 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
|
||||
case WIRE_GOSSIP_PING:
|
||||
return ping_req(conn, daemon, daemon->master.msg_in);
|
||||
|
||||
case WIRE_GOSSIP_GET_INCOMING_CHANNELS:
|
||||
return get_incoming_channels(conn, daemon,
|
||||
daemon->master.msg_in);
|
||||
|
||||
#if DEVELOPER
|
||||
case WIRE_GOSSIP_QUERY_SCIDS:
|
||||
return query_scids_req(conn, daemon, daemon->master.msg_in);
|
||||
@@ -1981,6 +2022,7 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
|
||||
case WIRE_GOSSIP_SCIDS_REPLY:
|
||||
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE_REPLY:
|
||||
case WIRE_GOSSIP_RESOLVE_CHANNEL_REPLY:
|
||||
case WIRE_GOSSIP_GET_INCOMING_CHANNELS_REPLY:
|
||||
case WIRE_GOSSIP_GET_UPDATE:
|
||||
case WIRE_GOSSIP_GET_UPDATE_REPLY:
|
||||
case WIRE_GOSSIP_SEND_GOSSIP:
|
||||
|
||||
@@ -116,6 +116,7 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||
case WIRE_GOSSIP_QUERY_SCIDS:
|
||||
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
|
||||
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
|
||||
case WIRE_GOSSIP_GET_INCOMING_CHANNELS:
|
||||
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
|
||||
case WIRE_GOSSIP_DEV_SUPPRESS:
|
||||
/* This is a reply, so never gets through to here. */
|
||||
@@ -126,6 +127,7 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||
case WIRE_GOSSIP_SCIDS_REPLY:
|
||||
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE_REPLY:
|
||||
case WIRE_GOSSIP_RESOLVE_CHANNEL_REPLY:
|
||||
case WIRE_GOSSIP_GET_INCOMING_CHANNELS_REPLY:
|
||||
/* These are inter-daemon messages, not received by us */
|
||||
case WIRE_GOSSIP_LOCAL_ADD_CHANNEL:
|
||||
case WIRE_GOSSIP_LOCAL_CHANNEL_UPDATE:
|
||||
|
||||
Reference in New Issue
Block a user