gossipd: remove peer-related fields and wire messages.

This completes the removal of peer-related messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-07-24 15:48:58 +09:30
parent 0d442b5ff2
commit 7b2641ed0d
8 changed files with 13 additions and 200 deletions

View File

@ -101,8 +101,8 @@ struct daemon {
u32 broadcast_interval;
/* Local and global features to offer to peers. */
u8 *localfeatures, *globalfeatures;
/* Global features to list in node_announcement. */
u8 *globalfeatures;
u8 alias[33];
u8 rgb[3];
@ -1872,29 +1872,17 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
struct bitcoin_blkid chain_hash;
u32 update_channel_interval;
/* FIXME: Remove these from init msg */
bool dev_allow_localhost;
struct wireaddr_internal *proposed_wireaddr;
enum addr_listen_announce *proposed_listen_announce;
struct wireaddr *proxyaddr;
bool reconnect, use_proxy_always, use_dns;
char *tor_password;
if (!fromwire_gossipctl_init(
daemon, msg, &daemon->broadcast_interval, &chain_hash,
&daemon->id, &daemon->globalfeatures,
&daemon->localfeatures, &proposed_wireaddr,
&proposed_listen_announce, daemon->rgb,
daemon->alias, &update_channel_interval, &reconnect,
&proxyaddr, &use_proxy_always,
&dev_allow_localhost, &use_dns,
&tor_password, &daemon->announcable)) {
daemon->rgb,
daemon->alias, &update_channel_interval,
&daemon->announcable)) {
master_badmsg(WIRE_GOSSIPCTL_INIT, msg);
}
/* Prune time is twice update time */
daemon->rstate = new_routing_state(daemon, &chain_hash, &daemon->id,
update_channel_interval * 2,
dev_allow_localhost);
update_channel_interval * 2);
/* Load stored gossip messages */
gossip_store_load(daemon->rstate, daemon->rstate->store);
@ -2118,40 +2106,20 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
break;
#endif /* !DEVELOPER */
/* These are handled by channeld */
case WIRE_GOSSIPCTL_ACTIVATE:
case WIRE_GOSSIPCTL_RELEASE_PEER:
case WIRE_GOSSIPCTL_HAND_BACK_PEER:
case WIRE_GOSSIPCTL_CONNECT_TO_PEER:
case WIRE_GOSSIPCTL_PEER_ADDRHINT:
case WIRE_GOSSIPCTL_PEER_IMPORTANT:
case WIRE_GOSSIPCTL_PEER_DISCONNECTED:
case WIRE_GOSSIP_GETPEERS_REQUEST:
case WIRE_GOSSIPCTL_PEER_DISCONNECT:
break;
/* We send these, we don't receive them */
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_GOSSIP_GETNODES_REPLY:
case WIRE_GOSSIP_GETROUTE_REPLY:
case WIRE_GOSSIP_GETCHANNELS_REPLY:
case WIRE_GOSSIP_GETPEERS_REPLY:
case WIRE_GOSSIP_PING_REPLY:
case WIRE_GOSSIP_SCIDS_REPLY:
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE_REPLY:
case WIRE_GOSSIP_RESOLVE_CHANNEL_REPLY:
case WIRE_GOSSIP_PEER_CONNECTED:
case WIRE_GOSSIPCTL_CONNECT_TO_PEER_RESULT:
case WIRE_GOSSIP_PEER_NONGOSSIP:
case WIRE_GOSSIP_GET_UPDATE:
case WIRE_GOSSIP_GET_UPDATE_REPLY:
case WIRE_GOSSIP_SEND_GOSSIP:
case WIRE_GOSSIP_LOCAL_ADD_CHANNEL:
case WIRE_GOSSIP_LOCAL_CHANNEL_UPDATE:
case WIRE_GOSSIP_GET_TXOUT:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLY:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLYFAIL:
break;
}

View File

@ -9,100 +9,12 @@ gossipctl_init,,chain_hash,struct bitcoin_blkid
gossipctl_init,,id,struct pubkey
gossipctl_init,,gflen,u16
gossipctl_init,,gfeatures,gflen*u8
gossipctl_init,,lflen,u16
gossipctl_init,,lfeatures,lflen*u8
gossipctl_init,,num_wireaddrs,u16
gossipctl_init,,wireaddrs,num_wireaddrs*struct wireaddr_internal
gossipctl_init,,listen_announce,num_wireaddrs*enum addr_listen_announce
gossipctl_init,,rgb,3*u8
gossipctl_init,,alias,32*u8
gossipctl_init,,update_channel_interval,u32
gossipctl_init,,reconnect,bool
gossipctl_init,,tor_proxyaddr,?struct wireaddr
gossipctl_init,,use_tor_proxy_always,bool
gossipctl_init,,dev_allow_localhost,bool
gossipctl_init,,use_dns,bool
gossipctl_init,,tor_password,wirestring
gossipctl_init,,num_announcable,u16
gossipctl_init,,announcable,num_announcable*struct wireaddr
# Activate the gossip daemon, so others can connect.
gossipctl_activate,3025
# Do we listen?
gossipctl_activate,,listen,bool
# Master -> gossipd: Optional hint for where to find peer.
gossipctl_peer_addrhint,3014
gossipctl_peer_addrhint,,id,struct pubkey
gossipctl_peer_addrhint,,addr,struct wireaddr_internal
# Master -> gossipd: connect to a peer.
gossipctl_connect_to_peer,3001
gossipctl_connect_to_peer,,id,struct pubkey
# Gossipd->master: result (not a reply since it can be out-of-order, but
# you will get one reply for every request).
gossipctl_connect_to_peer_result,3020
gossipctl_connect_to_peer_result,,id,struct pubkey
# True it connected.
gossipctl_connect_to_peer_result,,connected,bool
# Otherwise, why we can't reach them.
gossipctl_connect_to_peer_result,,failreason,wirestring
# Master -> gossipd: try to always maintain connection to this peer (or not)
gossipctl_peer_important,3010
gossipctl_peer_important,,id,struct pubkey
gossipctl_peer_important,,important,bool
# Gossipd -> master: we got a peer. Two fds: peer and gossip
gossip_peer_connected,3002
gossip_peer_connected,,id,struct pubkey
gossip_peer_connected,,addr,struct wireaddr_internal
gossip_peer_connected,,crypto_state,struct crypto_state
gossip_peer_connected,,gflen,u16
gossip_peer_connected,,gfeatures,gflen*u8
gossip_peer_connected,,lflen,u16
gossip_peer_connected,,lfeatures,lflen*u8
# Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip
gossip_peer_nongossip,3003
gossip_peer_nongossip,,id,struct pubkey
gossip_peer_nongossip,,addr,struct wireaddr_internal
gossip_peer_nongossip,,crypto_state,struct crypto_state
gossip_peer_nongossip,,gflen,u16
gossip_peer_nongossip,,gfeatures,gflen*u8
gossip_peer_nongossip,,lflen,u16
gossip_peer_nongossip,,lfeatures,lflen*u8
gossip_peer_nongossip,,len,u16
gossip_peer_nongossip,,msg,len*u8
# Master -> gossipd: release a peer (so we can open a channel)
gossipctl_release_peer,3004
gossipctl_release_peer,,id,struct pubkey
# Gossipd -> master: reply to gossip_release_peer. Two fds: peer and gossip.
gossipctl_release_peer_reply,3104
gossipctl_release_peer_reply,,addr,struct wireaddr_internal
gossipctl_release_peer_reply,,crypto_state,struct crypto_state
gossipctl_release_peer_reply,,gflen,u16
gossipctl_release_peer_reply,,gfeatures,gflen*u8
gossipctl_release_peer_reply,,lflen,u16
gossipctl_release_peer_reply,,lfeatures,lflen*u8
# Gossipd -> master: reply to gossip_release_peer if we couldn't find the peer.
gossipctl_release_peer_replyfail,3204
# master -> gossipd: take back peer, with optional msg. (+peer fd, +gossip fd)
gossipctl_hand_back_peer,3013
gossipctl_hand_back_peer,,id,struct pubkey
gossipctl_hand_back_peer,,crypto_state,struct crypto_state
gossipctl_hand_back_peer,,len,u16
gossipctl_hand_back_peer,,msg,len*u8
# master -> gossipd: peer has disconnected.
gossipctl_peer_disconnected,3015
gossipctl_peer_disconnected,,id,struct pubkey
# Pass JSON-RPC getnodes call through
gossip_getnodes_request,3005
gossip_getnodes_request,,id,?struct pubkey
@ -188,16 +100,6 @@ gossip_resolve_channel_reply,3109
gossip_resolve_channel_reply,,num_keys,u16
gossip_resolve_channel_reply,,keys,num_keys*struct pubkey
# The main daemon asks for peers
gossip_getpeers_request,3011
gossip_getpeers_request,,id,?struct pubkey
gossip_getpeers_reply,3111
gossip_getpeers_reply,,num,u16
gossip_getpeers_reply,,id,num*struct pubkey
gossip_getpeers_reply,,addr,num*struct wireaddr_internal
gossip_getpeers_reply,,nodes,num*struct gossip_getnodes_entry
# Channel daemon can ask for updates for a specific channel, for sending
# errors. Must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
gossip_get_update,3012
@ -255,17 +157,6 @@ gossip_routing_failure,,channel_update,len*u8
gossip_mark_channel_unroutable,3022
gossip_mark_channel_unroutable,,channel,struct short_channel_id
# master->gossipd: Request to disconnect from a peer.
gossipctl_peer_disconnect,3023
gossipctl_peer_disconnect,,id,struct pubkey
# Gossipd -> master: reply to gossip_peer_disconnect with peer id.
gossipctl_peer_disconnect_reply,3123
# Gossipd -> master: reply to gossip_peer_disconnect if we couldn't find the peer.
gossipctl_peer_disconnect_replyfail,3223
gossipctl_peer_disconnect_replyfail,,isconnected,bool
# master -> gossipd: a potential funding outpoint was spent, please forget the eventual channel
gossip_outpoint_spent,3024
gossip_outpoint_spent,,short_channel_id,struct short_channel_id

1 #include <common/cryptomsg.h>
9 gossipctl_init,,gflen,u16
10 gossipctl_init,,gfeatures,gflen*u8
11 gossipctl_init,,lflen,u16 gossipctl_init,,rgb,3*u8
gossipctl_init,,lfeatures,lflen*u8
gossipctl_init,,num_wireaddrs,u16
gossipctl_init,,wireaddrs,num_wireaddrs*struct wireaddr_internal
gossipctl_init,,listen_announce,num_wireaddrs*enum addr_listen_announce
gossipctl_init,,rgb,3*u8
12 gossipctl_init,,alias,32*u8
13 gossipctl_init,,update_channel_interval,u32
14 gossipctl_init,,reconnect,bool gossipctl_init,,num_announcable,u16
gossipctl_init,,tor_proxyaddr,?struct wireaddr
gossipctl_init,,use_tor_proxy_always,bool
gossipctl_init,,dev_allow_localhost,bool
gossipctl_init,,use_dns,bool
gossipctl_init,,tor_password,wirestring
gossipctl_init,,num_announcable,u16
15 gossipctl_init,,announcable,num_announcable*struct wireaddr
16 # Activate the gossip daemon, so others can connect. # Pass JSON-RPC getnodes call through
17 gossipctl_activate,3025 gossip_getnodes_request,3005
# Do we listen?
gossipctl_activate,,listen,bool
# Master -> gossipd: Optional hint for where to find peer.
gossipctl_peer_addrhint,3014
gossipctl_peer_addrhint,,id,struct pubkey
gossipctl_peer_addrhint,,addr,struct wireaddr_internal
# Master -> gossipd: connect to a peer.
gossipctl_connect_to_peer,3001
gossipctl_connect_to_peer,,id,struct pubkey
# Gossipd->master: result (not a reply since it can be out-of-order, but
# you will get one reply for every request).
gossipctl_connect_to_peer_result,3020
gossipctl_connect_to_peer_result,,id,struct pubkey
# True it connected.
gossipctl_connect_to_peer_result,,connected,bool
# Otherwise, why we can't reach them.
gossipctl_connect_to_peer_result,,failreason,wirestring
# Master -> gossipd: try to always maintain connection to this peer (or not)
gossipctl_peer_important,3010
gossipctl_peer_important,,id,struct pubkey
gossipctl_peer_important,,important,bool
# Gossipd -> master: we got a peer. Two fds: peer and gossip
gossip_peer_connected,3002
gossip_peer_connected,,id,struct pubkey
gossip_peer_connected,,addr,struct wireaddr_internal
gossip_peer_connected,,crypto_state,struct crypto_state
gossip_peer_connected,,gflen,u16
gossip_peer_connected,,gfeatures,gflen*u8
gossip_peer_connected,,lflen,u16
gossip_peer_connected,,lfeatures,lflen*u8
# Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip
gossip_peer_nongossip,3003
gossip_peer_nongossip,,id,struct pubkey
gossip_peer_nongossip,,addr,struct wireaddr_internal
gossip_peer_nongossip,,crypto_state,struct crypto_state
gossip_peer_nongossip,,gflen,u16
gossip_peer_nongossip,,gfeatures,gflen*u8
gossip_peer_nongossip,,lflen,u16
gossip_peer_nongossip,,lfeatures,lflen*u8
gossip_peer_nongossip,,len,u16
gossip_peer_nongossip,,msg,len*u8
# Master -> gossipd: release a peer (so we can open a channel)
gossipctl_release_peer,3004
gossipctl_release_peer,,id,struct pubkey
# Gossipd -> master: reply to gossip_release_peer. Two fds: peer and gossip.
gossipctl_release_peer_reply,3104
gossipctl_release_peer_reply,,addr,struct wireaddr_internal
gossipctl_release_peer_reply,,crypto_state,struct crypto_state
gossipctl_release_peer_reply,,gflen,u16
gossipctl_release_peer_reply,,gfeatures,gflen*u8
gossipctl_release_peer_reply,,lflen,u16
gossipctl_release_peer_reply,,lfeatures,lflen*u8
# Gossipd -> master: reply to gossip_release_peer if we couldn't find the peer.
gossipctl_release_peer_replyfail,3204
# master -> gossipd: take back peer, with optional msg. (+peer fd, +gossip fd)
gossipctl_hand_back_peer,3013
gossipctl_hand_back_peer,,id,struct pubkey
gossipctl_hand_back_peer,,crypto_state,struct crypto_state
gossipctl_hand_back_peer,,len,u16
gossipctl_hand_back_peer,,msg,len*u8
# master -> gossipd: peer has disconnected.
gossipctl_peer_disconnected,3015
gossipctl_peer_disconnected,,id,struct pubkey
# Pass JSON-RPC getnodes call through
gossip_getnodes_request,3005
gossip_getnodes_request,,id,?struct pubkey
#include <lightningd/gossip_msg.h>
gossip_getnodes_reply,3105
gossip_getnodes_reply,,num_nodes,u16
gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry
# Pass JSON-RPC getroute call through
gossip_getroute_request,3006
gossip_getroute_request,,source,struct pubkey
gossip_getroute_request,,destination,struct pubkey
gossip_getroute_request,,msatoshi,u64
gossip_getroute_request,,riskfactor,u16
gossip_getroute_request,,final_cltv,u32
18 gossip_getroute_request,,fuzz,double gossip_getnodes_request,,id,?struct pubkey
19 gossip_getroute_request,,seed,struct siphash_seed #include <lightningd/gossip_msg.h>
20 gossip_getroute_reply,3106 gossip_getnodes_reply,3105
100 gossip_local_channel_update,,short_channel_id,struct short_channel_id gossip_local_add_channel,3017
101 gossip_local_channel_update,,disable,bool gossip_local_add_channel,,short_channel_id,struct short_channel_id
102 gossip_local_channel_update,,cltv_expiry_delta,u16 gossip_local_add_channel,,remote_node_id,struct pubkey
gossip_local_channel_update,,htlc_minimum_msat,u64
gossip_local_channel_update,,fee_base_msat,u32
gossip_local_channel_update,,fee_proportional_millionths,u32
gossip_local_channel_close,3027
gossip_local_channel_close,,short_channel_id,struct short_channel_id
# Gossipd->master get this tx output please.
gossip_get_txout,3018
gossip_get_txout,,short_channel_id,struct short_channel_id
# master->gossipd here is the output, or empty if none.
gossip_get_txout_reply,3118
103 gossip_get_txout_reply,,short_channel_id,struct short_channel_id gossip_local_channel_update,3026
104 gossip_get_txout_reply,,satoshis,u64 gossip_local_channel_update,,short_channel_id,struct short_channel_id
105 gossip_get_txout_reply,,len,u16 gossip_local_channel_update,,disable,bool
157
158
159
160
161
162

View File

@ -86,8 +86,7 @@ static struct node_map *empty_node_map(const tal_t *ctx)
struct routing_state *new_routing_state(const tal_t *ctx,
const struct bitcoin_blkid *chain_hash,
const struct pubkey *local_id,
u32 prune_timeout,
bool dev_allow_localhost)
u32 prune_timeout)
{
struct routing_state *rstate = tal(ctx, struct routing_state);
rstate->nodes = empty_node_map(rstate);
@ -96,7 +95,6 @@ struct routing_state *new_routing_state(const tal_t *ctx,
rstate->local_id = *local_id;
rstate->prune_timeout = prune_timeout;
rstate->store = gossip_store_new(rstate, rstate, rstate->broadcasts);
rstate->dev_allow_localhost = dev_allow_localhost;
rstate->local_channel_announced = false;
list_head_init(&rstate->pending_cannouncement);
uintmap_init(&rstate->chanmap);

View File

@ -177,9 +177,6 @@ struct routing_state {
* restarts */
struct gossip_store *store;
/* For testing, we announce and accept localhost */
bool dev_allow_localhost;
/* A map of channels indexed by short_channel_ids */
UINTMAP(struct chan *) chanmap;
@ -204,8 +201,7 @@ struct route_hop {
struct routing_state *new_routing_state(const tal_t *ctx,
const struct bitcoin_blkid *chain_hash,
const struct pubkey *local_id,
u32 prune_timeout,
bool dev_allow_localhost);
u32 prune_timeout);
struct chan *new_chan(struct routing_state *rstate,
const struct short_channel_id *scid,

View File

@ -229,7 +229,7 @@ int main(int argc, char *argv[])
| SECP256K1_CONTEXT_SIGN);
setup_tmpctx();
rstate = new_routing_state(tmpctx, &zerohash, &me, 0, false);
rstate = new_routing_state(tmpctx, &zerohash, &me, 0);
opt_register_noarg("--perfme", opt_set_bool, &perfme,
"Run perfme-start and perfme-stop around benchmark");

View File

@ -166,7 +166,7 @@ int main(void)
strlen("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06"),
&c);
rstate = new_routing_state(tmpctx, &zerohash, &a, 0, false);
rstate = new_routing_state(tmpctx, &zerohash, &a, 0);
/* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */
nc = get_or_make_connection(rstate, &c, &b, "6990:2:1");

View File

@ -200,7 +200,7 @@ int main(void)
memset(&tmp, 'a', sizeof(tmp));
pubkey_from_privkey(&tmp, &a);
rstate = new_routing_state(tmpctx, &zerohash, &a, 0, false);
rstate = new_routing_state(tmpctx, &zerohash, &a, 0);
new_node(rstate, &a);

View File

@ -130,26 +130,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIP_LOCAL_CHANNEL_CLOSE:
break;
/* These are handled by connectd */
case WIRE_GOSSIPCTL_ACTIVATE:
case WIRE_GOSSIP_GETPEERS_REQUEST:
case WIRE_GOSSIPCTL_CONNECT_TO_PEER:
case WIRE_GOSSIPCTL_HAND_BACK_PEER:
case WIRE_GOSSIPCTL_RELEASE_PEER:
case WIRE_GOSSIPCTL_PEER_ADDRHINT:
case WIRE_GOSSIPCTL_PEER_DISCONNECT:
case WIRE_GOSSIPCTL_PEER_IMPORTANT:
case WIRE_GOSSIPCTL_PEER_DISCONNECTED:
case WIRE_GOSSIP_GETPEERS_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLY:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLYFAIL:
case WIRE_GOSSIP_PEER_CONNECTED:
case WIRE_GOSSIP_PEER_NONGOSSIP:
case WIRE_GOSSIPCTL_CONNECT_TO_PEER_RESULT:
break;
case WIRE_GOSSIP_GET_TXOUT:
get_txout(gossip, msg);
break;
@ -164,13 +144,6 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
u8 *msg;
int hsmfd;
u64 capabilities = HSM_CAP_SIGN_GOSSIP;
struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
bool allow_localhost = false;
#if DEVELOPER
if (ld->dev_allow_localhost)
allow_localhost = true;
#endif
msg = towire_hsm_client_hsmfd(tmpctx, &ld->id, 0, capabilities);
if (!wire_sync_write(ld->hsm_fd, msg))
@ -190,25 +163,12 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
if (!ld->gossip)
err(1, "Could not subdaemon gossip");
/* If no addr specified, hand wildcard to gossipd */
if (tal_count(wireaddrs) == 0 && ld->autolisten) {
wireaddrs = tal_arrz(tmpctx, struct wireaddr_internal, 1);
listen_announce = tal_arr(tmpctx, enum addr_listen_announce, 1);
wireaddrs->itype = ADDR_INTERNAL_ALLPROTO;
wireaddrs->u.port = ld->portnum;
*listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
}
msg = towire_gossipctl_init(
tmpctx, ld->config.broadcast_interval,
&get_chainparams(ld)->genesis_blockhash, &ld->id,
get_offered_global_features(tmpctx),
get_offered_local_features(tmpctx), wireaddrs,
listen_announce, ld->rgb,
ld->alias, ld->config.channel_update_interval, ld->reconnect,
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
allow_localhost, ld->config.use_dns,
ld->tor_service_password ? ld->tor_service_password : "",
ld->rgb,
ld->alias, ld->config.channel_update_interval,
ld->announcable);
subd_send_msg(ld->gossip, msg);
}