Browse Source

connectd: wean off gossip_wire message types, use our own.

This involves much renaming of gossip -> channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
5c066b9a25
  1. 149
      connectd/connect.c
  2. 95
      connectd/connect_wire.csv
  3. 4
      lightningd/channel.c
  4. 104
      lightningd/connect_control.c
  5. 75
      lightningd/gossip_control.c
  6. 3
      lightningd/gossip_control.h
  7. 56
      lightningd/opening_control.c
  8. 4
      lightningd/opening_control.h
  9. 60
      lightningd/peer_control.c
  10. 68
      wallet/test/run-wallet.c

149
connectd/connect.c

@ -58,7 +58,7 @@
#include <wire/wire_sync.h>
#include <zlib.h>
#define GOSSIP_MAX_REACH_ATTEMPTS 10
#define CONNECT_MAX_REACH_ATTEMPTS 10
#define HSM_FD 3
#define GOSSIPCTL_FD 4
@ -417,7 +417,7 @@ static void reached_peer(struct peer *peer, struct io_conn *conn)
/* Tell any connect command what happened. */
if (r->master_needs_response) {
msg = towire_gossipctl_connect_to_peer_result(NULL, &r->id,
msg = towire_connectctl_connect_to_peer_result(NULL, &r->id,
true, "");
daemon_conn_send(&peer->daemon->master, take(msg));
}
@ -548,7 +548,7 @@ static struct io_plan *peer_connected(struct io_conn *conn, struct peer *peer)
return io_close(conn);
/* We will not have anything queued, since we're not duplex. */
msg = towire_gossip_peer_connected(peer, &peer->id, &peer->addr,
msg = towire_connect_peer_connected(peer, &peer->id, &peer->addr,
&peer->local->pcs.cs,
peer->gfeatures, peer->lfeatures);
send_peer_with_fds(peer, msg);
@ -614,7 +614,7 @@ static struct io_plan *init_new_peer(struct io_conn *conn,
* dies while we're waiting for it to finish IO */
static void fail_release(struct peer *peer)
{
u8 *msg = towire_gossipctl_release_peer_replyfail(NULL);
u8 *msg = towire_connectctl_release_peer_replyfail(NULL);
daemon_conn_send(&peer->daemon->master, take(msg));
}
@ -622,14 +622,14 @@ static struct io_plan *ready_for_master(struct io_conn *conn, struct peer *peer)
{
u8 *msg;
if (peer->local->nongossip_msg)
msg = towire_gossip_peer_nongossip(peer, &peer->id,
msg = towire_connect_peer_nongossip(peer, &peer->id,
&peer->addr,
&peer->local->pcs.cs,
peer->gfeatures,
peer->lfeatures,
peer->local->nongossip_msg);
else
msg = towire_gossipctl_release_peer_reply(peer,
msg = towire_connectctl_release_peer_reply(peer,
&peer->addr,
&peer->local->pcs.cs,
peer->gfeatures,
@ -894,10 +894,10 @@ static struct io_plan *hand_back_peer(struct io_conn *conn,
struct returning_peer *rpeer = tal(daemon, struct returning_peer);
rpeer->daemon = daemon;
if (!fromwire_gossipctl_hand_back_peer(msg, msg,
if (!fromwire_connectctl_hand_back_peer(msg, msg,
&rpeer->id, &rpeer->cs,
&rpeer->inner_msg))
master_badmsg(WIRE_GOSSIPCTL_HAND_BACK_PEER, msg);
master_badmsg(WIRE_CONNECTCTL_HAND_BACK_PEER, msg);
status_debug("Handing back peer %s to master",
type_to_string(msg, struct pubkey, &rpeer->id));
@ -912,20 +912,20 @@ static struct io_plan *disconnect_peer(struct io_conn *conn, struct daemon *daem
struct pubkey id;
struct peer *peer;
if (!fromwire_gossipctl_peer_disconnect(msg, &id))
master_badmsg(WIRE_GOSSIPCTL_PEER_DISCONNECT, msg);
if (!fromwire_connectctl_peer_disconnect(msg, &id))
master_badmsg(WIRE_CONNECTCTL_PEER_DISCONNECT, msg);
peer = find_peer(daemon, &id);
if (peer && peer->local) {
/* This peer is local to this (gossipd) daemon */
/* This peer is local to this (connectd) daemon */
io_close(peer->local->conn);
msg = towire_gossipctl_peer_disconnect_reply(NULL);
msg = towire_connectctl_peer_disconnect_reply(NULL);
daemon_conn_send(&daemon->master, take(msg));
} else {
status_trace("disconnect_peer: peer %s %s",
type_to_string(tmpctx, struct pubkey, &id),
!peer ? "not connected" : "not gossiping");
msg = towire_gossipctl_peer_disconnect_replyfail(NULL, peer ? true : false);
msg = towire_connectctl_peer_disconnect_replyfail(NULL, peer ? true : false);
daemon_conn_send(&daemon->master, take(msg));
}
return daemon_conn_read_next(conn, &daemon->master);
@ -937,8 +937,8 @@ static struct io_plan *release_peer(struct io_conn *conn, struct daemon *daemon,
struct pubkey id;
struct peer *peer;
if (!fromwire_gossipctl_release_peer(msg, &id))
master_badmsg(WIRE_GOSSIPCTL_RELEASE_PEER, msg);
if (!fromwire_connectctl_release_peer(msg, &id))
master_badmsg(WIRE_CONNECTCTL_RELEASE_PEER, msg);
peer = find_peer(daemon, &id);
if (!peer || !peer->local || peer->local->return_to_master) {
@ -948,7 +948,7 @@ static struct io_plan *release_peer(struct io_conn *conn, struct daemon *daemon,
!peer ? "not found"
: peer->local ? "already releasing"
: "not local");
msg = towire_gossipctl_release_peer_replyfail(NULL);
msg = towire_connectctl_release_peer_replyfail(NULL);
daemon_conn_send(&daemon->master, take(msg));
} else {
peer->local->return_to_master = true;
@ -1271,10 +1271,10 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx,
}
/* Parse an incoming gossip init message and assign config variables
/* Parse an incoming connect init message and assign config variables
* to the daemon.
*/
static struct io_plan *gossip_init(struct daemon_conn *master,
static struct io_plan *connect_init(struct daemon_conn *master,
struct daemon *daemon,
const u8 *msg)
{
@ -1318,7 +1318,7 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
return daemon_conn_read_next(master->conn, master);
}
static struct io_plan *gossip_activate(struct daemon_conn *master,
static struct io_plan *connect_activate(struct daemon_conn *master,
struct daemon *daemon,
const u8 *msg)
{
@ -1377,7 +1377,7 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
/* Tell any connect command what happened. */
if (reach->master_needs_response) {
msg = towire_gossipctl_connect_to_peer_result(NULL, &reach->id,
msg = towire_connectctl_connect_to_peer_result(NULL, &reach->id,
false, err);
daemon_conn_send(&reach->daemon->master, take(msg));
}
@ -1547,7 +1547,7 @@ static void try_reach_peer(struct daemon *daemon, const struct pubkey *id,
status_debug("try_reach_peer: have peer %s",
type_to_string(tmpctx, struct pubkey, id));
if (master_needs_response) {
msg = towire_gossipctl_connect_to_peer_result(NULL, id,
msg = towire_connectctl_connect_to_peer_result(NULL, id,
true,
"");
daemon_conn_send(&daemon->master, take(msg));
@ -1593,7 +1593,7 @@ static void try_reach_peer(struct daemon *daemon, const struct pubkey *id,
status_debug("No address known for %s, giving up",
type_to_string(tmpctx, struct pubkey, id));
if (master_needs_response) {
msg = towire_gossipctl_connect_to_peer_result(NULL, id,
msg = towire_connectctl_connect_to_peer_result(NULL, id,
false,
"No address known, giving up");
daemon_conn_send(&daemon->master, take(msg));
@ -1659,7 +1659,7 @@ static void try_reach_peer(struct daemon *daemon, const struct pubkey *id,
strerror(errno));
status_debug("%s", err);
if (master_needs_response) {
msg = towire_gossipctl_connect_to_peer_result(NULL, id,
msg = towire_connectctl_connect_to_peer_result(NULL, id,
false, err);
daemon_conn_send(&daemon->master, take(msg));
}
@ -1702,8 +1702,8 @@ static struct io_plan *connect_to_peer(struct io_conn *conn,
struct pubkey id;
struct important_peerid *imp;
if (!fromwire_gossipctl_connect_to_peer(msg, &id))
master_badmsg(WIRE_GOSSIPCTL_CONNECT_TO_PEER, msg);
if (!fromwire_connectctl_connect_to_peer(msg, &id))
master_badmsg(WIRE_CONNECTCTL_CONNECT_TO_PEER, msg);
/* If this is an important peer, free any outstanding timer */
imp = important_peerid_map_get(&daemon->important_peerids, &id);
@ -1718,8 +1718,8 @@ static struct io_plan *addr_hint(struct io_conn *conn,
{
struct addrhint *a = tal(daemon, struct addrhint);
if (!fromwire_gossipctl_peer_addrhint(msg, &a->id, &a->addr))
master_badmsg(WIRE_GOSSIPCTL_PEER_ADDRHINT, msg);
if (!fromwire_connectctl_peer_addrhint(msg, &a->id, &a->addr))
master_badmsg(WIRE_CONNECTCTL_PEER_ADDRHINT, msg);
/* Replace any old one. */
tal_free(find_addrhint(daemon, &a->id));
@ -1737,8 +1737,8 @@ static struct io_plan *peer_important(struct io_conn *conn,
bool important;
struct important_peerid *imp;
if (!fromwire_gossipctl_peer_important(msg, &id, &important))
master_badmsg(WIRE_GOSSIPCTL_PEER_IMPORTANT, msg);
if (!fromwire_connectctl_peer_important(msg, &id, &important))
master_badmsg(WIRE_CONNECTCTL_PEER_IMPORTANT, msg);
imp = important_peerid_map_get(&daemon->important_peerids, &id);
if (important) {
@ -1770,8 +1770,8 @@ static struct io_plan *peer_disconnected(struct io_conn *conn,
struct pubkey id;
struct peer *peer;
if (!fromwire_gossipctl_peer_disconnected(msg, &id))
master_badmsg(WIRE_GOSSIPCTL_PEER_DISCONNECTED, msg);
if (!fromwire_connectctl_peer_disconnected(msg, &id))
master_badmsg(WIRE_CONNECTCTL_PEER_DISCONNECTED, msg);
peer = find_peer(daemon, &id);
if (!peer)
@ -1825,8 +1825,8 @@ static struct io_plan *get_peers(struct io_conn *conn,
const struct gossip_getnodes_entry **nodes = tal_arr(conn, const struct gossip_getnodes_entry *, n);
struct pubkey *specific_id;
if (!fromwire_gossip_getpeers_request(msg, msg, &specific_id))
master_badmsg(WIRE_GOSSIPCTL_PEER_ADDRHINT, msg);
if (!fromwire_connect_getpeers_request(msg, msg, &specific_id))
master_badmsg(WIRE_CONNECTCTL_PEER_ADDRHINT, msg);
list_for_each(&daemon->peers, peer, list) {
if (specific_id && !pubkey_eq(specific_id, &peer->id))
@ -1842,7 +1842,7 @@ static struct io_plan *get_peers(struct io_conn *conn,
}
daemon_conn_send(&daemon->master,
take(towire_gossip_getpeers_reply(NULL, id, wireaddr, nodes)));
take(towire_connect_getpeers_reply(NULL, id, wireaddr, nodes)));
return daemon_conn_read_next(conn, &daemon->master);
}
@ -1850,80 +1850,51 @@ static struct io_plan *get_peers(struct io_conn *conn,
static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master)
{
struct daemon *daemon = container_of(master, struct daemon, 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);
enum connect_wire_type t = fromwire_peektype(master->msg_in);
switch (t) {
case WIRE_GOSSIPCTL_RELEASE_PEER:
case WIRE_CONNECTCTL_INIT:
return connect_init(master, daemon, master->msg_in);
case WIRE_CONNECTCTL_ACTIVATE:
return connect_activate(master, daemon, master->msg_in);
case WIRE_CONNECTCTL_RELEASE_PEER:
return release_peer(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_HAND_BACK_PEER:
case WIRE_CONNECTCTL_HAND_BACK_PEER:
return hand_back_peer(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_CONNECT_TO_PEER:
case WIRE_CONNECTCTL_CONNECT_TO_PEER:
return connect_to_peer(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_PEER_ADDRHINT:
case WIRE_CONNECTCTL_PEER_ADDRHINT:
return addr_hint(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_PEER_IMPORTANT:
case WIRE_CONNECTCTL_PEER_IMPORTANT:
return peer_important(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_PEER_DISCONNECTED:
case WIRE_CONNECTCTL_PEER_DISCONNECTED:
return peer_disconnected(conn, daemon, master->msg_in);
case WIRE_GOSSIP_GETPEERS_REQUEST:
case WIRE_CONNECT_GETPEERS_REQUEST:
return get_peers(conn, daemon, master->msg_in);
case WIRE_GOSSIPCTL_PEER_DISCONNECT:
case WIRE_CONNECTCTL_PEER_DISCONNECT:
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:
case WIRE_GOSSIP_QUERY_SCIDS:
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIP_OUTPOINT_SPENT:
case WIRE_GOSSIP_LOCAL_CHANNEL_CLOSE:
case WIRE_GOSSIP_GET_TXOUT_REPLY:
case WIRE_GOSSIP_ROUTING_FAILURE:
case WIRE_GOSSIP_MARK_CHANNEL_UNROUTABLE:
case WIRE_GOSSIP_GETROUTE_REQUEST:
case WIRE_GOSSIP_GETCHANNELS_REQUEST:
case WIRE_GOSSIP_RESOLVE_CHANNEL_REQUEST:
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:
case WIRE_CONNECTCTL_INIT_REPLY:
case WIRE_CONNECTCTL_ACTIVATE_REPLY:
case WIRE_CONNECTCTL_RELEASE_PEER_REPLY:
case WIRE_CONNECTCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_CONNECT_GETPEERS_REPLY:
case WIRE_CONNECT_PEER_CONNECTED:
case WIRE_CONNECTCTL_CONNECT_TO_PEER_RESULT:
case WIRE_CONNECT_PEER_NONGOSSIP:
case WIRE_CONNECTCTL_PEER_DISCONNECT_REPLY:
case WIRE_CONNECTCTL_PEER_DISCONNECT_REPLYFAIL:
case WIRE_CONNECT_RECONNECTED:
break;
}

95
connectd/connect_wire.csv

@ -1,4 +1,6 @@
#include <common/cryptomsg.h>
#include <common/wireaddr.h>
#include <lightningd/gossip_msg.h>
connectctl_init,2000
connectctl_init,,broadcast_interval,u32
@ -39,3 +41,96 @@ connectctl_activate_reply,2125
# connectd->master: disconnect this peer please (due to reconnect).
connect_reconnected,2112
connect_reconnected,,id,struct pubkey
# Master -> connectd: Optional hint for where to find peer.
connectctl_peer_addrhint,2014
connectctl_peer_addrhint,,id,struct pubkey
connectctl_peer_addrhint,,addr,struct wireaddr_internal
# Master -> connectd: connect to a peer.
connectctl_connect_to_peer,2001
connectctl_connect_to_peer,,id,struct pubkey
# Connectd->master: result (not a reply since it can be out-of-order, but
# you will get one reply for every request).
connectctl_connect_to_peer_result,2020
connectctl_connect_to_peer_result,,id,struct pubkey
# True it connected.
connectctl_connect_to_peer_result,,connected,bool
# Otherwise, why we can't reach them.
connectctl_connect_to_peer_result,,failreason,wirestring
# Master -> connectd: try to always maintain connection to this peer (or not)
connectctl_peer_important,2010
connectctl_peer_important,,id,struct pubkey
connectctl_peer_important,,important,bool
# Connectd -> master: we got a peer. Two fds: peer and gossip
connect_peer_connected,2002
connect_peer_connected,,id,struct pubkey
connect_peer_connected,,addr,struct wireaddr_internal
connect_peer_connected,,crypto_state,struct crypto_state
connect_peer_connected,,gflen,u16
connect_peer_connected,,gfeatures,gflen*u8
connect_peer_connected,,lflen,u16
connect_peer_connected,,lfeatures,lflen*u8
# Connectd -> master: peer sent non-gossip packet. Two fds: peer and gossip
connect_peer_nongossip,2003
connect_peer_nongossip,,id,struct pubkey
connect_peer_nongossip,,addr,struct wireaddr_internal
connect_peer_nongossip,,crypto_state,struct crypto_state
connect_peer_nongossip,,gflen,u16
connect_peer_nongossip,,gfeatures,gflen*u8
connect_peer_nongossip,,lflen,u16
connect_peer_nongossip,,lfeatures,lflen*u8
connect_peer_nongossip,,len,u16
connect_peer_nongossip,,msg,len*u8
# Master -> connectd: release a peer (so we can open a channel)
connectctl_release_peer,2004
connectctl_release_peer,,id,struct pubkey
# Connectd -> master: reply to connect_release_peer. Two fds: peer and gossip.
connectctl_release_peer_reply,2104
connectctl_release_peer_reply,,addr,struct wireaddr_internal
connectctl_release_peer_reply,,crypto_state,struct crypto_state
connectctl_release_peer_reply,,gflen,u16
connectctl_release_peer_reply,,gfeatures,gflen*u8
connectctl_release_peer_reply,,lflen,u16
connectctl_release_peer_reply,,lfeatures,lflen*u8
# Connectd -> master: reply to connect_release_peer if we couldn't find the peer.
connectctl_release_peer_replyfail,2204
# master -> connectd: take back peer, with optional msg. (+peer fd, +gossip fd)
connectctl_hand_back_peer,2013
connectctl_hand_back_peer,,id,struct pubkey
connectctl_hand_back_peer,,crypto_state,struct crypto_state
connectctl_hand_back_peer,,len,u16
connectctl_hand_back_peer,,msg,len*u8
# master -> connectd: peer has disconnected.
connectctl_peer_disconnected,2015
connectctl_peer_disconnected,,id,struct pubkey
# The main daemon asks for peers
connect_getpeers_request,2011
connect_getpeers_request,,id,?struct pubkey
connect_getpeers_reply,2111
connect_getpeers_reply,,num,u16
connect_getpeers_reply,,id,num*struct pubkey
connect_getpeers_reply,,addr,num*struct wireaddr_internal
connect_getpeers_reply,,nodes,num*struct gossip_getnodes_entry
# master->connectd: Request to disconnect from a peer.
connectctl_peer_disconnect,2023
connectctl_peer_disconnect,,id,struct pubkey
# Connectd -> master: reply to connect_peer_disconnect with peer id.
connectctl_peer_disconnect_reply,2123
# Connectd -> master: reply to connect_peer_disconnect if we couldn't find the peer.
connectctl_peer_disconnect_replyfail,2223
connectctl_peer_disconnect_replyfail,,isconnected,bool

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

4
lightningd/channel.c

@ -2,8 +2,8 @@
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/tal/str/str.h>
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <lightningd/channel.h>
@ -29,7 +29,7 @@ void channel_set_owner(struct channel *channel, struct subd *owner)
if (old_owner) {
subd_release_channel(old_owner, channel);
if (channel->connected && !connects_to_peer(owner)) {
u8 *msg = towire_gossipctl_peer_disconnected(NULL,
u8 *msg = towire_connectctl_peer_disconnected(NULL,
&channel->peer->id);
subd_send_msg(channel->peer->ld->connectd, take(msg));
channel->connected = false;

104
lightningd/connect_control.c

@ -7,12 +7,10 @@
#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>
@ -20,6 +18,7 @@
#include <lightningd/log.h>
#include <lightningd/opening_control.h>
#include <lightningd/param.h>
#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
#include <wire/gen_peer_wire.h>
#include <wire/wire_sync.h>
@ -60,18 +59,18 @@ static struct connect *find_connect(struct lightningd *ld,
return NULL;
}
void gossip_connect_result(struct lightningd *ld, const u8 *msg)
static void connectd_connect_result(struct lightningd *ld, const u8 *msg)
{
struct pubkey id;
bool connected;
char *err;
struct connect *c;
if (!fromwire_gossipctl_connect_to_peer_result(tmpctx, msg,
if (!fromwire_connectctl_connect_to_peer_result(tmpctx, msg,
&id,
&connected,
&err))
fatal("Gossip gave bad GOSSIPCTL_CONNECT_TO_PEER_RESULT message %s",
fatal("Connect gave bad CONNECTCTL_CONNECT_TO_PEER_RESULT message %s",
tal_hex(msg, msg));
@ -179,16 +178,16 @@ static void json_connect(struct command *cmd,
}
/* Tell it about the address. */
msg = towire_gossipctl_peer_addrhint(cmd, &id, &addr);
msg = towire_connectctl_peer_addrhint(cmd, &id, &addr);
subd_send_msg(cmd->ld->connectd, take(msg));
}
/* If there isn't already a connect command, tell connectd */
if (!find_connect(cmd->ld, &id)) {
msg = towire_gossipctl_connect_to_peer(NULL, &id);
msg = towire_connectctl_connect_to_peer(NULL, &id);
subd_send_msg(cmd->ld->connectd, take(msg));
}
/* Leave this here for gossip_connect_result */
/* Leave this here for connect_connect_result */
new_connect(cmd->ld, &id, cmd);
command_still_pending(cmd);
}
@ -217,15 +216,83 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
channel_fail_transient(c, "Reconnected");
}
static void peer_nongossip(struct subd *connectd, const u8 *msg,
int peer_fd, int gossip_fd)
{
struct pubkey id;
struct crypto_state cs;
struct wireaddr_internal addr;
u8 *gfeatures, *lfeatures, *in_pkt;
if (!fromwire_connect_peer_nongossip(msg, msg,
&id, &addr, &cs,
&gfeatures,
&lfeatures,
&in_pkt))
fatal("Connectd gave bad CONNECT_PEER_NONGOSSIP message %s",
tal_hex(msg, msg));
/* We already checked the features when it first connected. */
if (!features_supported(gfeatures, lfeatures)) {
log_unusual(connectd->log,
"Connectd gave unsupported features %s/%s",
tal_hex(msg, gfeatures),
tal_hex(msg, lfeatures));
close(peer_fd);
close(gossip_fd);
return;
}
peer_sent_nongossip(connectd->ld, &id, &addr, &cs,
gfeatures, lfeatures,
peer_fd, gossip_fd, in_pkt);
}
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) {
enum connect_wire_type t = fromwire_peektype(msg);
switch (t) {
/* These are messages we send, not them. */
case WIRE_CONNECTCTL_INIT:
case WIRE_CONNECTCTL_ACTIVATE:
case WIRE_CONNECT_GETPEERS_REQUEST:
case WIRE_CONNECTCTL_PEER_ADDRHINT:
case WIRE_CONNECTCTL_CONNECT_TO_PEER:
case WIRE_CONNECTCTL_PEER_IMPORTANT:
case WIRE_CONNECTCTL_RELEASE_PEER:
case WIRE_CONNECTCTL_HAND_BACK_PEER:
case WIRE_CONNECTCTL_PEER_DISCONNECTED:
case WIRE_CONNECTCTL_PEER_DISCONNECT:
/* This is a reply, so never gets through to here. */
case WIRE_CONNECTCTL_INIT_REPLY:
case WIRE_CONNECTCTL_ACTIVATE_REPLY:
case WIRE_CONNECT_GETPEERS_REPLY:
case WIRE_CONNECTCTL_RELEASE_PEER_REPLY:
case WIRE_CONNECTCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_CONNECTCTL_PEER_DISCONNECT_REPLY:
case WIRE_CONNECTCTL_PEER_DISCONNECT_REPLYFAIL:
break;
case WIRE_CONNECT_RECONNECTED:
peer_please_disconnect(connectd->ld, msg);
return 0;
break;
case WIRE_CONNECT_PEER_CONNECTED:
if (tal_count(fds) != 2)
return 2;
peer_connected(connectd->ld, msg, fds[0], fds[1]);
break;
case WIRE_CONNECT_PEER_NONGOSSIP:
if (tal_count(fds) != 2)
return 2;
peer_nongossip(connectd, msg, fds[0], fds[1]);
break;
case WIRE_CONNECTCTL_CONNECT_TO_PEER_RESULT:
connectd_connect_result(connectd->ld, msg);
break;
}
return gossip_msg(connectd->ld->gossip, msg, fds);
return 0;
}
static void connect_init_done(struct subd *connectd,
@ -245,15 +312,6 @@ static void connect_init_done(struct subd *connectd,
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)
{
int fds[2];
@ -284,7 +342,7 @@ int connectd_init(struct lightningd *ld)
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,
connect_wire_type_name, connectd_msg,
take(&hsmfd), take(&fds[1]), NULL);
if (!ld->connectd)
err(1, "Could not subdaemon connectd");

75
lightningd/gossip_control.c

@ -32,38 +32,6 @@
#include <wire/gen_peer_wire.h>
#include <wire/wire_sync.h>
static void peer_nongossip(struct subd *gossip, const u8 *msg,
int peer_fd, int gossip_fd)
{
struct pubkey id;
struct crypto_state cs;
struct wireaddr_internal addr;
u8 *gfeatures, *lfeatures, *in_pkt;
if (!fromwire_gossip_peer_nongossip(msg, msg,
&id, &addr, &cs,
&gfeatures,
&lfeatures,
&in_pkt))
fatal("Gossip gave bad GOSSIP_PEER_NONGOSSIP message %s",
tal_hex(msg, msg));
/* We already checked the features when it first connected. */
if (!features_supported(gfeatures, lfeatures)) {
log_unusual(gossip->log,
"Gossip gave unsupported features %s/%s",
tal_hex(msg, gfeatures),
tal_hex(msg, lfeatures));
close(peer_fd);
close(gossip_fd);
return;
}
peer_sent_nongossip(gossip->ld, &id, &addr, &cs,
gfeatures, lfeatures,
peer_fd, gossip_fd, in_pkt);
}
static void got_txout(struct bitcoind *bitcoind,
const struct bitcoin_tx_output *output,
struct short_channel_id *scid)
@ -125,24 +93,18 @@ static void get_txout(struct subd *gossip, const u8 *msg)
}
}
unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
{
enum gossip_wire_type t = fromwire_peektype(msg);
switch (t) {
/* These are messages we send, not them. */
case WIRE_GOSSIPCTL_INIT:
case WIRE_GOSSIPCTL_ACTIVATE:
case WIRE_GOSSIP_GETNODES_REQUEST:
case WIRE_GOSSIP_GETROUTE_REQUEST:
case WIRE_GOSSIP_GETCHANNELS_REQUEST:
case WIRE_GOSSIP_GETPEERS_REQUEST:
case WIRE_GOSSIP_PING:
case WIRE_GOSSIP_RESOLVE_CHANNEL_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_GOSSIP_GET_UPDATE:
case WIRE_GOSSIP_SEND_GOSSIP:
case WIRE_GOSSIP_GET_TXOUT_REPLY:
@ -153,45 +115,44 @@ unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIPCTL_PEER_DISCONNECT:
case WIRE_GOSSIPCTL_PEER_IMPORTANT:
case WIRE_GOSSIPCTL_PEER_DISCONNECTED:
/* This is a reply, so never gets through to here. */
case WIRE_GOSSIP_GET_UPDATE_REPLY:
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_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLYFAIL:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLY:
case WIRE_GOSSIPCTL_PEER_DISCONNECT_REPLYFAIL:
/* These are inter-daemon messages, not received by us */
case WIRE_GOSSIP_LOCAL_ADD_CHANNEL:
case WIRE_GOSSIP_LOCAL_CHANNEL_UPDATE:
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:
if (tal_count(fds) != 2)
return 2;
peer_connected(gossip->ld, msg, fds[0], fds[1]);
break;
case WIRE_GOSSIP_PEER_NONGOSSIP:
if (tal_count(fds) != 2)
return 2;
peer_nongossip(gossip, msg, fds[0], fds[1]);
case WIRE_GOSSIPCTL_CONNECT_TO_PEER_RESULT:
break;
case WIRE_GOSSIP_GET_TXOUT:
get_txout(gossip, msg);
break;
case WIRE_GOSSIPCTL_CONNECT_TO_PEER_RESULT:
gossip_connect_result(gossip->ld, msg);
break;
}
return 0;
}

3
lightningd/gossip_control.h

@ -12,7 +12,4 @@ void gossip_init(struct lightningd *ld, int connectd_fd);
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 */

56
lightningd/opening_control.c

@ -6,8 +6,8 @@
#include <common/key_derive.h>
#include <common/wallet_tx.h>
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel_control.h>
@ -67,7 +67,7 @@ struct uncommitted_channel {
struct funding_channel {
/* In lightningd->fundchannels while waiting for gossipd reply. */
/* In lightningd->fundchannels while waiting for connectd reply. */
struct list_node list;
struct command *cmd; /* Which also owns us. */
@ -99,8 +99,8 @@ static void remove_funding_channel_from_list(struct funding_channel *fc)
list_del_from(&fc->cmd->ld->fundchannels, &fc->list);
}
/* Opening failed: hand back to gossipd (sending errpkt if not NULL) */
static void uncommitted_channel_to_gossipd(struct lightningd *ld,
/* Opening failed: hand back to connectd (sending errpkt if not NULL) */
static void uncommitted_channel_to_connectd(struct lightningd *ld,
struct uncommitted_channel *uc,
const struct crypto_state *cs,
int peer_fd, int gossip_fd,
@ -120,8 +120,8 @@ static void uncommitted_channel_to_gossipd(struct lightningd *ld,
if (uc->fc)
command_fail(uc->fc->cmd, LIGHTNINGD, "%s", errstr);
/* Hand back to gossipd, (maybe) with an error packet to send. */
msg = towire_gossipctl_hand_back_peer(errstr, &uc->peer->id, cs,
/* Hand back to connectd, (maybe) with an error packet to send. */
msg = towire_connectctl_hand_back_peer(errstr, &uc->peer->id, cs,
errorpkt);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
@ -131,7 +131,7 @@ static void uncommitted_channel_to_gossipd(struct lightningd *ld,
static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
const char *desc)
{
u8 *msg = towire_gossipctl_peer_disconnected(tmpctx, &uc->peer->id);
u8 *msg = towire_connectctl_peer_disconnected(tmpctx, &uc->peer->id);
log_info(uc->log, "%s", desc);
subd_send_msg(uc->peer->ld->connectd, msg);
if (uc->fc)
@ -268,13 +268,13 @@ static void funding_broadcast_failed(struct channel *channel,
exitstatus, err);
}
void tell_gossipd_peer_is_important(struct lightningd *ld,
void tell_connectd_peer_is_important(struct lightningd *ld,
const struct channel *channel)
{
u8 *msg;
/* Tell gossipd we need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, true);
/* Tell connectd we need to keep connection to this peer */
msg = towire_connectctl_peer_important(NULL, &channel->peer->id, true);
subd_send_msg(ld->connectd, take(msg));
}
@ -429,7 +429,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
channel_watch_funding(ld, channel);
tell_gossipd_peer_is_important(ld, channel);
tell_connectd_peer_is_important(ld, channel);
/* Start normal channel daemon. */
peer_start_channeld(channel, &cs, fds[0], fds[1], NULL, false);
@ -533,7 +533,7 @@ static void opening_fundee_finished(struct subd *openingd,
channel_watch_funding(ld, channel);
tell_gossipd_peer_is_important(ld, channel);
tell_connectd_peer_is_important(ld, channel);
/* On to normal operation! */
peer_start_channeld(channel, &cs,
@ -557,7 +557,7 @@ static void opening_channel_errmsg(struct uncommitted_channel *uc,
/* An error occurred (presumably negotiation fail). */
const char *errsrc = err_for_them ? "sent" : "received";
uncommitted_channel_to_gossipd(uc->peer->ld, uc,
uncommitted_channel_to_connectd(uc->peer->ld, uc,
cs,
peer_fd, gossip_fd,
err_for_them,
@ -677,8 +677,8 @@ static void channel_config(struct lightningd *ld,
ours->channel_reserve_satoshis = 0;
};
/* Peer has spontaneously exited from gossip due to open msg. Return
* NULL if we took over, otherwise hand back to gossipd with this
/* Peer has spontaneously exited from connectd due to open msg. Return
* NULL if we took over, otherwise hand back to connectd with this
* error.
*/
u8 *peer_accept_channel(const tal_t *ctx,
@ -724,7 +724,7 @@ u8 *peer_accept_channel(const tal_t *ctx,
strerror(errno));
errpkt = towire_errorfmt(uc, channel_id, "%s", errmsg);
uncommitted_channel_to_gossipd(ld, uc,
uncommitted_channel_to_connectd(ld, uc,
cs,
peer_fd, gossip_fd,
errpkt, "%s", errmsg);
@ -808,7 +808,7 @@ static void peer_offer_channel(struct lightningd *ld,
if (!fc->uc->openingd) {
/* We don't send them an error packet: for them, nothing
* happened! */
uncommitted_channel_to_gossipd(ld, fc->uc, NULL,
uncommitted_channel_to_connectd(ld, fc->uc, NULL,
peer_fd, gossip_fd,
NULL,
"Failed to launch openingd: %s",
@ -842,13 +842,13 @@ static void peer_offer_channel(struct lightningd *ld,
take(msg), -1, 2, opening_funder_finished, fc);
}
/* Peer has been released from gossip. Start opening. */
static void gossip_peer_released(struct subd *gossip,
/* Peer has been released from connectd. Start opening. */
static void connectd_peer_released(struct subd *connectd,
const u8 *resp,
const int *fds,
struct funding_channel *fc)
{
struct lightningd *ld = gossip->ld;
struct lightningd *ld = connectd->ld;
struct crypto_state cs;
u8 *gfeatures, *lfeatures;
struct wireaddr_internal addr;
@ -861,11 +861,11 @@ static void gossip_peer_released(struct subd *gossip,
c = active_channel_by_id(ld, &fc->peerid, &uc);
if (!fromwire_gossipctl_release_peer_reply(fc, resp, &addr, &cs,
if (!fromwire_connectctl_release_peer_reply(fc, resp, &addr, &cs,
&gfeatures, &lfeatures)) {
if (!fromwire_gossipctl_release_peer_replyfail(resp)) {
fatal("Gossip daemon gave invalid reply %s",
tal_hex(gossip, resp));
if (!fromwire_connectctl_release_peer_replyfail(resp)) {
fatal("Connect daemon gave invalid reply %s",
tal_hex(connectd, resp));
}
if (uc)
command_fail(fc->cmd, LIGHTNINGD, "Peer already OPENING");
@ -878,7 +878,7 @@ static void gossip_peer_released(struct subd *gossip,
}
assert(tal_count(fds) == 2);
/* Gossipd should guarantee peer is unique: we would have killed any
/* Connectd should guarantee peer is unique: we would have killed any
* old connection when it was told us peer reconnected. */
assert(!c);
assert(!uc);
@ -889,7 +889,7 @@ static void gossip_peer_released(struct subd *gossip,
fds[0], fds[1]);
}
/* We can race: we're trying to get gossipd to release peer just as it
/* We can race: we're trying to get connectd to release peer just as it
* reconnects. If that's happened, treat it as if it were
* released. */
bool handle_opening_channel(struct lightningd *ld,
@ -956,8 +956,8 @@ static void json_fund_channel(struct command *cmd,
list_add(&cmd->ld->fundchannels, &fc->list);
tal_add_destructor(fc, remove_funding_channel_from_list);
msg = towire_gossipctl_release_peer(cmd, &fc->peerid);
subd_req(fc, cmd->ld->connectd, msg, -1, 2, gossip_peer_released, fc);
msg = towire_connectctl_release_peer(cmd, &fc->peerid);
subd_req(fc, cmd->ld->connectd, msg, -1, 2, connectd_peer_released, fc);
command_still_pending(cmd);
}

4
lightningd/opening_control.h

@ -40,6 +40,6 @@ bool handle_opening_channel(struct lightningd *ld,
void kill_uncommitted_channel(struct uncommitted_channel *uc,
const char *why);
void tell_gossipd_peer_is_important(struct lightningd *ld,
const struct channel *channel);
void tell_connectd_peer_is_important(struct lightningd *ld,
const struct channel *channel);
#endif /* LIGHTNING_LIGHTNINGD_OPENING_CONTROL_H */

60
lightningd/peer_control.c

@ -20,10 +20,9 @@
#include <common/status.h>
#include <common/timeout.h>
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gen_gossip_wire.h>
#include <gossipd/routing.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <lightningd/bitcoind.h>
@ -348,8 +347,8 @@ void drop_to_chain(struct lightningd *ld, struct channel *channel,
{
u8 *msg;
/* Tell gossipd we no longer need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, false);
/* Tell connectd we no longer need to keep connection to this peer */
msg = towire_connectctl_peer_important(NULL, &channel->peer->id, false);
subd_send_msg(ld->connectd, take(msg));
sign_last_tx(channel);
@ -386,7 +385,7 @@ void channel_errmsg(struct channel *channel,
err_for_them,
tal_len(err_for_them), 0);
/* Make sure channel_fail_permanent doesn't tell gossipd we died! */
/* Make sure channel_fail_permanent doesn't tell connectd we died! */
channel->connected = false;
/* BOLT #1:
@ -397,7 +396,7 @@ void channel_errmsg(struct channel *channel,
* - MUST fail all channels with the receiving node.
* - MUST close the connection.
*/
/* FIXME: Gossipd closes connection, but doesn't fail channels. */
/* FIXME: Connectd closes connection, but doesn't fail channels. */
/* BOLT #1:
*
@ -414,8 +413,8 @@ void channel_errmsg(struct channel *channel,
channel->owner->name,
err_for_them ? "sent" : "received", desc);
/* Hand back to connectdd, with any error packet. */
msg = towire_gossipctl_hand_back_peer(NULL, &channel->peer->id,
/* Hand back to connectd, with any error packet. */
msg = towire_connectctl_hand_back_peer(NULL, &channel->peer->id,
cs, err_for_them);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
@ -437,10 +436,10 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
struct wireaddr_internal addr;
struct uncommitted_channel *uc;
if (!fromwire_gossip_peer_connected(msg, msg,
if (!fromwire_connect_peer_connected(msg, msg,
&id, &addr, &cs,
&gfeatures, &lfeatures))
fatal("Gossip gave bad GOSSIP_PEER_CONNECTED message %s",
fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s",
tal_hex(msg, msg));
if (!features_supported(gfeatures, lfeatures)) {
@ -528,7 +527,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
send_error:
/* Hand back to channeld, with an error packet. */
msg = towire_gossipctl_hand_back_peer(msg, &id, &cs, error);
msg = towire_connectctl_hand_back_peer(msg, &id, &cs, error);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
@ -613,7 +612,7 @@ void peer_sent_nongossip(struct lightningd *ld,
send_error:
/* Hand back to channeld, with an error packet. */
msg = towire_gossipctl_hand_back_peer(ld, id, cs, error);
msg = towire_connectctl_hand_back_peer(ld, id, cs, error);
subd_send_msg(ld->connectd, take(msg));
subd_send_fd(ld->connectd, peer_fd);
subd_send_fd(ld->connectd, gossip_fd);
@ -730,7 +729,7 @@ static void json_add_node_decoration(struct json_result *response,
json_add_hex(response, "color", node->color, ARRAY_SIZE(node->color));
}
static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
static void connectd_getpeers_complete(struct subd *connectd, const u8 *msg,
const int *fds UNUSED,
struct getpeers_args *gpa)
{
@ -741,9 +740,9 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
struct json_result *response = new_json_result(gpa->cmd);
struct peer *p;
if (!fromwire_gossip_getpeers_reply(msg, msg, &ids, &addrs, &nodes)) {
if (!fromwire_connect_getpeers_reply(msg, msg, &ids, &addrs, &nodes)) {
command_fail(gpa->cmd, LIGHTNINGD,
"Bad response from gossipd");
"Bad response from connectd");
return;
}
@ -930,7 +929,7 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
addrs + i));
json_array_end(response);
json_add_bool(response, "connected", true);
json_add_string(response, "owner", gossip->name);
json_add_string(response, "owner", connectd->name);
json_object_end(response);
}
@ -953,8 +952,8 @@ static void json_listpeers(struct command *cmd,
/* 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);
take(towire_connect_getpeers_request(cmd, gpa->specific_id)),
-1, 0, connectd_getpeers_complete, gpa);
command_still_pending(cmd);
}
@ -1104,15 +1103,15 @@ static void activate_peer(struct peer *peer)
struct channel *channel;
struct lightningd *ld = peer->ld;
/* Pass channeld any addrhints we currently have */
msg = towire_gossipctl_peer_addrhint(peer, &peer->id, &peer->addr);
/* Pass connectd any addrhints we currently have */
msg = towire_connectctl_peer_addrhint(peer, &peer->id, &peer->addr);
subd_send_msg(peer->ld->connectd, take(msg));
/* We can only have one active channel: make sure connectd
* knows to reconnect. */
channel = peer_active_channel(peer);
if (channel)
tell_gossipd_peer_is_important(ld, channel);
tell_connectd_peer_is_important(ld, channel);
list_for_each(&peer->channels, channel, list) {
/* Watching lockin may be unnecessary, but it's harmless. */
@ -1129,15 +1128,16 @@ void activate_peers(struct lightningd *ld)
}
/* Peer has been released from connectd. */
static void gossip_peer_disconnected (struct subd *connectd,
const u8 *resp,
const int *fds,
struct command *cmd) {
static void connectd_peer_disconnected(struct subd *connectd,
const u8 *resp,
const int *fds,
struct command *cmd)
{
bool isconnected;
if (!fromwire_gossipctl_peer_disconnect_reply(resp)) {
if (!fromwire_gossipctl_peer_disconnect_replyfail(resp, &isconnected))
fatal("Gossip daemon gave invalid reply %s",
if (!fromwire_connectctl_peer_disconnect_reply(resp)) {
if (!fromwire_connectctl_peer_disconnect_replyfail(resp, &isconnected))
fatal("Connect daemon gave invalid reply %s",
tal_hex(tmpctx, resp));
if (isconnected)
command_fail(cmd, LIGHTNINGD,
@ -1162,8 +1162,8 @@ static void json_disconnect(struct command *cmd,
NULL))
return;
msg = towire_gossipctl_peer_disconnect(cmd, &id);
subd_req(cmd, cmd->ld->connectd, msg, -1, 0, gossip_peer_disconnected, cmd);
msg = towire_connectctl_peer_disconnect(cmd, &id);
subd_req(cmd, cmd->ld->connectd, msg, -1, 0, connectd_peer_disconnected, cmd);
command_still_pending(cmd);
}

68
wallet/test/run-wallet.c

@ -65,18 +65,18 @@ bool extract_channel_id(const u8 *in_pkt UNNEEDED, struct channel_id *channel_id
/* Generated stub for features_supported */
bool features_supported(const u8 *gfeatures UNNEEDED, const u8 *lfeatures UNNEEDED)
{ fprintf(stderr, "features_supported called!\n"); abort(); }
/* Generated stub for fromwire_gossipctl_peer_disconnect_reply */
bool fromwire_gossipctl_peer_disconnect_reply(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_gossipctl_peer_disconnect_reply called!\n"); abort(); }
/* Generated stub for fromwire_gossipctl_peer_disconnect_replyfail */
bool fromwire_gossipctl_peer_disconnect_replyfail(const void *p UNNEEDED, bool *isconnected UNNEEDED)
{ fprintf(stderr, "fromwire_gossipctl_peer_disconnect_replyfail called!\n"); abort(); }
/* Generated stub for fromwire_gossip_getpeers_reply */
bool fromwire_gossip_getpeers_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey **id UNNEEDED, struct wireaddr_internal **addr UNNEEDED, struct gossip_getnodes_entry ***nodes UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_getpeers_reply called!\n"); abort(); }
/* Generated stub for fromwire_gossip_peer_connected */
bool fromwire_gossip_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct crypto_state *crypto_state UNNEEDED, u8 **gfeatures UNNEEDED, u8 **lfeatures UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_peer_connected called!\n"); abort(); }
/* Generated stub for fromwire_connectctl_peer_disconnect_reply */
bool fromwire_connectctl_peer_disconnect_reply(const void *p UNNEEDED)
{ fprintf(stderr, "fromwire_connectctl_peer_disconnect_reply called!\n"); abort(); }
/* Generated stub for fromwire_connectctl_peer_disconnect_replyfail */
bool fromwire_connectctl_peer_disconnect_replyfail(const void *p UNNEEDED, bool *isconnected UNNEEDED)
{ fprintf(stderr, "fromwire_connectctl_peer_disconnect_replyfail called!\n"); abort(); }
/* Generated stub for fromwire_connect_getpeers_reply */
bool fromwire_connect_getpeers_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey **id UNNEEDED, struct wireaddr_internal **addr UNNEEDED, struct gossip_getnodes_entry ***nodes UNNEEDED)
{ fprintf(stderr, "fromwire_connect_getpeers_reply called!\n"); abort(); }
/* Generated stub for fromwire_connect_peer_connected */
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct crypto_state *crypto_state UNNEEDED, u8 **gfeatures UNNEEDED, u8 **lfeatures UNNEEDED)
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
@ -354,39 +354,39 @@ void subd_send_fd(struct subd *sd UNNEEDED, int fd UNNEEDED)
/* Generated stub for subd_send_msg */
void subd_send_msg(struct subd *sd UNNEEDED, const u8 *msg_out UNNEEDED)
{ fprintf(stderr, "subd_send_msg called!\n"); abort(); }
/* Generated stub for tell_gossipd_peer_is_important */
void tell_gossipd_peer_is_important(struct lightningd *ld UNNEEDED,
const struct channel *channel UNNEEDED)
{ fprintf(stderr, "tell_gossipd_peer_is_important called!\n"); abort(); }
/* Generated stub for tell_connectd_peer_is_important */
void tell_connectd_peer_is_important(struct lightningd *ld UNNEEDED,
const struct channel *channel UNNEEDED)
{ fprintf(stderr, "tell_connectd_peer_is_important called!\n"); abort(); }
/* Generated stub for towire_channel_dev_reenable_commit */
u8 *towire_channel_dev_reenable_commit(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_channel_dev_reenable_commit called!\n"); abort(); }
/* Generated stub for towire_channel_send_shutdown */
u8 *towire_channel_send_shutdown(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_channel_send_shutdown called!\n"); abort(); }
/* Generated stub for towire_connectctl_hand_back_peer */
u8 *towire_connectctl_hand_back_peer(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, const struct crypto_state *crypto_state UNNEEDED, const u8 *msg UNNEEDED)
{ fprintf(stderr, "towire_connectctl_hand_back_peer called!\n"); abort(); }
/* Generated stub for towire_connectctl_peer_addrhint */
u8 *towire_connectctl_peer_addrhint(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, const struct wireaddr_internal *addr UNNEEDED)
{ fprintf(stderr, "towire_connectctl_peer_addrhint called!\n"); abort(); }
/* Generated stub for towire_connectctl_peer_disconnect */
u8 *towire_connectctl_peer_disconnect(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_connectctl_peer_disconnect called!\n"); abort(); }
/* Generated stub for towire_connectctl_peer_disconnected */
u8 *towire_connectctl_peer_disconnected(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_connectctl_peer_disconnected called!\n"); abort(); }
/* Generated stub for towire_connectctl_peer_important */
u8 *towire_connectctl_peer_important(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, bool important UNNEEDED)
{ fprintf(stderr, "towire_connectctl_peer_important called!\n"); abort(); }
/* Generated stub for towire_connect_getpeers_request */
u8 *towire_connect_getpeers_request(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_connect_getpeers_request called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossipctl_hand_back_peer */
u8 *towire_gossipctl_hand_back_peer(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, const struct crypto_state *crypto_state UNNEEDED, const u8 *msg UNNEEDED)
{ fprintf(stderr, "towire_gossipctl_hand_back_peer called!\n"); abort(); }
/* Generated stub for towire_gossipctl_peer_addrhint */
u8 *towire_gossipctl_peer_addrhint(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, const struct wireaddr_internal *addr UNNEEDED)
{ fprintf(stderr, "towire_gossipctl_peer_addrhint called!\n"); abort(); }
/* Generated stub for towire_gossipctl_peer_disconnect */
u8 *towire_gossipctl_peer_disconnect(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_gossipctl_peer_disconnect called!\n"); abort(); }
/* Generated stub for towire_gossipctl_peer_disconnected */
u8 *towire_gossipctl_peer_disconnected(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_gossipctl_peer_disconnected called!\n"); abort(); }
/* Generated stub for towire_gossipctl_peer_important */
u8 *towire_gossipctl_peer_important(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED, bool important UNNEEDED)
{ fprintf(stderr, "towire_gossipctl_peer_important called!\n"); abort(); }
/* Generated stub for towire_gossip_getpeers_request */
u8 *towire_gossip_getpeers_request(const tal_t *ctx UNNEEDED, const struct pubkey *id UNNEEDED)
{ fprintf(stderr, "towire_gossip_getpeers_request called!\n"); abort(); }
/* Generated stub for towire_hsm_sign_commitment_tx */
u8 *towire_hsm_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct pubkey *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED, u64 funding_amount UNNEEDED)
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }

Loading…
Cancel
Save