diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 207c74b0e..2c0f71b55 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -199,9 +199,10 @@ bool peer_start_channeld(struct channel *channel, if (hsmfd < 0) fatal("Could not read fd from HSM: %s", strerror(errno)); - channel_set_owner(channel, new_channel_subd(ld, + channel_set_owner(channel, + new_channel_subd(ld, "lightning_channeld", channel, - channel->log, + channel->log, true, channel_wire_type_name, channel_msg, channel_errmsg, diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index a41c0a291..bd2006d36 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -145,9 +145,10 @@ void peer_start_closingd(struct channel *channel, return; } - channel_set_owner(channel, new_channel_subd(ld, + channel_set_owner(channel, + new_channel_subd(ld, "lightning_closingd", - channel, channel->log, + channel, channel->log, true, closing_wire_type_name, closing_msg, channel_errmsg, channel_set_billboard, diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index 66af23b97..199f44dd0 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -387,7 +387,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel, channel_set_owner(channel, new_channel_subd(ld, "lightning_onchaind", channel, - channel->log, + channel->log, false, onchain_wire_type_name, onchain_msg, onchain_error, diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 08bdee102..360916ec0 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -698,7 +698,7 @@ u8 *peer_accept_channel(const tal_t *ctx, "Multiple channels unsupported"); uc->openingd = new_channel_subd(ld, "lightning_openingd", uc, uc->log, - opening_wire_type_name, NULL, + true, opening_wire_type_name, NULL, opening_channel_errmsg, opening_channel_set_billboard, take(&peer_fd), take(&gossip_fd), @@ -786,12 +786,13 @@ static void peer_offer_channel(struct lightningd *ld, tal_steal(fc->uc, fc); fc->uc->openingd = new_channel_subd(ld, - "lightning_openingd", fc->uc, fc->uc->log, - opening_wire_type_name, NULL, - opening_channel_errmsg, - opening_channel_set_billboard, - take(&peer_fd), take(&gossip_fd), - NULL); + "lightning_openingd", + fc->uc, fc->uc->log, + true, opening_wire_type_name, NULL, + opening_channel_errmsg, + opening_channel_set_billboard, + take(&peer_fd), take(&gossip_fd), + NULL); if (!fc->uc->openingd) { /* We don't send them an error packet: for them, nothing * happened! */ diff --git a/lightningd/subd.c b/lightningd/subd.c index 27e1e626d..f4c69cb92 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -631,6 +631,7 @@ static struct subd *new_subd(struct lightningd *ld, const char *name, void *channel, struct log *base_log, + bool talks_to_peer, const char *(*msgname)(int msgtype), unsigned int (*msgcb)(struct subd *, const u8 *, const int *fds), @@ -674,6 +675,7 @@ static struct subd *new_subd(struct lightningd *ld, sd->name = name; sd->must_not_exit = false; + sd->talks_to_peer = talks_to_peer; sd->msgname = msgname; sd->msgcb = msgcb; sd->errcb = errcb; @@ -707,7 +709,7 @@ struct subd *new_global_subd(struct lightningd *ld, struct subd *sd; va_start(ap, msgcb); - sd = new_subd(ld, name, NULL, NULL, msgname, msgcb, NULL, NULL, &ap); + sd = new_subd(ld, name, NULL, NULL, false, msgname, msgcb, NULL, NULL, &ap); va_end(ap); sd->must_not_exit = true; @@ -718,6 +720,7 @@ struct subd *new_channel_subd_(struct lightningd *ld, const char *name, void *channel, struct log *base_log, + bool talks_to_peer, const char *(*msgname)(int msgtype), unsigned int (*msgcb)(struct subd *, const u8 *, const int *fds), @@ -735,7 +738,7 @@ struct subd *new_channel_subd_(struct lightningd *ld, struct subd *sd; va_start(ap, billboardcb); - sd = new_subd(ld, name, channel, base_log, msgname, + sd = new_subd(ld, name, channel, base_log, talks_to_peer, msgname, msgcb, errcb, billboardcb, &ap); va_end(ap); return sd; diff --git a/lightningd/subd.h b/lightningd/subd.h index 5a9b8a086..037e9c7c2 100644 --- a/lightningd/subd.h +++ b/lightningd/subd.h @@ -61,6 +61,9 @@ struct subd { /* For global daemons: we fail if they fail. */ bool must_not_exit; + /* Do we talk to a peer? ie. not onchaind */ + bool talks_to_peer; + /* Messages queue up here. */ struct msg_queue outq; @@ -109,6 +112,7 @@ struct subd *new_channel_subd_(struct lightningd *ld, const char *name, void *channel, struct log *base_log, + bool talks_to_peer, const char *(*msgname)(int msgtype), unsigned int (*msgcb)(struct subd *, const u8 *, const int *fds), @@ -122,9 +126,10 @@ struct subd *new_channel_subd_(struct lightningd *ld, const char *happenings), ...); -#define new_channel_subd(ld, name, channel, log, msgname, \ +#define new_channel_subd(ld, name, channel, log, talks_to_peer, msgname, \ msgcb, errcb, billboardcb, ...) \ - new_channel_subd_((ld), (name), (channel), (log), (msgname), (msgcb), \ + new_channel_subd_((ld), (name), (channel), (log), (talks_to_peer), \ + (msgname), (msgcb), \ typesafe_cb_postargs(void, void *, (errcb), \ (channel), int, int, \ const struct crypto_state *, \