Browse Source

gossipd: remove connectd functionality, enable connectd.

This patch guts gossipd of all peer-related functionality, and hands
all the peer-related requests to channeld instead.

gossipd now gets the final announcable addresses in its init msg, since
it doesn't handle socket binding any more.

lightningd now actually starts connectd, and activates it.  The init
messages for both gossipd and connectd still contain redundant fields
which need cleaning up.

There are shims to handle the fact that connectd's wire messages are
still (mostly) gossipd messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
3d3d2ef9af
  1. 7
      connectd/connect.c
  2. 4
      gossipd/Makefile
  3. 1874
      gossipd/gossip.c
  4. 9
      gossipd/gossip_wire.csv
  5. 2
      lightningd/Makefile
  6. 2
      lightningd/channel.c
  7. 147
      lightningd/connect_control.c
  8. 2
      lightningd/connect_control.h
  9. 35
      lightningd/gossip_control.c
  10. 4
      lightningd/gossip_control.h
  11. 5
      lightningd/lightningd.c
  12. 5
      lightningd/lightningd.h
  13. 12
      lightningd/opening_control.c
  14. 46
      lightningd/peer_control.c
  15. 6
      lightningd/test/run-find_my_path.c
  16. 21
      tests/test_lightningd.py

7
connectd/connect.c

@ -1830,13 +1830,12 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
enum gossip_wire_type t= fromwire_peektype(master->msg_in);
/* FIXME: Move away from gossip wiretypes */
if (fromwire_peektype(master->msg_in) == WIRE_CONNECTCTL_INIT)
return gossip_init(master, daemon, master->msg_in);
if (fromwire_peektype(master->msg_in) == WIRE_CONNECTCTL_ACTIVATE)
return gossip_activate(master, daemon, master->msg_in);
switch (t) {
case WIRE_GOSSIPCTL_INIT:
return gossip_init(master, daemon, master->msg_in);
case WIRE_GOSSIPCTL_RELEASE_PEER:
return release_peer(conn, daemon, master->msg_in);
@ -1862,6 +1861,7 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
return disconnect_peer(conn, daemon, master->msg_in);
/* FIXME: We don't really do these, gossipd does */
case WIRE_GOSSIPCTL_INIT:
case WIRE_GOSSIPCTL_ACTIVATE:
case WIRE_GOSSIP_GETNODES_REQUEST:
case WIRE_GOSSIP_PING:
@ -1880,7 +1880,6 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
break;
/* We send these, we don't receive them */
case WIRE_GOSSIPCTL_ACTIVATE_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_GOSSIP_GETNODES_REPLY:

4
gossipd/Makefile

@ -16,11 +16,7 @@ LIGHTNINGD_GOSSIP_HEADERS := gossipd/gen_gossip_wire.h \
gossipd/gossip.h \
gossipd/gen_gossip_store.h \
gossipd/gossip_store.h \
gossipd/handshake.h \
gossipd/netaddress.h \
gossipd/routing.h \
gossipd/tor_autoservice.h \
gossipd/tor.h \
gossipd/broadcast.h
LIGHTNINGD_GOSSIP_SRC := $(LIGHTNINGD_GOSSIP_HEADERS:.h=.c)
LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o)

1874
gossipd/gossip.c

File diff suppressed because it is too large

9
gossipd/gossip_wire.csv

@ -23,19 +23,14 @@ 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
# Gossipd->master, I am ready, here's the addresses I bound, can announce.
gossipctl_activate_reply,3125
gossipctl_activate_reply,,num_bindings,u16
gossipctl_activate_reply,,bindings,num_bindings*struct wireaddr_internal
gossipctl_activate_reply,,num_announcable,u16
gossipctl_activate_reply,,announcable,num_announcable*struct wireaddr
# Master -> gossipd: Optional hint for where to find peer.
gossipctl_peer_addrhint,3014
gossipctl_peer_addrhint,,id,struct pubkey

Can't render this file because it has a wrong number of fields in line 6.

2
lightningd/Makefile

@ -118,7 +118,7 @@ check-makefile: check-lightningd-makefile
check-lightningd-makefile:
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS)
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS)
clean: lightningd-clean

2
lightningd/channel.c

@ -31,7 +31,7 @@ void channel_set_owner(struct channel *channel, struct subd *owner)
if (channel->connected && !connects_to_peer(owner)) {
u8 *msg = towire_gossipctl_peer_disconnected(NULL,
&channel->peer->id);
subd_send_msg(channel->peer->ld->gossip, take(msg));
subd_send_msg(channel->peer->ld->connectd, take(msg));
channel->connected = false;
}
}

147
lightningd/connect_control.c

@ -1,16 +1,28 @@
#include <bitcoin/pubkey.h>
#include <ccan/err/err.h>
#include <ccan/fdpass/fdpass.h>
#include <ccan/list/list.h>
#include <ccan/tal/str/str.h>
#include <common/features.h>
#include <common/wireaddr.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/capabilities.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <lightningd/channel.h>
#include <lightningd/connect_control.h>
#include <lightningd/gossip_control.h>
#include <lightningd/json.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/jsonrpc_errors.h>
#include <lightningd/lightningd.h>
#include <lightningd/log.h>
#include <lightningd/opening_control.h>
#include <lightningd/param.h>
#include <lightningd/subd.h>
#include <wire/gen_peer_wire.h>
#include <wire/wire_sync.h>
struct connect {
struct list_node list;
@ -168,13 +180,13 @@ static void json_connect(struct command *cmd,
/* Tell it about the address. */
msg = towire_gossipctl_peer_addrhint(cmd, &id, &addr);
subd_send_msg(cmd->ld->gossip, take(msg));
subd_send_msg(cmd->ld->connectd, take(msg));
}
/* If there isn't already a connect command, tell gossipd */
/* If there isn't already a connect command, tell connectd */
if (!find_connect(cmd->ld, &id)) {
msg = towire_gossipctl_connect_to_peer(NULL, &id);
subd_send_msg(cmd->ld->gossip, take(msg));
subd_send_msg(cmd->ld->connectd, take(msg));
}
/* Leave this here for gossip_connect_result */
new_connect(cmd->ld, &id, cmd);
@ -189,13 +201,140 @@ static const struct json_command connect_command = {
};
AUTODATA(json_command, &connect_command);
static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
{
struct pubkey id;
struct channel *c;
struct uncommitted_channel *uc;
if (!fromwire_connect_reconnected(msg, &id))
fatal("Bad msg %s from connectd", tal_hex(tmpctx, msg));
c = active_channel_by_id(ld, &id, &uc);
if (uc)
kill_uncommitted_channel(uc, "Reconnected");
else if (c)
channel_fail_transient(c, "Reconnected");
}
static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fds)
{
/* FIXME: Move away from gossip types */
if (fromwire_peektype(msg) == WIRE_CONNECT_RECONNECTED) {
peer_please_disconnect(connectd->ld, msg);
return 0;
}
return gossip_msg(connectd->ld->gossip, msg, fds);
}
static void connect_init_done(struct subd *connectd,
const u8 *reply,
const int *fds UNUSED,
void *unused UNUSED)
{
struct lightningd *ld = connectd->ld;
if (!fromwire_connectctl_init_reply(ld, reply,
&ld->binding,
&ld->announcable))
fatal("Bad connectctl_activate_reply: %s",
tal_hex(reply, reply));
/* Break out of loop, so we can begin */
io_break(connectd);
}
/* FIXME: This is a transition hack */
static const char *connect_and_gossip_wire_type_name(int e)
{
const char *name = connect_wire_type_name(e);
if (strstarts(name, "INVALID"))
name = gossip_wire_type_name(e);
return name;
}
int connectd_init(struct lightningd *ld)
{
/* FIXME: implement */
int fds[2];
u8 *msg;
int hsmfd;
u64 capabilities = HSM_CAP_ECDH;
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
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
fatal("Could not socketpair for connectd<->gossipd");
msg = towire_hsm_client_hsmfd(tmpctx, &ld->id, 0, capabilities);
if (!wire_sync_write(ld->hsm_fd, msg))
fatal("Could not write to HSM: %s", strerror(errno));
msg = wire_sync_read(tmpctx, ld->hsm_fd);
if (!fromwire_hsm_client_hsmfd_reply(msg))
fatal("Malformed hsmfd response: %s", tal_hex(msg, msg));
hsmfd = fdpass_recv(ld->hsm_fd);
if (hsmfd < 0)
fatal("Could not read fd from HSM: %s", strerror(errno));
ld->connectd = new_global_subd(ld, "lightning_connectd",
connect_and_gossip_wire_type_name, connectd_msg,
take(&hsmfd), take(&fds[1]), NULL);
if (!ld->connectd)
err(1, "Could not subdaemon connectd");
/* If no addr specified, hand wildcard to connectd */
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_connectctl_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 : "");
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_init_done, NULL);
/* Wait for init_reply */
io_loop(NULL, NULL);
return fds[0];
}
static void connect_activate_done(struct subd *connectd,
const u8 *reply UNUSED,
const int *fds UNUSED,
void *unused UNUSED)
{
/* Break out of loop, so we can begin */
io_break(connectd);
}
void connectd_activate(struct lightningd *ld)
{
const u8 *msg = towire_connectctl_activate(NULL, ld->listen);
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_activate_done, NULL);
/* Wait for activate_reply */
io_loop(NULL, NULL);
}

2
lightningd/connect_control.h

@ -7,6 +7,8 @@ struct pubkey;
/* Returns fd for gossipd to talk to connectd */
int connectd_init(struct lightningd *ld);
void connectd_activate(struct lightningd *ld);
void gossip_connect_result(struct lightningd *ld, const u8 *msg);
#endif /* LIGHTNING_LIGHTNINGD_CONNECT_CONTROL_H */

35
lightningd/gossip_control.c

@ -125,7 +125,7 @@ static void get_txout(struct subd *gossip, const u8 *msg)
}
}
static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
{
enum gossip_wire_type t = fromwire_peektype(msg);
@ -157,7 +157,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIPCTL_PEER_IMPORTANT:
case WIRE_GOSSIPCTL_PEER_DISCONNECTED:
/* This is a reply, so never gets through to here. */
case WIRE_GOSSIPCTL_ACTIVATE_REPLY:
case WIRE_GOSSIP_GET_UPDATE_REPLY:
case WIRE_GOSSIP_GETNODES_REPLY:
case WIRE_GOSSIP_GETROUTE_REPLY:
@ -203,7 +202,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
{
u8 *msg;
int hsmfd;
u64 capabilities = HSM_CAP_ECDH | HSM_CAP_SIGN_GOSSIP;
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;
@ -248,37 +247,11 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
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->tor_service_password ? ld->tor_service_password : "",
ld->announcable);
subd_send_msg(ld->gossip, msg);
}
static void gossip_activate_done(struct subd *gossip UNUSED,
const u8 *reply,
const int *fds UNUSED,
void *unused UNUSED)
{
struct lightningd *ld = gossip->ld;
if (!fromwire_gossipctl_activate_reply(gossip->ld, reply,
&ld->binding,
&ld->announcable))
fatal("Bad gossipctl_activate_reply: %s",
tal_hex(reply, reply));
/* Break out of loop, so we can begin */
io_break(gossip);
}
void gossip_activate(struct lightningd *ld)
{
const u8 *msg = towire_gossipctl_activate(NULL, ld->listen);
subd_req(ld->gossip, ld->gossip, take(msg), -1, 0,
gossip_activate_done, NULL);
/* Wait for activate done */
io_loop(NULL, NULL);
}
void gossipd_notify_spend(struct lightningd *ld,
const struct short_channel_id *scid)
{

4
lightningd/gossip_control.h

@ -8,9 +8,11 @@
struct lightningd;
void gossip_init(struct lightningd *ld, int connectd_fd);
void gossip_activate(struct lightningd *ld);
void gossipd_notify_spend(struct lightningd *ld,
const struct short_channel_id *scid);
/* FIXME: Exposing this is a hack for connectd transition. */
struct subd;
unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds);
#endif /* LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H */

5
lightningd/lightningd.c

@ -208,6 +208,7 @@ static void shutdown_subdaemons(struct lightningd *ld)
db_begin_transaction(ld->wallet->db);
/* Let everyone shutdown cleanly. */
close(ld->hsm_fd);
subd_shutdown(ld->connectd, 10);
subd_shutdown(ld->gossip, 10);
subd_shutdown(ld->hsm, 10);
@ -423,9 +424,9 @@ int main(int argc, char *argv[])
/* Create PID file */
pidfile_create(ld);
/* Activate gossip daemon. Needs to be after the initialization of
/* Activate connect daemon. Needs to be after the initialization of
* chaintopology, otherwise we may be asking for uninitialized data. */
gossip_activate(ld);
connectd_activate(ld);
/* Replay transactions for all running onchainds */
onchaind_replay_channels(ld);

5
lightningd/lightningd.h

@ -126,8 +126,11 @@ struct lightningd {
int hsm_fd;
struct subd *hsm;
/* Daemon for routing */
struct subd *gossip;
/* Daemon looking after peers during init / before channel. */
struct subd *gossip;
struct subd *connectd;
/* All peers we're tracking. */
struct list_head peers;

12
lightningd/opening_control.c

@ -123,9 +123,9 @@ static void uncommitted_channel_to_gossipd(struct lightningd *ld,
/* Hand back to gossipd, (maybe) with an error packet to send. */
msg = towire_gossipctl_hand_back_peer(errstr, &uc->peer->id, cs,
errorpkt);
subd_send_msg(ld->gossip, take(msg));
subd_send_fd(ld->gossip, peer_fd);
subd_send_fd(ld->gossip, gossip_fd);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
}
static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
@ -133,7 +133,7 @@ static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
{
u8 *msg = towire_gossipctl_peer_disconnected(tmpctx, &uc->peer->id);
log_info(uc->log, "%s", desc);
subd_send_msg(uc->peer->ld->gossip, msg);
subd_send_msg(uc->peer->ld->connectd, msg);
if (uc->fc)
command_fail(uc->fc->cmd, LIGHTNINGD, "%s", desc);
}
@ -275,7 +275,7 @@ void tell_gossipd_peer_is_important(struct lightningd *ld,
/* Tell gossipd we need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, true);
subd_send_msg(ld->gossip, take(msg));
subd_send_msg(ld->connectd, take(msg));
}
static void opening_funder_finished(struct subd *openingd, const u8 *resp,
@ -957,7 +957,7 @@ static void json_fund_channel(struct command *cmd,
tal_add_destructor(fc, remove_funding_channel_from_list);
msg = towire_gossipctl_release_peer(cmd, &fc->peerid);
subd_req(fc, cmd->ld->gossip, msg, -1, 2, gossip_peer_released, fc);
subd_req(fc, cmd->ld->connectd, msg, -1, 2, gossip_peer_released, fc);
command_still_pending(cmd);
}

46
lightningd/peer_control.c

@ -350,7 +350,7 @@ void drop_to_chain(struct lightningd *ld, struct channel *channel,
/* Tell gossipd we no longer need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, false);
subd_send_msg(ld->gossip, take(msg));
subd_send_msg(ld->connectd, take(msg));
sign_last_tx(channel);
@ -414,15 +414,15 @@ void channel_errmsg(struct channel *channel,
channel->owner->name,
err_for_them ? "sent" : "received", desc);
/* Hand back to gossipd, with any error packet. */
/* Hand back to connectdd, with any error packet. */
msg = towire_gossipctl_hand_back_peer(NULL, &channel->peer->id,
cs, err_for_them);
subd_send_msg(ld->gossip, take(msg));
subd_send_fd(ld->gossip, peer_fd);
subd_send_fd(ld->gossip, gossip_fd);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
}
/* Gossipd tells us a peer has connected: it never hands us duplicates, since
/* Connectd tells us a peer has connected: it never hands us duplicates, since
* it holds them until we say peer_died. */
void peer_connected(struct lightningd *ld, const u8 *msg,
int peer_fd, int gossip_fd)
@ -527,11 +527,11 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
error = NULL;
send_error:
/* Hand back to gossipd, with an error packet. */
/* Hand back to channeld, with an error packet. */
msg = towire_gossipctl_hand_back_peer(msg, &id, &cs, error);
subd_send_msg(ld->gossip, take(msg));
subd_send_fd(ld->gossip, peer_fd);
subd_send_fd(ld->gossip, gossip_fd);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
}
static struct channel *channel_by_channel_id(struct peer *peer,
@ -612,11 +612,11 @@ void peer_sent_nongossip(struct lightningd *ld,
fromwire_peektype(in_msg));
send_error:
/* Hand back to gossipd, with an error packet. */
/* Hand back to channeld, with an error packet. */
msg = towire_gossipctl_hand_back_peer(ld, id, cs, error);
subd_send_msg(ld->gossip, take(msg));
subd_send_fd(ld->gossip, peer_fd);
subd_send_fd(ld->gossip, gossip_fd);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
}
static enum watch_result funding_lockin_cb(struct channel *channel,
@ -951,8 +951,8 @@ static void json_listpeers(struct command *cmd,
NULL))
return;
/* Get peers from gossipd. */
subd_req(cmd, cmd->ld->gossip,
/* Get peers from connectd. */
subd_req(cmd, cmd->ld->connectd,
take(towire_gossip_getpeers_request(cmd, gpa->specific_id)),
-1, 0, gossipd_getpeers_complete, gpa);
command_still_pending(cmd);
@ -1104,11 +1104,11 @@ static void activate_peer(struct peer *peer)
struct channel *channel;
struct lightningd *ld = peer->ld;
/* Pass gossipd any addrhints we currently have */
/* Pass channeld any addrhints we currently have */
msg = towire_gossipctl_peer_addrhint(peer, &peer->id, &peer->addr);
subd_send_msg(peer->ld->gossip, take(msg));
subd_send_msg(peer->ld->connectd, take(msg));
/* We can only have one active channel: make sure gossipd
/* We can only have one active channel: make sure connectd
* knows to reconnect. */
channel = peer_active_channel(peer);
if (channel)
@ -1128,8 +1128,8 @@ void activate_peers(struct lightningd *ld)
activate_peer(p);
}
/* Peer has been released from gossip. */
static void gossip_peer_disconnected (struct subd *gossip,
/* Peer has been released from connectd. */
static void gossip_peer_disconnected (struct subd *connectd,
const u8 *resp,
const int *fds,
struct command *cmd) {
@ -1138,7 +1138,7 @@ static void gossip_peer_disconnected (struct subd *gossip,
if (!fromwire_gossipctl_peer_disconnect_reply(resp)) {
if (!fromwire_gossipctl_peer_disconnect_replyfail(resp, &isconnected))
fatal("Gossip daemon gave invalid reply %s",
tal_hex(gossip, resp));
tal_hex(tmpctx, resp));
if (isconnected)
command_fail(cmd, LIGHTNINGD,
"Peer is not in gossip mode");
@ -1163,7 +1163,7 @@ static void json_disconnect(struct command *cmd,
return;
msg = towire_gossipctl_peer_disconnect(cmd, &id);
subd_req(cmd, cmd->ld->gossip, msg, -1, 0, gossip_peer_disconnected, cmd);
subd_req(cmd, cmd->ld->connectd, msg, -1, 0, gossip_peer_disconnected, cmd);
command_still_pending(cmd);
}

6
lightningd/test/run-find_my_path.c

@ -15,6 +15,9 @@ void begin_topology(struct chain_topology *topo UNNEEDED)
void channel_notify_new_block(struct lightningd *ld UNNEEDED,
u32 block_height UNNEEDED)
{ fprintf(stderr, "channel_notify_new_block called!\n"); abort(); }
/* Generated stub for connectd_activate */
void connectd_activate(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "connectd_activate called!\n"); abort(); }
/* Generated stub for connectd_init */
int connectd_init(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "connectd_init called!\n"); abort(); }
@ -50,9 +53,6 @@ void fatal(const char *fmt UNNEEDED, ...)
/* Generated stub for free_htlcs */
void free_htlcs(struct lightningd *ld UNNEEDED, const struct channel *channel UNNEEDED)
{ fprintf(stderr, "free_htlcs called!\n"); abort(); }
/* Generated stub for gossip_activate */
void gossip_activate(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "gossip_activate called!\n"); abort(); }
/* Generated stub for gossip_init */
void gossip_init(struct lightningd *ld UNNEEDED, int connectd_fd UNNEEDED)
{ fprintf(stderr, "gossip_init called!\n"); abort(); }

21
tests/test_lightningd.py

@ -695,6 +695,7 @@ class LightningDTests(BaseLightningDTests):
l1.rpc.connect, '032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e', 'localhost', l2.port)
@unittest.skipIf(not DEVELOPER, "needs --dev-allow-localhost")
@unittest.skip("FIXME: Re-enable once gossipd gives out addresses to connectd")
def test_connect_by_gossip(self):
"""Test connecting to an unknown peer using node gossip
"""
@ -2782,8 +2783,8 @@ class LightningDTests(BaseLightningDTests):
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
# Need full IO logging so we can see gossip (from gossipd and channeld)
subprocess.run(['kill', '-USR1', l1.subd_pid('gossipd')])
# Need full IO logging so we can see gossip (from connectd and channeld)
subprocess.run(['kill', '-USR1', l1.subd_pid('connectd')])
# Empty result tests.
reply = l1.rpc.dev_query_scids(l2.info['id'], ['1:1:1', '2:2:2'])
@ -2840,9 +2841,9 @@ class LightningDTests(BaseLightningDTests):
l2 = self.node_factory.get_node()
l3 = self.node_factory.get_node()
# Full IO logging for gossipds
subprocess.run(['kill', '-USR1', l1.subd_pid('gossipd')])
subprocess.run(['kill', '-USR1', l2.subd_pid('gossipd')])
# Full IO logging for connectds
subprocess.run(['kill', '-USR1', l1.subd_pid('connectd')])
subprocess.run(['kill', '-USR1', l2.subd_pid('connectd')])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
@ -2951,9 +2952,9 @@ class LightningDTests(BaseLightningDTests):
may_reconnect=True)
l4 = self.node_factory.get_node(may_reconnect=True)
# Turn on IO logging for gossipds
subprocess.run(['kill', '-USR1', l1.subd_pid('gossipd')])
subprocess.run(['kill', '-USR1', l2.subd_pid('gossipd')])
# Turn on IO logging for connectd
subprocess.run(['kill', '-USR1', l1.subd_pid('connectd')])
subprocess.run(['kill', '-USR1', l2.subd_pid('connectd')])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
@ -3555,8 +3556,8 @@ class LightningDTests(BaseLightningDTests):
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# We should get a message about reconnecting, but order unsynced.
l2.daemon.wait_for_logs(['gossipd.*reconnect for active peer',
'openingd.*Error reading gossip msg'])
l2.daemon.wait_for_logs(['connectd.*reconnect for active peer',
'Killing openingd: Reconnected'])
# Should work fine.
l1.rpc.fundchannel(l2.info['id'], 20000)

Loading…
Cancel
Save