mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
gossipd: tell lightningd its node_announcement on startup, if any.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
48b9b6a05c
commit
dd86e817b4
6 changed files with 44 additions and 2 deletions
|
@ -633,6 +633,17 @@ static void tell_master_local_cupdates(struct daemon *daemon)
|
|||
&c->scid,
|
||||
cupdate)));
|
||||
}
|
||||
|
||||
/* Tell lightningd about our current node_announcement, if any */
|
||||
if (me->bcast.index) {
|
||||
const u8 *nannounce;
|
||||
nannounce = gossip_store_get(tmpctx,
|
||||
daemon->rstate->gs,
|
||||
me->bcast.index);
|
||||
daemon_conn_send(daemon->master,
|
||||
take(towire_gossipd_init_nannounce(NULL,
|
||||
nannounce)));
|
||||
}
|
||||
}
|
||||
|
||||
struct peer *first_random_peer(struct daemon *daemon,
|
||||
|
@ -721,7 +732,7 @@ static void gossip_init(struct daemon *daemon, const u8 *msg)
|
|||
tal_add_destructor(daemon->connectd, master_or_connectd_gone);
|
||||
|
||||
/* Tell it about all our local (public) channel_update messages,
|
||||
* so it doesn't unnecessarily regenerate them. */
|
||||
* and node_announcement, so it doesn't unnecessarily regenerate them. */
|
||||
tell_master_local_cupdates(daemon);
|
||||
|
||||
/* OK, we are ready. */
|
||||
|
@ -967,6 +978,7 @@ static struct io_plan *recv_req(struct io_conn *conn,
|
|||
|
||||
/* We send these, we don't receive them */
|
||||
case WIRE_GOSSIPD_INIT_CUPDATE:
|
||||
case WIRE_GOSSIPD_INIT_NANNOUNCE:
|
||||
case WIRE_GOSSIPD_INIT_REPLY:
|
||||
case WIRE_GOSSIPD_GET_TXOUT:
|
||||
case WIRE_GOSSIPD_DEV_MEMLEAK_REPLY:
|
||||
|
|
|
@ -24,6 +24,11 @@ msgdata,gossipd_init_cupdate,scid,short_channel_id,
|
|||
msgdata,gossipd_init_cupdate,len,u16,
|
||||
msgdata,gossipd_init_cupdate,cupdate,u8,len
|
||||
|
||||
# Gossipd tells us our node_announcement before init_reply.
|
||||
msgtype,gossipd_init_nannounce,3102
|
||||
msgdata,gossipd_init_nannounce,len,u16,
|
||||
msgdata,gossipd_init_nannounce,nannounce,u8,len
|
||||
|
||||
msgtype,gossipd_init_reply,3100
|
||||
|
||||
# In developer mode, we can mess with time.
|
||||
|
|
|
|
@ -1032,6 +1032,11 @@ void channel_gossip_node_announce(struct lightningd *ld)
|
|||
|
||||
nannounce = unsigned_node_announcement(tmpctx, ld);
|
||||
|
||||
/* Don't bother with duplicates */
|
||||
if (ld->node_announcement
|
||||
&& node_announcement_same(ld->node_announcement, nannounce))
|
||||
return;
|
||||
|
||||
/* Ask hsmd to sign it (synchronous) */
|
||||
msg = hsm_sync_req(tmpctx, ld,
|
||||
take(towire_hsmd_node_announcement_sig_req(NULL,
|
||||
|
|
|
@ -138,6 +138,19 @@ static void handle_init_cupdate(struct lightningd *ld, const u8 *msg)
|
|||
channel_gossip_update_from_gossipd(channel, take(update));
|
||||
}
|
||||
|
||||
static void handle_init_nannounce(struct lightningd *ld, const u8 *msg)
|
||||
{
|
||||
u8 *nannounce;
|
||||
|
||||
if (!fromwire_gossipd_init_nannounce(ld, msg, &nannounce)) {
|
||||
fatal("Gossip gave bad GOSSIPD_INIT_NANNOUNCE %s",
|
||||
tal_hex(msg, msg));
|
||||
}
|
||||
|
||||
assert(!ld->node_announcement);
|
||||
ld->node_announcement = nannounce;
|
||||
}
|
||||
|
||||
static void handle_peer_update_data(struct lightningd *ld, const u8 *msg)
|
||||
{
|
||||
struct peer_update update;
|
||||
|
@ -180,6 +193,9 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
|||
case WIRE_GOSSIPD_INIT_CUPDATE:
|
||||
handle_init_cupdate(gossip->ld, msg);
|
||||
break;
|
||||
case WIRE_GOSSIPD_INIT_NANNOUNCE:
|
||||
handle_init_nannounce(gossip->ld, msg);
|
||||
break;
|
||||
case WIRE_GOSSIPD_GET_TXOUT:
|
||||
get_txout(gossip, msg);
|
||||
break;
|
||||
|
|
|
@ -237,6 +237,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||
ld->announce_dns = false;
|
||||
|
||||
ld->lease_rates = NULL;
|
||||
ld->node_announcement = NULL;
|
||||
ld->remote_addr_v4 = NULL;
|
||||
ld->remote_addr_v6 = NULL;
|
||||
ld->discovered_ip_v4 = NULL;
|
||||
|
|
|
@ -183,10 +183,13 @@ struct lightningd {
|
|||
/* Setup: And the bitset for each, whether to listen, announce or both */
|
||||
enum addr_listen_announce *proposed_listen_announce;
|
||||
|
||||
/* Actual bindings and announceables from gossipd */
|
||||
/* Actual bindings and announceables from connectd */
|
||||
struct wireaddr_internal *binding;
|
||||
struct wireaddr *announceable;
|
||||
|
||||
/* Current node announcement (if any) */
|
||||
const u8 *node_announcement;
|
||||
|
||||
/* Lease rates to advertize, set by json_setleaserates */
|
||||
struct lease_rates *lease_rates;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue