mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: move tell_lightningd_peer_update from routing.c into gossipd.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
2d09af8d56
commit
561859da0c
@ -152,7 +152,7 @@ static void give_lightningd_canned_private_update(struct routing_state *rstate,
|
||||
}
|
||||
|
||||
/* From NULL source (i.e. trust us!) */
|
||||
tell_lightningd_peer_update(rstate,
|
||||
tell_lightningd_peer_update(rstate->daemon,
|
||||
NULL,
|
||||
short_channel_id,
|
||||
fee_base_msat,
|
||||
|
@ -549,6 +549,27 @@ static void gossip_refresh_network(struct daemon *daemon)
|
||||
route_prune(daemon->rstate);
|
||||
}
|
||||
|
||||
void tell_lightningd_peer_update(struct daemon *daemon,
|
||||
const struct node_id *source_peer,
|
||||
struct short_channel_id scid,
|
||||
u32 fee_base_msat,
|
||||
u32 fee_ppm,
|
||||
u16 cltv_delta,
|
||||
struct amount_msat htlc_minimum,
|
||||
struct amount_msat htlc_maximum)
|
||||
{
|
||||
struct peer_update remote_update;
|
||||
u8* msg;
|
||||
remote_update.scid = scid;
|
||||
remote_update.fee_base = fee_base_msat;
|
||||
remote_update.fee_ppm = fee_ppm;
|
||||
remote_update.cltv_delta = cltv_delta;
|
||||
remote_update.htlc_minimum_msat = htlc_minimum;
|
||||
remote_update.htlc_maximum_msat = htlc_maximum;
|
||||
msg = towire_gossipd_remote_channel_update(NULL, source_peer, &remote_update);
|
||||
daemon_conn_send(daemon->master, take(msg));
|
||||
}
|
||||
|
||||
static void tell_master_local_cupdates(struct daemon *daemon)
|
||||
{
|
||||
struct chan_map_iter i;
|
||||
|
@ -136,4 +136,14 @@ void queue_peer_msg(struct peer *peer, const u8 *msg TAKES);
|
||||
void queue_peer_from_store(struct peer *peer,
|
||||
const struct broadcastable *bcast);
|
||||
|
||||
/* We have an update for one of our channels (or unknown). */
|
||||
void tell_lightningd_peer_update(struct daemon *daemon,
|
||||
const struct node_id *source_peer,
|
||||
struct short_channel_id scid,
|
||||
u32 fee_base_msat,
|
||||
u32 fee_ppm,
|
||||
u16 cltv_delta,
|
||||
struct amount_msat htlc_minimum,
|
||||
struct amount_msat htlc_maximum);
|
||||
|
||||
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_H */
|
||||
|
@ -1123,27 +1123,6 @@ static bool is_chan_dying(struct routing_state *rstate,
|
||||
return false;
|
||||
}
|
||||
|
||||
void tell_lightningd_peer_update(struct routing_state *rstate,
|
||||
const struct node_id *source_peer,
|
||||
struct short_channel_id scid,
|
||||
u32 fee_base_msat,
|
||||
u32 fee_ppm,
|
||||
u16 cltv_delta,
|
||||
struct amount_msat htlc_minimum,
|
||||
struct amount_msat htlc_maximum)
|
||||
{
|
||||
struct peer_update remote_update;
|
||||
u8* msg;
|
||||
remote_update.scid = scid;
|
||||
remote_update.fee_base = fee_base_msat;
|
||||
remote_update.fee_ppm = fee_ppm;
|
||||
remote_update.cltv_delta = cltv_delta;
|
||||
remote_update.htlc_minimum_msat = htlc_minimum;
|
||||
remote_update.htlc_maximum_msat = htlc_maximum;
|
||||
msg = towire_gossipd_remote_channel_update(NULL, source_peer, &remote_update);
|
||||
daemon_conn_send(rstate->daemon->master, take(msg));
|
||||
}
|
||||
|
||||
/* Is this channel_update different from prev (not sigs and timestamps)? */
|
||||
static bool cupdate_different(struct gossip_store *gs,
|
||||
const struct half_chan *hc,
|
||||
@ -1217,7 +1196,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||
if (index)
|
||||
return false;
|
||||
/* Allow ld to process a private channel update */
|
||||
tell_lightningd_peer_update(rstate, source_peer,
|
||||
tell_lightningd_peer_update(rstate->daemon, source_peer,
|
||||
short_channel_id, fee_base_msat,
|
||||
fee_proportional_millionths,
|
||||
expiry, htlc_minimum,
|
||||
@ -1330,7 +1309,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||
/* If this is a peer's update to one of our local channels, tell lightningd. */
|
||||
if (node_id_eq(&chan->nodes[!direction]->id, &rstate->daemon->id)) {
|
||||
/* give lightningd the channel's inbound info to store to db */
|
||||
tell_lightningd_peer_update(rstate,
|
||||
tell_lightningd_peer_update(rstate->daemon,
|
||||
/* Note: we can get public
|
||||
* channel_updates from other than
|
||||
* direct peer! So tell lightningd
|
||||
@ -1561,7 +1540,7 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
|
||||
* check signature assuming it's from that peer, and if it's valid, hand to ld */
|
||||
if (source_peer
|
||||
&& sigcheck_channel_update(tmpctx, source_peer, &signature, serialized) == NULL) {
|
||||
tell_lightningd_peer_update(rstate, source_peer,
|
||||
tell_lightningd_peer_update(rstate->daemon, source_peer,
|
||||
short_channel_id, fee_base_msat,
|
||||
fee_proportional_millionths,
|
||||
expiry, htlc_minimum,
|
||||
|
@ -397,13 +397,4 @@ const char *unfinalized_entries(const tal_t *ctx, struct routing_state *rstate);
|
||||
|
||||
void remove_all_gossip(struct routing_state *rstate);
|
||||
|
||||
/* We have an update for one of our channels (or unknown). */
|
||||
void tell_lightningd_peer_update(struct routing_state *rstate,
|
||||
const struct node_id *source_peer,
|
||||
struct short_channel_id scid,
|
||||
u32 fee_base_msat,
|
||||
u32 fee_ppm,
|
||||
u16 cltv_delta,
|
||||
struct amount_msat htlc_minimum,
|
||||
struct amount_msat htlc_maximum);
|
||||
#endif /* LIGHTNING_GOSSIPD_ROUTING_H */
|
||||
|
Loading…
Reference in New Issue
Block a user