mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
connectd: convert to new wire generation style.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fe8564555f
commit
398b4806b9
@ -7,13 +7,13 @@ connectd-wrongdir:
|
|||||||
default: connectd-all
|
default: connectd-all
|
||||||
|
|
||||||
# Control daemon uses this:
|
# Control daemon uses this:
|
||||||
LIGHTNINGD_CONNECT_CONTROL_HEADERS := connectd/gen_connect_wire.h connectd/gen_connect_gossip_wire.h
|
LIGHTNINGD_CONNECT_CONTROL_HEADERS := connectd/connectd_wiregen.h connectd/connectd_gossipd_wiregen.h
|
||||||
LIGHTNINGD_CONNECT_CONTROL_SRC := connectd/gen_connect_wire.c connectd/gen_connect_gossip_wire.c
|
LIGHTNINGD_CONNECT_CONTROL_SRC := connectd/connectd_wiregen.c connectd/connectd_gossipd_wiregen.c
|
||||||
LIGHTNINGD_CONNECT_CONTROL_OBJS := $(LIGHTNINGD_CONNECT_CONTROL_SRC:.c=.o)
|
LIGHTNINGD_CONNECT_CONTROL_OBJS := $(LIGHTNINGD_CONNECT_CONTROL_SRC:.c=.o)
|
||||||
|
|
||||||
# connectd needs these:
|
# connectd needs these:
|
||||||
LIGHTNINGD_CONNECT_HEADERS := connectd/gen_connect_wire.h \
|
LIGHTNINGD_CONNECT_HEADERS := connectd/connectd_wiregen.h \
|
||||||
connectd/gen_connect_gossip_wire.h \
|
connectd/connectd_gossipd_wiregen.h \
|
||||||
connectd/connectd.h \
|
connectd/connectd.h \
|
||||||
connectd/peer_exchange_initmsg.h \
|
connectd/peer_exchange_initmsg.h \
|
||||||
connectd/handshake.h \
|
connectd/handshake.h \
|
||||||
@ -26,11 +26,11 @@ LIGHTNINGD_CONNECT_OBJS := $(LIGHTNINGD_CONNECT_SRC:.c=.o)
|
|||||||
# Make sure these depend on everything.
|
# Make sure these depend on everything.
|
||||||
ALL_OBJS += $(LIGHTNINGD_CONNECT_OBJS)
|
ALL_OBJS += $(LIGHTNINGD_CONNECT_OBJS)
|
||||||
ALL_PROGRAMS += lightningd/lightning_connectd
|
ALL_PROGRAMS += lightningd/lightning_connectd
|
||||||
ALL_GEN_HEADERS += connectd/gen_connect_wire.h connectd/gen_connect_gossip_wire.h
|
ALL_GEN_HEADERS += connectd/connectd_wiregen.h connectd/connectd_gossipd_wiregen.h
|
||||||
|
|
||||||
# For checking
|
# For checking
|
||||||
LIGHTNINGD_CONNECT_ALLSRC_NOGEN := $(filter-out connectd/gen_%, $(LIGHTNINGD_CONNECT_CLIENT_SRC) $(LIGHTNINGD_CONNECT_SRC))
|
LIGHTNINGD_CONNECT_ALLSRC_NOGEN := $(filter-out connectd/%wiregen.c, $(LIGHTNINGD_CONNECT_CLIENT_SRC) $(LIGHTNINGD_CONNECT_SRC))
|
||||||
LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN := $(filter-out connectd/gen_%, $(LIGHTNINGD_CONNECT_CLIENT_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS))
|
LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN := $(filter-out connectd/%wiregen.h, $(LIGHTNINGD_CONNECT_CLIENT_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS))
|
||||||
|
|
||||||
# Add to headers which any object might need.
|
# Add to headers which any object might need.
|
||||||
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CONNECT_HEADERS)
|
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CONNECT_HEADERS)
|
||||||
@ -85,18 +85,6 @@ connectd-all: lightningd/lightning_connectd
|
|||||||
|
|
||||||
lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
|
lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
|
||||||
|
|
||||||
connectd/gen_connect_wire.h: $(WIRE_GEN) connectd/connect_wire.csv
|
|
||||||
$(WIRE_GEN) --page header $@ connect_wire_type < connectd/connect_wire.csv > $@
|
|
||||||
|
|
||||||
connectd/gen_connect_wire.c: $(WIRE_GEN) connectd/connect_wire.csv
|
|
||||||
$(WIRE_GEN) --page impl ${@:.c=.h} connect_wire_type < connectd/connect_wire.csv > $@
|
|
||||||
|
|
||||||
connectd/gen_connect_gossip_wire.h: $(WIRE_GEN) connectd/connect_gossip_wire.csv
|
|
||||||
$(WIRE_GEN) --page header $@ connect_gossip_wire_type < connectd/connect_gossip_wire.csv > $@
|
|
||||||
|
|
||||||
connectd/gen_connect_gossip_wire.c: $(WIRE_GEN) connectd/connect_gossip_wire.csv
|
|
||||||
$(WIRE_GEN) --page impl ${@:.c=.h} connect_gossip_wire_type < connectd/connect_gossip_wire.csv > $@
|
|
||||||
|
|
||||||
check-source: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
|
check-source: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||||
check-source-bolt: $(LIGHTNINGD_CONNECT_SRC:%=bolt-check/%) $(LIGHTNINGD_CONNECT_HEADERS:%=bolt-check/%)
|
check-source-bolt: $(LIGHTNINGD_CONNECT_SRC:%=bolt-check/%) $(LIGHTNINGD_CONNECT_HEADERS:%=bolt-check/%)
|
||||||
check-whitespace: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-whitespace/%)
|
check-whitespace: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-whitespace/%)
|
||||||
@ -104,6 +92,6 @@ check-whitespace: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGH
|
|||||||
clean: connectd-clean
|
clean: connectd-clean
|
||||||
|
|
||||||
connectd-clean:
|
connectd-clean:
|
||||||
$(RM) $(LIGHTNINGD_CONNECT_OBJS) connectd/gen_*
|
$(RM) $(LIGHTNINGD_CONNECT_OBJS)
|
||||||
|
|
||||||
-include connectd/test/Makefile
|
-include connectd/test/Makefile
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#include <common/node_id.h>
|
|
||||||
#include <common/per_peer_state.h>
|
|
||||||
#include <common/wireaddr.h>
|
|
||||||
|
|
||||||
# Communication between gossipd and connectd.
|
|
||||||
msgtype,gossip_new_peer,4000
|
|
||||||
msgdata,gossip_new_peer,id,node_id,
|
|
||||||
# Did we negotiate LOCAL_GOSSIP_QUERIES?
|
|
||||||
msgdata,gossip_new_peer,gossip_queries_feature,bool,
|
|
||||||
# Did they offer LOCAL_INITIAL_ROUTING_SYNC?
|
|
||||||
msgdata,gossip_new_peer,initial_routing_sync,bool,
|
|
||||||
|
|
||||||
# if success: + gossip fd and gossip_store fd
|
|
||||||
msgtype,gossip_new_peer_reply,4100
|
|
||||||
msgdata,gossip_new_peer_reply,success,bool,
|
|
||||||
msgdata,gossip_new_peer_reply,gs,?gossip_state,
|
|
||||||
|
|
||||||
# Connectd asks gossipd for any known addresses for that node.
|
|
||||||
msgtype,gossip_get_addrs,4001
|
|
||||||
msgdata,gossip_get_addrs,id,node_id,
|
|
||||||
|
|
||||||
msgtype,gossip_get_addrs_reply,4101
|
|
||||||
msgdata,gossip_get_addrs_reply,num,u16,
|
|
||||||
msgdata,gossip_get_addrs_reply,addrs,wireaddr,num
|
|
|
@ -1,70 +0,0 @@
|
|||||||
#include <common/cryptomsg.h>
|
|
||||||
#include <common/features.h>
|
|
||||||
#include <common/per_peer_state.h>
|
|
||||||
#include <common/wireaddr.h>
|
|
||||||
#include <lightningd/gossip_msg.h>
|
|
||||||
|
|
||||||
msgtype,connectctl_init,2000
|
|
||||||
msgdata,connectctl_init,chainparams,chainparams,
|
|
||||||
msgdata,connectctl_init,our_features,feature_set,
|
|
||||||
msgdata,connectctl_init,id,node_id,
|
|
||||||
msgdata,connectctl_init,num_wireaddrs,u16,
|
|
||||||
msgdata,connectctl_init,wireaddrs,wireaddr_internal,num_wireaddrs
|
|
||||||
msgdata,connectctl_init,listen_announce,enum addr_listen_announce,num_wireaddrs
|
|
||||||
msgdata,connectctl_init,tor_proxyaddr,?wireaddr,
|
|
||||||
msgdata,connectctl_init,use_tor_proxy_always,bool,
|
|
||||||
msgdata,connectctl_init,dev_allow_localhost,bool,
|
|
||||||
msgdata,connectctl_init,use_dns,bool,
|
|
||||||
msgdata,connectctl_init,tor_password,wirestring,
|
|
||||||
msgdata,connectctl_init,use_v3_autotor,bool,
|
|
||||||
|
|
||||||
# Connectd->master, here are the addresses I bound, can announce.
|
|
||||||
msgtype,connectctl_init_reply,2100
|
|
||||||
msgdata,connectctl_init_reply,num_bindings,u16,
|
|
||||||
msgdata,connectctl_init_reply,bindings,wireaddr_internal,num_bindings
|
|
||||||
msgdata,connectctl_init_reply,num_announcable,u16,
|
|
||||||
msgdata,connectctl_init_reply,announcable,wireaddr,num_announcable
|
|
||||||
|
|
||||||
# Activate the connect daemon, so others can connect.
|
|
||||||
msgtype,connectctl_activate,2025
|
|
||||||
# Do we listen?
|
|
||||||
msgdata,connectctl_activate,listen,bool,
|
|
||||||
|
|
||||||
# Connectd->master, I am ready.
|
|
||||||
msgtype,connectctl_activate_reply,2125
|
|
||||||
|
|
||||||
# connectd->master: disconnect this peer please (due to reconnect).
|
|
||||||
msgtype,connect_reconnected,2112
|
|
||||||
msgdata,connect_reconnected,id,node_id,
|
|
||||||
|
|
||||||
# Master -> connectd: connect to a peer.
|
|
||||||
msgtype,connectctl_connect_to_peer,2001
|
|
||||||
msgdata,connectctl_connect_to_peer,id,node_id,
|
|
||||||
msgdata,connectctl_connect_to_peer,seconds_waited,u32,
|
|
||||||
msgdata,connectctl_connect_to_peer,addrhint,?wireaddr_internal,
|
|
||||||
|
|
||||||
# Connectd->master: connect failed.
|
|
||||||
msgtype,connectctl_connect_failed,2020
|
|
||||||
msgdata,connectctl_connect_failed,id,node_id,
|
|
||||||
msgdata,connectctl_connect_failed,failcode,errcode_t,
|
|
||||||
msgdata,connectctl_connect_failed,failreason,wirestring,
|
|
||||||
msgdata,connectctl_connect_failed,seconds_to_delay,u32,
|
|
||||||
msgdata,connectctl_connect_failed,addrhint,?wireaddr_internal,
|
|
||||||
|
|
||||||
# Connectd -> master: we got a peer. Three fds: peer, gossip and gossip_store
|
|
||||||
msgtype,connect_peer_connected,2002
|
|
||||||
msgdata,connect_peer_connected,id,node_id,
|
|
||||||
msgdata,connect_peer_connected,addr,wireaddr_internal,
|
|
||||||
msgdata,connect_peer_connected,pps,per_peer_state,
|
|
||||||
msgdata,connect_peer_connected,flen,u16,
|
|
||||||
msgdata,connect_peer_connected,features,u8,flen
|
|
||||||
|
|
||||||
# master -> connectd: peer has disconnected.
|
|
||||||
msgtype,connectctl_peer_disconnected,2015
|
|
||||||
msgdata,connectctl_peer_disconnected,id,node_id,
|
|
||||||
|
|
||||||
# master -> connectd: do you have a memleak?
|
|
||||||
msgtype,connect_dev_memleak,2033
|
|
||||||
|
|
||||||
msgtype,connect_dev_memleak_reply,2133
|
|
||||||
msgdata,connect_dev_memleak_reply,leak,bool,
|
|
|
@ -44,8 +44,8 @@
|
|||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
#include <connectd/connectd.h>
|
#include <connectd/connectd.h>
|
||||||
#include <connectd/gen_connect_gossip_wire.h>
|
#include <connectd/connectd_gossipd_wiregen.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <connectd/handshake.h>
|
#include <connectd/handshake.h>
|
||||||
#include <connectd/netaddress.h>
|
#include <connectd/netaddress.h>
|
||||||
#include <connectd/peer_exchange_initmsg.h>
|
#include <connectd/peer_exchange_initmsg.h>
|
||||||
@ -315,7 +315,7 @@ static bool get_gossipfds(struct daemon *daemon,
|
|||||||
|
|
||||||
/*~ We do this communication sync, since gossipd is our friend and
|
/*~ We do this communication sync, since gossipd is our friend and
|
||||||
* it's easier. If gossipd fails, we fail. */
|
* it's easier. If gossipd fails, we fail. */
|
||||||
msg = towire_gossip_new_peer(NULL, id, gossip_queries_feature,
|
msg = towire_gossipd_new_peer(NULL, id, gossip_queries_feature,
|
||||||
initial_routing_sync);
|
initial_routing_sync);
|
||||||
if (!wire_sync_write(GOSSIPCTL_FD, take(msg)))
|
if (!wire_sync_write(GOSSIPCTL_FD, take(msg)))
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
@ -323,7 +323,7 @@ static bool get_gossipfds(struct daemon *daemon,
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, GOSSIPCTL_FD);
|
msg = wire_sync_read(tmpctx, GOSSIPCTL_FD);
|
||||||
if (!fromwire_gossip_new_peer_reply(pps, msg, &success, &pps->gs))
|
if (!fromwire_gossipd_new_peer_reply(pps, msg, &success, &pps->gs))
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
"Failed parsing msg gossipctl: %s",
|
"Failed parsing msg gossipctl: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
@ -387,7 +387,7 @@ static struct io_plan *peer_reconnected(struct io_conn *conn,
|
|||||||
status_peer_debug(id, "reconnect");
|
status_peer_debug(id, "reconnect");
|
||||||
|
|
||||||
/* Tell master to kill it: will send peer_disconnect */
|
/* Tell master to kill it: will send peer_disconnect */
|
||||||
msg = towire_connect_reconnected(NULL, id);
|
msg = towire_connectd_reconnected(NULL, id);
|
||||||
daemon_conn_send(daemon->master, take(msg));
|
daemon_conn_send(daemon->master, take(msg));
|
||||||
|
|
||||||
/* Save arguments for next time. */
|
/* Save arguments for next time. */
|
||||||
@ -471,7 +471,7 @@ struct io_plan *peer_connected(struct io_conn *conn,
|
|||||||
return io_close(conn);
|
return io_close(conn);
|
||||||
|
|
||||||
/* Create message to tell master peer has connected. */
|
/* Create message to tell master peer has connected. */
|
||||||
msg = towire_connect_peer_connected(NULL, id, addr, pps, their_features);
|
msg = towire_connectd_peer_connected(NULL, id, addr, pps, their_features);
|
||||||
|
|
||||||
/*~ daemon_conn is a message queue for inter-daemon communication: we
|
/*~ daemon_conn is a message queue for inter-daemon communication: we
|
||||||
* queue up the `connect_peer_connected` message to tell lightningd
|
* queue up the `connect_peer_connected` message to tell lightningd
|
||||||
@ -635,7 +635,7 @@ static void connect_failed(struct daemon *daemon,
|
|||||||
* happened. We leave it to lightningd to decide if it wants to try
|
* happened. We leave it to lightningd to decide if it wants to try
|
||||||
* again, with the wait_seconds as a hint of how long before
|
* again, with the wait_seconds as a hint of how long before
|
||||||
* asking. */
|
* asking. */
|
||||||
msg = towire_connectctl_connect_failed(NULL, id, errcode, errmsg,
|
msg = towire_connectd_connect_failed(NULL, id, errcode, errmsg,
|
||||||
wait_seconds, addrhint);
|
wait_seconds, addrhint);
|
||||||
daemon_conn_send(daemon->master, take(msg));
|
daemon_conn_send(daemon->master, take(msg));
|
||||||
|
|
||||||
@ -1234,7 +1234,7 @@ static struct io_plan *connect_init(struct io_conn *conn,
|
|||||||
char *tor_password;
|
char *tor_password;
|
||||||
|
|
||||||
/* Fields which require allocation are allocated off daemon */
|
/* Fields which require allocation are allocated off daemon */
|
||||||
if (!fromwire_connectctl_init(
|
if (!fromwire_connectd_init(
|
||||||
daemon, msg,
|
daemon, msg,
|
||||||
&chainparams,
|
&chainparams,
|
||||||
&daemon->our_features,
|
&daemon->our_features,
|
||||||
@ -1247,7 +1247,7 @@ static struct io_plan *connect_init(struct io_conn *conn,
|
|||||||
&daemon->use_v3_autotor)) {
|
&daemon->use_v3_autotor)) {
|
||||||
/* This is a helper which prints the type expected and the actual
|
/* This is a helper which prints the type expected and the actual
|
||||||
* message, then exits (it should never be called!). */
|
* message, then exits (it should never be called!). */
|
||||||
master_badmsg(WIRE_CONNECTCTL_INIT, msg);
|
master_badmsg(WIRE_CONNECTD_INIT, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pubkey_from_node_id(&daemon->mykey, &daemon->id))
|
if (!pubkey_from_node_id(&daemon->mykey, &daemon->id))
|
||||||
@ -1285,7 +1285,7 @@ static struct io_plan *connect_init(struct io_conn *conn,
|
|||||||
|
|
||||||
/* Tell it we're ready, handing it the addresses we have. */
|
/* Tell it we're ready, handing it the addresses we have. */
|
||||||
daemon_conn_send(daemon->master,
|
daemon_conn_send(daemon->master,
|
||||||
take(towire_connectctl_init_reply(NULL,
|
take(towire_connectd_init_reply(NULL,
|
||||||
binding,
|
binding,
|
||||||
announcable)));
|
announcable)));
|
||||||
|
|
||||||
@ -1300,8 +1300,8 @@ static struct io_plan *connect_activate(struct io_conn *conn,
|
|||||||
{
|
{
|
||||||
bool do_listen;
|
bool do_listen;
|
||||||
|
|
||||||
if (!fromwire_connectctl_activate(msg, &do_listen))
|
if (!fromwire_connectd_activate(msg, &do_listen))
|
||||||
master_badmsg(WIRE_CONNECTCTL_ACTIVATE, msg);
|
master_badmsg(WIRE_CONNECTD_ACTIVATE, msg);
|
||||||
|
|
||||||
/* If we're --offline, lightningd tells us not to actually listen. */
|
/* If we're --offline, lightningd tells us not to actually listen. */
|
||||||
if (do_listen) {
|
if (do_listen) {
|
||||||
@ -1325,7 +1325,7 @@ static struct io_plan *connect_activate(struct io_conn *conn,
|
|||||||
|
|
||||||
/* OK, we're ready! */
|
/* OK, we're ready! */
|
||||||
daemon_conn_send(daemon->master,
|
daemon_conn_send(daemon->master,
|
||||||
take(towire_connectctl_activate_reply(NULL)));
|
take(towire_connectd_activate_reply(NULL)));
|
||||||
return daemon_conn_read_next(conn, daemon->master);
|
return daemon_conn_read_next(conn, daemon->master);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1395,7 +1395,7 @@ static void add_gossip_addrs(struct wireaddr_internal **addrs,
|
|||||||
struct wireaddr *normal_addrs;
|
struct wireaddr *normal_addrs;
|
||||||
|
|
||||||
/* For simplicity, we do this synchronous. */
|
/* For simplicity, we do this synchronous. */
|
||||||
msg = towire_gossip_get_addrs(NULL, id);
|
msg = towire_gossipd_get_addrs(NULL, id);
|
||||||
if (!wire_sync_write(GOSSIPCTL_FD, take(msg)))
|
if (!wire_sync_write(GOSSIPCTL_FD, take(msg)))
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
"Failed writing to gossipctl: %s",
|
"Failed writing to gossipctl: %s",
|
||||||
@ -1404,7 +1404,7 @@ static void add_gossip_addrs(struct wireaddr_internal **addrs,
|
|||||||
/* This returns 'struct wireaddr's since that's what's supported by
|
/* This returns 'struct wireaddr's since that's what's supported by
|
||||||
* the BOLT #7 protocol. */
|
* the BOLT #7 protocol. */
|
||||||
msg = wire_sync_read(tmpctx, GOSSIPCTL_FD);
|
msg = wire_sync_read(tmpctx, GOSSIPCTL_FD);
|
||||||
if (!fromwire_gossip_get_addrs_reply(tmpctx, msg, &normal_addrs))
|
if (!fromwire_gossipd_get_addrs_reply(tmpctx, msg, &normal_addrs))
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
"Failed parsing get_addrs_reply gossipctl: %s",
|
"Failed parsing get_addrs_reply gossipctl: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
@ -1505,10 +1505,10 @@ static struct io_plan *connect_to_peer(struct io_conn *conn,
|
|||||||
u32 seconds_waited;
|
u32 seconds_waited;
|
||||||
struct wireaddr_internal *addrhint;
|
struct wireaddr_internal *addrhint;
|
||||||
|
|
||||||
if (!fromwire_connectctl_connect_to_peer(tmpctx, msg,
|
if (!fromwire_connectd_connect_to_peer(tmpctx, msg,
|
||||||
&id, &seconds_waited,
|
&id, &seconds_waited,
|
||||||
&addrhint))
|
&addrhint))
|
||||||
master_badmsg(WIRE_CONNECTCTL_CONNECT_TO_PEER, msg);
|
master_badmsg(WIRE_CONNECTD_CONNECT_TO_PEER, msg);
|
||||||
|
|
||||||
try_connect_peer(daemon, &id, seconds_waited, addrhint);
|
try_connect_peer(daemon, &id, seconds_waited, addrhint);
|
||||||
return daemon_conn_read_next(conn, daemon->master);
|
return daemon_conn_read_next(conn, daemon->master);
|
||||||
@ -1520,8 +1520,8 @@ static struct io_plan *peer_disconnected(struct io_conn *conn,
|
|||||||
{
|
{
|
||||||
struct node_id id, *node;
|
struct node_id id, *node;
|
||||||
|
|
||||||
if (!fromwire_connectctl_peer_disconnected(msg, &id))
|
if (!fromwire_connectd_peer_disconnected(msg, &id))
|
||||||
master_badmsg(WIRE_CONNECTCTL_PEER_DISCONNECTED, msg);
|
master_badmsg(WIRE_CONNECTD_PEER_DISCONNECTED, msg);
|
||||||
|
|
||||||
/* We should stay in sync with lightningd at all times. */
|
/* We should stay in sync with lightningd at all times. */
|
||||||
node = node_set_get(&daemon->peers, &id);
|
node = node_set_get(&daemon->peers, &id);
|
||||||
@ -1557,7 +1557,7 @@ static struct io_plan *dev_connect_memleak(struct io_conn *conn,
|
|||||||
|
|
||||||
found_leak = dump_memleak(memtable);
|
found_leak = dump_memleak(memtable);
|
||||||
daemon_conn_send(daemon->master,
|
daemon_conn_send(daemon->master,
|
||||||
take(towire_connect_dev_memleak_reply(NULL,
|
take(towire_connectd_dev_memleak_reply(NULL,
|
||||||
found_leak)));
|
found_leak)));
|
||||||
return daemon_conn_read_next(conn, daemon->master);
|
return daemon_conn_read_next(conn, daemon->master);
|
||||||
}
|
}
|
||||||
@ -1567,34 +1567,34 @@ static struct io_plan *recv_req(struct io_conn *conn,
|
|||||||
const u8 *msg,
|
const u8 *msg,
|
||||||
struct daemon *daemon)
|
struct daemon *daemon)
|
||||||
{
|
{
|
||||||
enum connect_wire_type t = fromwire_peektype(msg);
|
enum connectd_wire t = fromwire_peektype(msg);
|
||||||
|
|
||||||
/* Demux requests from lightningd: we expect INIT then ACTIVATE, then
|
/* Demux requests from lightningd: we expect INIT then ACTIVATE, then
|
||||||
* connect requests and disconnected messages. */
|
* connect requests and disconnected messages. */
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case WIRE_CONNECTCTL_INIT:
|
case WIRE_CONNECTD_INIT:
|
||||||
return connect_init(conn, daemon, msg);
|
return connect_init(conn, daemon, msg);
|
||||||
|
|
||||||
case WIRE_CONNECTCTL_ACTIVATE:
|
case WIRE_CONNECTD_ACTIVATE:
|
||||||
return connect_activate(conn, daemon, msg);
|
return connect_activate(conn, daemon, msg);
|
||||||
|
|
||||||
case WIRE_CONNECTCTL_CONNECT_TO_PEER:
|
case WIRE_CONNECTD_CONNECT_TO_PEER:
|
||||||
return connect_to_peer(conn, daemon, msg);
|
return connect_to_peer(conn, daemon, msg);
|
||||||
|
|
||||||
case WIRE_CONNECTCTL_PEER_DISCONNECTED:
|
case WIRE_CONNECTD_PEER_DISCONNECTED:
|
||||||
return peer_disconnected(conn, daemon, msg);
|
return peer_disconnected(conn, daemon, msg);
|
||||||
|
|
||||||
case WIRE_CONNECT_DEV_MEMLEAK:
|
case WIRE_CONNECTD_DEV_MEMLEAK:
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
return dev_connect_memleak(conn, daemon, msg);
|
return dev_connect_memleak(conn, daemon, msg);
|
||||||
#endif
|
#endif
|
||||||
/* We send these, we don't receive them */
|
/* We send these, we don't receive them */
|
||||||
case WIRE_CONNECTCTL_INIT_REPLY:
|
case WIRE_CONNECTD_INIT_REPLY:
|
||||||
case WIRE_CONNECTCTL_ACTIVATE_REPLY:
|
case WIRE_CONNECTD_ACTIVATE_REPLY:
|
||||||
case WIRE_CONNECT_PEER_CONNECTED:
|
case WIRE_CONNECTD_PEER_CONNECTED:
|
||||||
case WIRE_CONNECT_RECONNECTED:
|
case WIRE_CONNECTD_RECONNECTED:
|
||||||
case WIRE_CONNECTCTL_CONNECT_FAILED:
|
case WIRE_CONNECTD_CONNECT_FAILED:
|
||||||
case WIRE_CONNECT_DEV_MEMLEAK_REPLY:
|
case WIRE_CONNECTD_DEV_MEMLEAK_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
connectd/connectd_gossipd_wire.csv
Normal file
24
connectd/connectd_gossipd_wire.csv
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <common/node_id.h>
|
||||||
|
#include <common/per_peer_state.h>
|
||||||
|
#include <common/wireaddr.h>
|
||||||
|
|
||||||
|
# Communication between gossipd and connectd.
|
||||||
|
msgtype,gossipd_new_peer,4000
|
||||||
|
msgdata,gossipd_new_peer,id,node_id,
|
||||||
|
# Did we negotiate LOCAL_GOSSIP_QUERIES?
|
||||||
|
msgdata,gossipd_new_peer,gossip_queries_feature,bool,
|
||||||
|
# Did they offer LOCAL_INITIAL_ROUTING_SYNC?
|
||||||
|
msgdata,gossipd_new_peer,initial_routing_sync,bool,
|
||||||
|
|
||||||
|
# if success: + gossip fd and gossip_store fd
|
||||||
|
msgtype,gossipd_new_peer_reply,4100
|
||||||
|
msgdata,gossipd_new_peer_reply,success,bool,
|
||||||
|
msgdata,gossipd_new_peer_reply,gs,?gossip_state,
|
||||||
|
|
||||||
|
# Connectd asks gossipd for any known addresses for that node.
|
||||||
|
msgtype,gossipd_get_addrs,4001
|
||||||
|
msgdata,gossipd_get_addrs,id,node_id,
|
||||||
|
|
||||||
|
msgtype,gossipd_get_addrs_reply,4101
|
||||||
|
msgdata,gossipd_get_addrs_reply,num,u16,
|
||||||
|
msgdata,gossipd_get_addrs_reply,addrs,wireaddr,num
|
|
70
connectd/connectd_wire.csv
Normal file
70
connectd/connectd_wire.csv
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include <common/cryptomsg.h>
|
||||||
|
#include <common/features.h>
|
||||||
|
#include <common/per_peer_state.h>
|
||||||
|
#include <common/wireaddr.h>
|
||||||
|
#include <lightningd/gossip_msg.h>
|
||||||
|
|
||||||
|
msgtype,connectd_init,2000
|
||||||
|
msgdata,connectd_init,chainparams,chainparams,
|
||||||
|
msgdata,connectd_init,our_features,feature_set,
|
||||||
|
msgdata,connectd_init,id,node_id,
|
||||||
|
msgdata,connectd_init,num_wireaddrs,u16,
|
||||||
|
msgdata,connectd_init,wireaddrs,wireaddr_internal,num_wireaddrs
|
||||||
|
msgdata,connectd_init,listen_announce,enum addr_listen_announce,num_wireaddrs
|
||||||
|
msgdata,connectd_init,tor_proxyaddr,?wireaddr,
|
||||||
|
msgdata,connectd_init,use_tor_proxy_always,bool,
|
||||||
|
msgdata,connectd_init,dev_allow_localhost,bool,
|
||||||
|
msgdata,connectd_init,use_dns,bool,
|
||||||
|
msgdata,connectd_init,tor_password,wirestring,
|
||||||
|
msgdata,connectd_init,use_v3_autotor,bool,
|
||||||
|
|
||||||
|
# Connectd->master, here are the addresses I bound, can announce.
|
||||||
|
msgtype,connectd_init_reply,2100
|
||||||
|
msgdata,connectd_init_reply,num_bindings,u16,
|
||||||
|
msgdata,connectd_init_reply,bindings,wireaddr_internal,num_bindings
|
||||||
|
msgdata,connectd_init_reply,num_announcable,u16,
|
||||||
|
msgdata,connectd_init_reply,announcable,wireaddr,num_announcable
|
||||||
|
|
||||||
|
# Activate the connect daemon, so others can connect.
|
||||||
|
msgtype,connectd_activate,2025
|
||||||
|
# Do we listen?
|
||||||
|
msgdata,connectd_activate,listen,bool,
|
||||||
|
|
||||||
|
# Connectd->master, I am ready.
|
||||||
|
msgtype,connectd_activate_reply,2125
|
||||||
|
|
||||||
|
# connectd->master: disconnect this peer please (due to reconnect).
|
||||||
|
msgtype,connectd_reconnected,2112
|
||||||
|
msgdata,connectd_reconnected,id,node_id,
|
||||||
|
|
||||||
|
# Master -> connectd: connect to a peer.
|
||||||
|
msgtype,connectd_connect_to_peer,2001
|
||||||
|
msgdata,connectd_connect_to_peer,id,node_id,
|
||||||
|
msgdata,connectd_connect_to_peer,seconds_waited,u32,
|
||||||
|
msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal,
|
||||||
|
|
||||||
|
# Connectd->master: connect failed.
|
||||||
|
msgtype,connectd_connect_failed,2020
|
||||||
|
msgdata,connectd_connect_failed,id,node_id,
|
||||||
|
msgdata,connectd_connect_failed,failcode,errcode_t,
|
||||||
|
msgdata,connectd_connect_failed,failreason,wirestring,
|
||||||
|
msgdata,connectd_connect_failed,seconds_to_delay,u32,
|
||||||
|
msgdata,connectd_connect_failed,addrhint,?wireaddr_internal,
|
||||||
|
|
||||||
|
# Connectd -> master: we got a peer. Three fds: peer, gossip and gossip_store
|
||||||
|
msgtype,connectd_peer_connected,2002
|
||||||
|
msgdata,connectd_peer_connected,id,node_id,
|
||||||
|
msgdata,connectd_peer_connected,addr,wireaddr_internal,
|
||||||
|
msgdata,connectd_peer_connected,pps,per_peer_state,
|
||||||
|
msgdata,connectd_peer_connected,flen,u16,
|
||||||
|
msgdata,connectd_peer_connected,features,u8,flen
|
||||||
|
|
||||||
|
# master -> connectd: peer has disconnected.
|
||||||
|
msgtype,connectd_peer_disconnected,2015
|
||||||
|
msgdata,connectd_peer_disconnected,id,node_id,
|
||||||
|
|
||||||
|
# master -> connectd: do you have a memleak?
|
||||||
|
msgtype,connectd_dev_memleak,2033
|
||||||
|
|
||||||
|
msgtype,connectd_dev_memleak_reply,2133
|
||||||
|
msgdata,connectd_dev_memleak_reply,leak,bool,
|
|
@ -7,7 +7,7 @@
|
|||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/connectd.h>
|
#include <connectd/connectd.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <connectd/peer_exchange_initmsg.h>
|
#include <connectd/peer_exchange_initmsg.h>
|
||||||
#include <wire/peer_wire.h>
|
#include <wire/peer_wire.h>
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ GOSSIPD_COMMON_OBJS := \
|
|||||||
common/version.o \
|
common/version.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
connectd/gen_connect_gossip_wire.o \
|
connectd/connectd_gossipd_wiregen.o \
|
||||||
lightningd/gossip_msg.o \
|
lightningd/gossip_msg.o \
|
||||||
wire/gen_onion_wire.o
|
wire/gen_onion_wire.o
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
#include <connectd/gen_connect_gossip_wire.h>
|
#include <connectd/connectd_gossipd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <gossipd/broadcast.h>
|
#include <gossipd/broadcast.h>
|
||||||
@ -551,7 +551,7 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
|
|||||||
int gossip_store_fd;
|
int gossip_store_fd;
|
||||||
struct gossip_state *gs;
|
struct gossip_state *gs;
|
||||||
|
|
||||||
if (!fromwire_gossip_new_peer(msg, &peer->id,
|
if (!fromwire_gossipd_new_peer(msg, &peer->id,
|
||||||
&peer->gossip_queries_feature,
|
&peer->gossip_queries_feature,
|
||||||
&peer->initial_routing_sync_feature)) {
|
&peer->initial_routing_sync_feature)) {
|
||||||
status_broken("Bad new_peer msg from connectd: %s",
|
status_broken("Bad new_peer msg from connectd: %s",
|
||||||
@ -564,7 +564,7 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
|
|||||||
status_broken("Failed to get readonly store fd: %s",
|
status_broken("Failed to get readonly store fd: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
daemon_conn_send(daemon->connectd,
|
daemon_conn_send(daemon->connectd,
|
||||||
take(towire_gossip_new_peer_reply(NULL,
|
take(towire_gossipd_new_peer_reply(NULL,
|
||||||
false,
|
false,
|
||||||
NULL)));
|
NULL)));
|
||||||
goto done;
|
goto done;
|
||||||
@ -576,7 +576,7 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
close(gossip_store_fd);
|
close(gossip_store_fd);
|
||||||
daemon_conn_send(daemon->connectd,
|
daemon_conn_send(daemon->connectd,
|
||||||
take(towire_gossip_new_peer_reply(NULL,
|
take(towire_gossipd_new_peer_reply(NULL,
|
||||||
false,
|
false,
|
||||||
NULL)));
|
NULL)));
|
||||||
goto done;
|
goto done;
|
||||||
@ -646,7 +646,7 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
|
|||||||
|
|
||||||
/* Reply with success, and the new fd and gossip_state. */
|
/* Reply with success, and the new fd and gossip_state. */
|
||||||
daemon_conn_send(daemon->connectd,
|
daemon_conn_send(daemon->connectd,
|
||||||
take(towire_gossip_new_peer_reply(NULL, true, gs)));
|
take(towire_gossipd_new_peer_reply(NULL, true, gs)));
|
||||||
daemon_conn_send_fd(daemon->connectd, fds[1]);
|
daemon_conn_send_fd(daemon->connectd, fds[1]);
|
||||||
daemon_conn_send_fd(daemon->connectd, gossip_store_fd);
|
daemon_conn_send_fd(daemon->connectd, gossip_store_fd);
|
||||||
|
|
||||||
@ -665,8 +665,8 @@ static struct io_plan *connectd_get_address(struct io_conn *conn,
|
|||||||
u8 *features;
|
u8 *features;
|
||||||
struct wireaddr *addrs;
|
struct wireaddr *addrs;
|
||||||
|
|
||||||
if (!fromwire_gossip_get_addrs(msg, &id)) {
|
if (!fromwire_gossipd_get_addrs(msg, &id)) {
|
||||||
status_broken("Bad gossip_get_addrs msg from connectd: %s",
|
status_broken("Bad gossipd_get_addrs msg from connectd: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
return io_close(conn);
|
return io_close(conn);
|
||||||
}
|
}
|
||||||
@ -676,7 +676,7 @@ static struct io_plan *connectd_get_address(struct io_conn *conn,
|
|||||||
addrs = NULL;
|
addrs = NULL;
|
||||||
|
|
||||||
daemon_conn_send(daemon->connectd,
|
daemon_conn_send(daemon->connectd,
|
||||||
take(towire_gossip_get_addrs_reply(NULL, addrs)));
|
take(towire_gossipd_get_addrs_reply(NULL, addrs)));
|
||||||
return daemon_conn_read_next(conn, daemon->connectd);
|
return daemon_conn_read_next(conn, daemon->connectd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,18 +685,18 @@ static struct io_plan *connectd_req(struct io_conn *conn,
|
|||||||
const u8 *msg,
|
const u8 *msg,
|
||||||
struct daemon *daemon)
|
struct daemon *daemon)
|
||||||
{
|
{
|
||||||
enum connect_gossip_wire_type t = fromwire_peektype(msg);
|
enum connectd_gossipd_wire t = fromwire_peektype(msg);
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case WIRE_GOSSIP_NEW_PEER:
|
case WIRE_GOSSIPD_NEW_PEER:
|
||||||
return connectd_new_peer(conn, daemon, msg);
|
return connectd_new_peer(conn, daemon, msg);
|
||||||
|
|
||||||
case WIRE_GOSSIP_GET_ADDRS:
|
case WIRE_GOSSIPD_GET_ADDRS:
|
||||||
return connectd_get_address(conn, daemon, msg);
|
return connectd_get_address(conn, daemon, msg);
|
||||||
|
|
||||||
/* We send these, don't receive them. */
|
/* We send these, don't receive them. */
|
||||||
case WIRE_GOSSIP_NEW_PEER_REPLY:
|
case WIRE_GOSSIPD_NEW_PEER_REPLY:
|
||||||
case WIRE_GOSSIP_GET_ADDRS_REPLY:
|
case WIRE_GOSSIPD_GET_ADDRS_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <common/jsonrpc_errors.h>
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/hsmd_wiregen.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@ -43,7 +43,7 @@ void channel_set_owner(struct channel *channel, struct subd *owner)
|
|||||||
*/
|
*/
|
||||||
if (channel->peer->ld->connectd) {
|
if (channel->peer->ld->connectd) {
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
msg = towire_connectctl_peer_disconnected(
|
msg = towire_connectd_peer_disconnected(
|
||||||
NULL,
|
NULL,
|
||||||
&channel->peer->id);
|
&channel->peer->id);
|
||||||
subd_send_msg(channel->peer->ld->connectd,
|
subd_send_msg(channel->peer->ld->connectd,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/capabilities.h>
|
#include <hsmd/capabilities.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
@ -164,7 +164,7 @@ static struct command_result *json_connect(struct command *cmd,
|
|||||||
} else
|
} else
|
||||||
addr = NULL;
|
addr = NULL;
|
||||||
|
|
||||||
msg = towire_connectctl_connect_to_peer(NULL, &id, 0, addr);
|
msg = towire_connectd_connect_to_peer(NULL, &id, 0, addr);
|
||||||
subd_send_msg(cmd->ld->connectd, take(msg));
|
subd_send_msg(cmd->ld->connectd, take(msg));
|
||||||
|
|
||||||
/* Leave this here for peer_connected or connect_failed. */
|
/* Leave this here for peer_connected or connect_failed. */
|
||||||
@ -193,7 +193,7 @@ static void maybe_reconnect(struct delayed_reconnect *d)
|
|||||||
|
|
||||||
/* Might have gone onchain since we started timer. */
|
/* Might have gone onchain since we started timer. */
|
||||||
if (channel_active(d->channel)) {
|
if (channel_active(d->channel)) {
|
||||||
u8 *msg = towire_connectctl_connect_to_peer(NULL, &peer->id,
|
u8 *msg = towire_connectd_connect_to_peer(NULL, &peer->id,
|
||||||
d->seconds_delayed,
|
d->seconds_delayed,
|
||||||
d->addrhint);
|
d->addrhint);
|
||||||
subd_send_msg(peer->ld->connectd, take(msg));
|
subd_send_msg(peer->ld->connectd, take(msg));
|
||||||
@ -239,9 +239,9 @@ static void connect_failed(struct lightningd *ld, const u8 *msg)
|
|||||||
struct wireaddr_internal *addrhint;
|
struct wireaddr_internal *addrhint;
|
||||||
struct channel *channel;
|
struct channel *channel;
|
||||||
|
|
||||||
if (!fromwire_connectctl_connect_failed(tmpctx, msg, &id, &errcode, &errmsg,
|
if (!fromwire_connectd_connect_failed(tmpctx, msg, &id, &errcode, &errmsg,
|
||||||
&seconds_to_delay, &addrhint))
|
&seconds_to_delay, &addrhint))
|
||||||
fatal("Connect gave bad CONNECTCTL_CONNECT_FAILED message %s",
|
fatal("Connect gave bad CONNECTD_CONNECT_FAILED message %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
/* We can have multiple connect commands: fail them all */
|
/* We can have multiple connect commands: fail them all */
|
||||||
@ -273,7 +273,7 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
|
|||||||
struct channel *c;
|
struct channel *c;
|
||||||
struct uncommitted_channel *uc;
|
struct uncommitted_channel *uc;
|
||||||
|
|
||||||
if (!fromwire_connect_reconnected(msg, &id))
|
if (!fromwire_connectd_reconnected(msg, &id))
|
||||||
fatal("Bad msg %s from connectd", tal_hex(tmpctx, msg));
|
fatal("Bad msg %s from connectd", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
c = active_channel_by_id(ld, &id, &uc);
|
c = active_channel_by_id(ld, &id, &uc);
|
||||||
@ -285,32 +285,32 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
|
|||||||
|
|
||||||
static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fds)
|
static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fds)
|
||||||
{
|
{
|
||||||
enum connect_wire_type t = fromwire_peektype(msg);
|
enum connectd_wire t = fromwire_peektype(msg);
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
/* These are messages we send, not them. */
|
/* These are messages we send, not them. */
|
||||||
case WIRE_CONNECTCTL_INIT:
|
case WIRE_CONNECTD_INIT:
|
||||||
case WIRE_CONNECTCTL_ACTIVATE:
|
case WIRE_CONNECTD_ACTIVATE:
|
||||||
case WIRE_CONNECTCTL_CONNECT_TO_PEER:
|
case WIRE_CONNECTD_CONNECT_TO_PEER:
|
||||||
case WIRE_CONNECTCTL_PEER_DISCONNECTED:
|
case WIRE_CONNECTD_PEER_DISCONNECTED:
|
||||||
case WIRE_CONNECT_DEV_MEMLEAK:
|
case WIRE_CONNECTD_DEV_MEMLEAK:
|
||||||
/* This is a reply, so never gets through to here. */
|
/* This is a reply, so never gets through to here. */
|
||||||
case WIRE_CONNECTCTL_INIT_REPLY:
|
case WIRE_CONNECTD_INIT_REPLY:
|
||||||
case WIRE_CONNECTCTL_ACTIVATE_REPLY:
|
case WIRE_CONNECTD_ACTIVATE_REPLY:
|
||||||
case WIRE_CONNECT_DEV_MEMLEAK_REPLY:
|
case WIRE_CONNECTD_DEV_MEMLEAK_REPLY:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIRE_CONNECT_RECONNECTED:
|
case WIRE_CONNECTD_RECONNECTED:
|
||||||
peer_please_disconnect(connectd->ld, msg);
|
peer_please_disconnect(connectd->ld, msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIRE_CONNECT_PEER_CONNECTED:
|
case WIRE_CONNECTD_PEER_CONNECTED:
|
||||||
if (tal_count(fds) != 3)
|
if (tal_count(fds) != 3)
|
||||||
return 3;
|
return 3;
|
||||||
peer_connected(connectd->ld, msg, fds[0], fds[1], fds[2]);
|
peer_connected(connectd->ld, msg, fds[0], fds[1], fds[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIRE_CONNECTCTL_CONNECT_FAILED:
|
case WIRE_CONNECTD_CONNECT_FAILED:
|
||||||
connect_failed(connectd->ld, msg);
|
connect_failed(connectd->ld, msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -324,10 +324,10 @@ static void connect_init_done(struct subd *connectd,
|
|||||||
{
|
{
|
||||||
struct lightningd *ld = connectd->ld;
|
struct lightningd *ld = connectd->ld;
|
||||||
|
|
||||||
if (!fromwire_connectctl_init_reply(ld, reply,
|
if (!fromwire_connectd_init_reply(ld, reply,
|
||||||
&ld->binding,
|
&ld->binding,
|
||||||
&ld->announcable))
|
&ld->announcable))
|
||||||
fatal("Bad connectctl_activate_reply: %s",
|
fatal("Bad connectd_activate_reply: %s",
|
||||||
tal_hex(reply, reply));
|
tal_hex(reply, reply));
|
||||||
|
|
||||||
/* Break out of loop, so we can begin */
|
/* Break out of loop, so we can begin */
|
||||||
@ -348,7 +348,7 @@ int connectd_init(struct lightningd *ld)
|
|||||||
hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH);
|
hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH);
|
||||||
|
|
||||||
ld->connectd = new_global_subd(ld, "lightning_connectd",
|
ld->connectd = new_global_subd(ld, "lightning_connectd",
|
||||||
connect_wire_type_name, connectd_msg,
|
connectd_wire_name, connectd_msg,
|
||||||
take(&hsmfd), take(&fds[1]), NULL);
|
take(&hsmfd), take(&fds[1]), NULL);
|
||||||
if (!ld->connectd)
|
if (!ld->connectd)
|
||||||
err(1, "Could not subdaemon connectd");
|
err(1, "Could not subdaemon connectd");
|
||||||
@ -362,7 +362,7 @@ int connectd_init(struct lightningd *ld)
|
|||||||
*listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
|
*listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = towire_connectctl_init(
|
msg = towire_connectd_init(
|
||||||
tmpctx, chainparams,
|
tmpctx, chainparams,
|
||||||
ld->our_features,
|
ld->our_features,
|
||||||
&ld->id,
|
&ld->id,
|
||||||
@ -393,7 +393,7 @@ static void connect_activate_done(struct subd *connectd,
|
|||||||
|
|
||||||
void connectd_activate(struct lightningd *ld)
|
void connectd_activate(struct lightningd *ld)
|
||||||
{
|
{
|
||||||
const u8 *msg = towire_connectctl_activate(NULL, ld->listen);
|
const u8 *msg = towire_connectd_activate(NULL, ld->listen);
|
||||||
|
|
||||||
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
|
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
|
||||||
connect_activate_done, NULL);
|
connect_activate_done, NULL);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
#include <common/param.h>
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gossipd_wiregen.h>
|
#include <gossipd/gossipd_wiregen.h>
|
||||||
#include <hsmd/hsmd_wiregen.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
@ -243,7 +243,7 @@ static void connect_dev_memleak_done(struct subd *connectd,
|
|||||||
{
|
{
|
||||||
bool found_leak;
|
bool found_leak;
|
||||||
|
|
||||||
if (!fromwire_connect_dev_memleak_reply(reply, &found_leak)) {
|
if (!fromwire_connectd_dev_memleak_reply(reply, &found_leak)) {
|
||||||
was_pending(command_fail(cmd, LIGHTNINGD,
|
was_pending(command_fail(cmd, LIGHTNINGD,
|
||||||
"Bad connect_dev_memleak"));
|
"Bad connect_dev_memleak"));
|
||||||
return;
|
return;
|
||||||
@ -324,7 +324,7 @@ static struct command_result *json_memleak(struct command *cmd,
|
|||||||
|
|
||||||
/* Start by asking connectd, which is always async. */
|
/* Start by asking connectd, which is always async. */
|
||||||
subd_req(ld->connectd, ld->connectd,
|
subd_req(ld->connectd, ld->connectd,
|
||||||
take(towire_connect_dev_memleak(NULL)),
|
take(towire_connectd_dev_memleak(NULL)),
|
||||||
-1, 0, connect_dev_memleak_done, cmd);
|
-1, 0, connect_dev_memleak_done, cmd);
|
||||||
|
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/channel_control.h>
|
#include <lightningd/channel_control.h>
|
||||||
@ -104,7 +104,7 @@ static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
|
|||||||
enum log_level level,
|
enum log_level level,
|
||||||
const char *desc)
|
const char *desc)
|
||||||
{
|
{
|
||||||
u8 *msg = towire_connectctl_peer_disconnected(tmpctx, &uc->peer->id);
|
u8 *msg = towire_connectd_peer_disconnected(tmpctx, &uc->peer->id);
|
||||||
log_(uc->log, level, NULL, false, "%s", desc);
|
log_(uc->log, level, NULL, false, "%s", desc);
|
||||||
subd_send_msg(uc->peer->ld->connectd, msg);
|
subd_send_msg(uc->peer->ld->connectd, msg);
|
||||||
if (uc->fc && uc->fc->cmd)
|
if (uc->fc && uc->fc->cmd)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/connectd_wiregen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <hsmd/hsmd_wiregen.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
@ -1007,7 +1007,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
|
|||||||
|
|
||||||
hook_payload = tal(NULL, struct peer_connected_hook_payload);
|
hook_payload = tal(NULL, struct peer_connected_hook_payload);
|
||||||
hook_payload->ld = ld;
|
hook_payload->ld = ld;
|
||||||
if (!fromwire_connect_peer_connected(hook_payload, msg,
|
if (!fromwire_connectd_peer_connected(hook_payload, msg,
|
||||||
&id, &hook_payload->addr,
|
&id, &hook_payload->addr,
|
||||||
&hook_payload->pps,
|
&hook_payload->pps,
|
||||||
&their_features))
|
&their_features))
|
||||||
@ -1486,7 +1486,7 @@ static void activate_peer(struct peer *peer, u32 delay)
|
|||||||
delay));
|
delay));
|
||||||
delay_then_reconnect(channel, delay, &peer->addr);
|
delay_then_reconnect(channel, delay, &peer->addr);
|
||||||
} else {
|
} else {
|
||||||
msg = towire_connectctl_connect_to_peer(NULL,
|
msg = towire_connectd_connect_to_peer(NULL,
|
||||||
&peer->id, 0,
|
&peer->id, 0,
|
||||||
&peer->addr);
|
&peer->addr);
|
||||||
subd_send_msg(ld->connectd, take(msg));
|
subd_send_msg(ld->connectd, take(msg));
|
||||||
|
@ -113,9 +113,9 @@ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
|
|||||||
/* Generated stub for fromwire_channeld_dev_memleak_reply */
|
/* Generated stub for fromwire_channeld_dev_memleak_reply */
|
||||||
bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_connect_peer_connected */
|
/* Generated stub for fromwire_connectd_peer_connected */
|
||||||
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
|
bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_connectd_peer_connected called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_gossipd_get_incoming_channels_reply */
|
/* Generated stub for fromwire_gossipd_get_incoming_channels_reply */
|
||||||
bool fromwire_gossipd_get_incoming_channels_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct route_info **public_route_info UNNEEDED, bool **public_deadends UNNEEDED, struct route_info **private_route_info UNNEEDED, bool **private_deadends UNNEEDED)
|
bool fromwire_gossipd_get_incoming_channels_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct route_info **public_route_info UNNEEDED, bool **public_deadends UNNEEDED, struct route_info **private_route_info UNNEEDED, bool **private_deadends UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_gossipd_get_incoming_channels_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_gossipd_get_incoming_channels_reply called!\n"); abort(); }
|
||||||
@ -476,12 +476,12 @@ u8 *towire_channeld_send_shutdown(const tal_t *ctx UNNEEDED, const u8 *shutdown_
|
|||||||
/* Generated stub for towire_channeld_specific_feerates */
|
/* Generated stub for towire_channeld_specific_feerates */
|
||||||
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
||||||
/* Generated stub for towire_connectctl_connect_to_peer */
|
/* Generated stub for towire_connectd_connect_to_peer */
|
||||||
u8 *towire_connectctl_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
|
u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_connectctl_connect_to_peer called!\n"); abort(); }
|
{ fprintf(stderr, "towire_connectd_connect_to_peer called!\n"); abort(); }
|
||||||
/* Generated stub for towire_connectctl_peer_disconnected */
|
/* Generated stub for towire_connectd_peer_disconnected */
|
||||||
u8 *towire_connectctl_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
u8 *towire_connectd_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_connectctl_peer_disconnected called!\n"); abort(); }
|
{ fprintf(stderr, "towire_connectd_peer_disconnected called!\n"); abort(); }
|
||||||
/* Generated stub for towire_errorfmt */
|
/* Generated stub for towire_errorfmt */
|
||||||
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||||
const struct channel_id *channel UNNEEDED,
|
const struct channel_id *channel UNNEEDED,
|
||||||
|
@ -126,9 +126,9 @@ bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p
|
|||||||
/* Generated stub for fromwire_channeld_sending_commitsig */
|
/* Generated stub for fromwire_channeld_sending_commitsig */
|
||||||
bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED)
|
bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_connect_peer_connected */
|
/* Generated stub for fromwire_connectd_peer_connected */
|
||||||
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
|
bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_connectd_peer_connected called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_custommsg_in */
|
/* Generated stub for fromwire_custommsg_in */
|
||||||
bool fromwire_custommsg_in(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **msg UNNEEDED)
|
bool fromwire_custommsg_in(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **msg UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_custommsg_in called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_custommsg_in called!\n"); abort(); }
|
||||||
@ -664,12 +664,12 @@ u8 *towire_channeld_sending_commitsig_reply(const tal_t *ctx UNNEEDED)
|
|||||||
/* Generated stub for towire_channeld_specific_feerates */
|
/* Generated stub for towire_channeld_specific_feerates */
|
||||||
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
||||||
/* Generated stub for towire_connectctl_connect_to_peer */
|
/* Generated stub for towire_connectd_connect_to_peer */
|
||||||
u8 *towire_connectctl_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
|
u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_connectctl_connect_to_peer called!\n"); abort(); }
|
{ fprintf(stderr, "towire_connectd_connect_to_peer called!\n"); abort(); }
|
||||||
/* Generated stub for towire_connectctl_peer_disconnected */
|
/* Generated stub for towire_connectd_peer_disconnected */
|
||||||
u8 *towire_connectctl_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
u8 *towire_connectd_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_connectctl_peer_disconnected called!\n"); abort(); }
|
{ fprintf(stderr, "towire_connectd_peer_disconnected called!\n"); abort(); }
|
||||||
/* Generated stub for towire_custommsg_out */
|
/* Generated stub for towire_custommsg_out */
|
||||||
u8 *towire_custommsg_out(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED)
|
u8 *towire_custommsg_out(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_custommsg_out called!\n"); abort(); }
|
{ fprintf(stderr, "towire_custommsg_out called!\n"); abort(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user