Browse Source

lightningd: have optional node_id associated with subdaemons.

We'll use this for logging it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
4fa7b30836
  1. 1
      lightningd/channel_control.c
  2. 3
      lightningd/closing_control.c
  3. 2
      lightningd/onchain_control.c
  4. 2
      lightningd/opening_control.c
  5. 12
      lightningd/subd.c
  6. 10
      lightningd/subd.h

1
lightningd/channel_control.c

@ -353,6 +353,7 @@ void peer_start_channeld(struct channel *channel,
channel_set_owner(channel, channel_set_owner(channel,
new_channel_subd(ld, new_channel_subd(ld,
"lightning_channeld", channel, "lightning_channeld", channel,
&channel->peer->id,
channel->log, true, channel->log, true,
channel_wire_type_name, channel_wire_type_name,
channel_msg, channel_msg,

3
lightningd/closing_control.c

@ -195,7 +195,8 @@ void peer_start_closingd(struct channel *channel,
channel_set_owner(channel, channel_set_owner(channel,
new_channel_subd(ld, new_channel_subd(ld,
"lightning_closingd", "lightning_closingd",
channel, channel->log, true, channel, &channel->peer->id,
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,

2
lightningd/onchain_control.c

@ -471,7 +471,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->peer->id,
channel->log, false, channel->log, false,
onchain_wire_type_name, onchain_wire_type_name,
onchain_msg, onchain_msg,

2
lightningd/opening_control.c

@ -923,7 +923,7 @@ void peer_start_openingd(struct peer *peer,
uc->openingd = new_channel_subd(peer->ld, uc->openingd = new_channel_subd(peer->ld,
"lightning_openingd", "lightning_openingd",
uc, uc->log, uc, &peer->id, uc->log,
true, opening_wire_type_name, true, opening_wire_type_name,
openingd_msg, openingd_msg,
opening_channel_errmsg, opening_channel_errmsg,

12
lightningd/subd.c

@ -601,6 +601,7 @@ static struct io_plan *msg_setup(struct io_conn *conn, struct subd *sd)
static struct subd *new_subd(struct lightningd *ld, static struct subd *new_subd(struct lightningd *ld,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id,
struct log *base_log, struct log *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
@ -658,6 +659,10 @@ static struct subd *new_subd(struct lightningd *ld,
tal_add_destructor(sd, destroy_subd); tal_add_destructor(sd, destroy_subd);
list_head_init(&sd->reqs); list_head_init(&sd->reqs);
sd->channel = channel; sd->channel = channel;
if (node_id)
sd->node_id = tal_dup(sd, struct node_id, node_id);
else
sd->node_id = NULL;
/* conn actually owns daemon: we die when it does. */ /* conn actually owns daemon: we die when it does. */
sd->conn = io_new_conn(ld, msg_fd, msg_setup, sd); sd->conn = io_new_conn(ld, msg_fd, msg_setup, sd);
@ -682,7 +687,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, false, msgname, msgcb, NULL, NULL, &ap); sd = new_subd(ld, name, NULL, NULL, NULL, false, msgname, msgcb, NULL, NULL, &ap);
va_end(ap); va_end(ap);
sd->must_not_exit = true; sd->must_not_exit = true;
@ -692,6 +697,7 @@ struct subd *new_global_subd(struct lightningd *ld,
struct subd *new_channel_subd_(struct lightningd *ld, struct subd *new_channel_subd_(struct lightningd *ld,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id,
struct log *base_log, struct log *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
@ -711,8 +717,8 @@ 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, talks_to_peer, msgname, sd = new_subd(ld, name, channel, node_id, base_log, talks_to_peer,
msgcb, errcb, billboardcb, &ap); msgname, msgcb, errcb, billboardcb, &ap);
va_end(ap); va_end(ap);
return sd; return sd;
} }

10
lightningd/subd.h

@ -34,6 +34,7 @@ struct subd {
/* For logging */ /* For logging */
struct log *log; struct log *log;
const struct node_id *node_id;
/* Callback when non-reply message comes in (inside db transaction) */ /* Callback when non-reply message comes in (inside db transaction) */
unsigned (*msgcb)(struct subd *, const u8 *, const int *); unsigned (*msgcb)(struct subd *, const u8 *, const int *);
@ -97,6 +98,7 @@ struct subd *new_global_subd(struct lightningd *ld,
* @ld: global state * @ld: global state
* @name: basename of daemon * @name: basename of daemon
* @channel: channel to associate. * @channel: channel to associate.
* @node_id: node_id of peer, for logging.
* @base_log: log to use (actually makes a copy so it has name in prefix) * @base_log: log to use (actually makes a copy so it has name in prefix)
* @msgname: function to get name from messages * @msgname: function to get name from messages
* @msgcb: function to call (inside db transaction) when non-fatal message received (or NULL) * @msgcb: function to call (inside db transaction) when non-fatal message received (or NULL)
@ -112,6 +114,7 @@ struct subd *new_global_subd(struct lightningd *ld,
struct subd *new_channel_subd_(struct lightningd *ld, struct subd *new_channel_subd_(struct lightningd *ld,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id,
struct log *base_log, struct log *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
@ -127,9 +130,10 @@ struct subd *new_channel_subd_(struct lightningd *ld,
const char *happenings), const char *happenings),
...); ...);
#define new_channel_subd(ld, name, channel, log, talks_to_peer, msgname, \ #define new_channel_subd(ld, name, channel, node_id, log, talks_to_peer, \
msgcb, errcb, billboardcb, ...) \ msgname, msgcb, errcb, billboardcb, ...) \
new_channel_subd_((ld), (name), (channel), (log), (talks_to_peer), \ new_channel_subd_((ld), (name), (channel), (node_id), (log), \
(talks_to_peer), \
(msgname), (msgcb), \ (msgname), (msgcb), \
typesafe_cb_postargs(void, void *, (errcb), \ typesafe_cb_postargs(void, void *, (errcb), \
(channel), \ (channel), \

Loading…
Cancel
Save