subd: record which ones connect to a peer.
This comes in useful for the next patch. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b68fb24758
commit
1e282ecb7a
|
@ -199,9 +199,10 @@ bool peer_start_channeld(struct channel *channel,
|
||||||
if (hsmfd < 0)
|
if (hsmfd < 0)
|
||||||
fatal("Could not read fd from HSM: %s", strerror(errno));
|
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,
|
"lightning_channeld", channel,
|
||||||
channel->log,
|
channel->log, true,
|
||||||
channel_wire_type_name,
|
channel_wire_type_name,
|
||||||
channel_msg,
|
channel_msg,
|
||||||
channel_errmsg,
|
channel_errmsg,
|
||||||
|
|
|
@ -145,9 +145,10 @@ void peer_start_closingd(struct channel *channel,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_set_owner(channel, new_channel_subd(ld,
|
channel_set_owner(channel,
|
||||||
|
new_channel_subd(ld,
|
||||||
"lightning_closingd",
|
"lightning_closingd",
|
||||||
channel, channel->log,
|
channel, channel->log, true,
|
||||||
closing_wire_type_name, closing_msg,
|
closing_wire_type_name, closing_msg,
|
||||||
channel_errmsg,
|
channel_errmsg,
|
||||||
channel_set_billboard,
|
channel_set_billboard,
|
||||||
|
|
|
@ -387,7 +387,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||||
channel_set_owner(channel, new_channel_subd(ld,
|
channel_set_owner(channel, new_channel_subd(ld,
|
||||||
"lightning_onchaind",
|
"lightning_onchaind",
|
||||||
channel,
|
channel,
|
||||||
channel->log,
|
channel->log, false,
|
||||||
onchain_wire_type_name,
|
onchain_wire_type_name,
|
||||||
onchain_msg,
|
onchain_msg,
|
||||||
onchain_error,
|
onchain_error,
|
||||||
|
|
|
@ -698,7 +698,7 @@ u8 *peer_accept_channel(const tal_t *ctx,
|
||||||
"Multiple channels unsupported");
|
"Multiple channels unsupported");
|
||||||
|
|
||||||
uc->openingd = new_channel_subd(ld, "lightning_openingd", uc, uc->log,
|
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_errmsg,
|
||||||
opening_channel_set_billboard,
|
opening_channel_set_billboard,
|
||||||
take(&peer_fd), take(&gossip_fd),
|
take(&peer_fd), take(&gossip_fd),
|
||||||
|
@ -786,12 +786,13 @@ static void peer_offer_channel(struct lightningd *ld,
|
||||||
tal_steal(fc->uc, fc);
|
tal_steal(fc->uc, fc);
|
||||||
|
|
||||||
fc->uc->openingd = new_channel_subd(ld,
|
fc->uc->openingd = new_channel_subd(ld,
|
||||||
"lightning_openingd", fc->uc, fc->uc->log,
|
"lightning_openingd",
|
||||||
opening_wire_type_name, NULL,
|
fc->uc, fc->uc->log,
|
||||||
opening_channel_errmsg,
|
true, opening_wire_type_name, NULL,
|
||||||
opening_channel_set_billboard,
|
opening_channel_errmsg,
|
||||||
take(&peer_fd), take(&gossip_fd),
|
opening_channel_set_billboard,
|
||||||
NULL);
|
take(&peer_fd), take(&gossip_fd),
|
||||||
|
NULL);
|
||||||
if (!fc->uc->openingd) {
|
if (!fc->uc->openingd) {
|
||||||
/* We don't send them an error packet: for them, nothing
|
/* We don't send them an error packet: for them, nothing
|
||||||
* happened! */
|
* happened! */
|
||||||
|
|
|
@ -631,6 +631,7 @@ static struct subd *new_subd(struct lightningd *ld,
|
||||||
const char *name,
|
const char *name,
|
||||||
void *channel,
|
void *channel,
|
||||||
struct log *base_log,
|
struct log *base_log,
|
||||||
|
bool talks_to_peer,
|
||||||
const char *(*msgname)(int msgtype),
|
const char *(*msgname)(int msgtype),
|
||||||
unsigned int (*msgcb)(struct subd *,
|
unsigned int (*msgcb)(struct subd *,
|
||||||
const u8 *, const int *fds),
|
const u8 *, const int *fds),
|
||||||
|
@ -674,6 +675,7 @@ static struct subd *new_subd(struct lightningd *ld,
|
||||||
|
|
||||||
sd->name = name;
|
sd->name = name;
|
||||||
sd->must_not_exit = false;
|
sd->must_not_exit = false;
|
||||||
|
sd->talks_to_peer = talks_to_peer;
|
||||||
sd->msgname = msgname;
|
sd->msgname = msgname;
|
||||||
sd->msgcb = msgcb;
|
sd->msgcb = msgcb;
|
||||||
sd->errcb = errcb;
|
sd->errcb = errcb;
|
||||||
|
@ -707,7 +709,7 @@ struct subd *new_global_subd(struct lightningd *ld,
|
||||||
struct subd *sd;
|
struct subd *sd;
|
||||||
|
|
||||||
va_start(ap, msgcb);
|
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);
|
va_end(ap);
|
||||||
|
|
||||||
sd->must_not_exit = true;
|
sd->must_not_exit = true;
|
||||||
|
@ -718,6 +720,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
|
||||||
const char *name,
|
const char *name,
|
||||||
void *channel,
|
void *channel,
|
||||||
struct log *base_log,
|
struct log *base_log,
|
||||||
|
bool talks_to_peer,
|
||||||
const char *(*msgname)(int msgtype),
|
const char *(*msgname)(int msgtype),
|
||||||
unsigned int (*msgcb)(struct subd *, const u8 *,
|
unsigned int (*msgcb)(struct subd *, const u8 *,
|
||||||
const int *fds),
|
const int *fds),
|
||||||
|
@ -735,7 +738,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
|
||||||
struct subd *sd;
|
struct subd *sd;
|
||||||
|
|
||||||
va_start(ap, billboardcb);
|
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);
|
msgcb, errcb, billboardcb, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return sd;
|
return sd;
|
||||||
|
|
|
@ -61,6 +61,9 @@ struct subd {
|
||||||
/* For global daemons: we fail if they fail. */
|
/* For global daemons: we fail if they fail. */
|
||||||
bool must_not_exit;
|
bool must_not_exit;
|
||||||
|
|
||||||
|
/* Do we talk to a peer? ie. not onchaind */
|
||||||
|
bool talks_to_peer;
|
||||||
|
|
||||||
/* Messages queue up here. */
|
/* Messages queue up here. */
|
||||||
struct msg_queue outq;
|
struct msg_queue outq;
|
||||||
|
|
||||||
|
@ -109,6 +112,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
|
||||||
const char *name,
|
const char *name,
|
||||||
void *channel,
|
void *channel,
|
||||||
struct log *base_log,
|
struct log *base_log,
|
||||||
|
bool talks_to_peer,
|
||||||
const char *(*msgname)(int msgtype),
|
const char *(*msgname)(int msgtype),
|
||||||
unsigned int (*msgcb)(struct subd *, const u8 *,
|
unsigned int (*msgcb)(struct subd *, const u8 *,
|
||||||
const int *fds),
|
const int *fds),
|
||||||
|
@ -122,9 +126,10 @@ struct subd *new_channel_subd_(struct lightningd *ld,
|
||||||
const char *happenings),
|
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, ...) \
|
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), \
|
typesafe_cb_postargs(void, void *, (errcb), \
|
||||||
(channel), int, int, \
|
(channel), int, int, \
|
||||||
const struct crypto_state *, \
|
const struct crypto_state *, \
|
||||||
|
|
Loading…
Reference in New Issue