|
@ -413,6 +413,18 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[2]) |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool handle_set_billboard(struct subd *sd, const u8 *msg) |
|
|
|
|
|
{ |
|
|
|
|
|
bool perm; |
|
|
|
|
|
char *happenings; |
|
|
|
|
|
|
|
|
|
|
|
if (!fromwire_status_peer_billboard(msg, msg, &perm, &happenings)) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
sd->billboardcb(sd->channel, perm, happenings); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd) |
|
|
static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd) |
|
|
{ |
|
|
{ |
|
|
int type = fromwire_peektype(sd->msg_in); |
|
|
int type = fromwire_peektype(sd->msg_in); |
|
@ -460,6 +472,12 @@ static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd) |
|
|
goto malformed; |
|
|
goto malformed; |
|
|
log_info(sd->log, "Peer connection lost"); |
|
|
log_info(sd->log, "Peer connection lost"); |
|
|
goto close; |
|
|
goto close; |
|
|
|
|
|
case WIRE_STATUS_PEER_BILLBOARD: |
|
|
|
|
|
if (!sd->channel) |
|
|
|
|
|
goto malformed; |
|
|
|
|
|
if (!handle_set_billboard(sd, sd->msg_in)) |
|
|
|
|
|
goto malformed; |
|
|
|
|
|
goto next; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (sd->channel) { |
|
|
if (sd->channel) { |
|
@ -629,6 +647,9 @@ static struct subd *new_subd(struct lightningd *ld, |
|
|
const struct channel_id *channel_id, |
|
|
const struct channel_id *channel_id, |
|
|
const char *desc, |
|
|
const char *desc, |
|
|
const u8 *err_for_them), |
|
|
const u8 *err_for_them), |
|
|
|
|
|
void (*billboardcb)(void *channel, |
|
|
|
|
|
bool perm, |
|
|
|
|
|
const char *happenings), |
|
|
va_list *ap) |
|
|
va_list *ap) |
|
|
{ |
|
|
{ |
|
|
struct subd *sd = tal(ld, struct subd); |
|
|
struct subd *sd = tal(ld, struct subd); |
|
@ -661,6 +682,7 @@ static struct subd *new_subd(struct lightningd *ld, |
|
|
sd->msgname = msgname; |
|
|
sd->msgname = msgname; |
|
|
sd->msgcb = msgcb; |
|
|
sd->msgcb = msgcb; |
|
|
sd->errcb = errcb; |
|
|
sd->errcb = errcb; |
|
|
|
|
|
sd->billboardcb = billboardcb; |
|
|
sd->fds_in = NULL; |
|
|
sd->fds_in = NULL; |
|
|
msg_queue_init(&sd->outq, sd); |
|
|
msg_queue_init(&sd->outq, sd); |
|
|
tal_add_destructor(sd, destroy_subd); |
|
|
tal_add_destructor(sd, destroy_subd); |
|
@ -687,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, &ap); |
|
|
sd = new_subd(ld, name, NULL, NULL, msgname, msgcb, NULL, NULL, &ap); |
|
|
va_end(ap); |
|
|
va_end(ap); |
|
|
|
|
|
|
|
|
sd->must_not_exit = true; |
|
|
sd->must_not_exit = true; |
|
@ -708,13 +730,16 @@ struct subd *new_channel_subd_(struct lightningd *ld, |
|
|
const struct channel_id *channel_id, |
|
|
const struct channel_id *channel_id, |
|
|
const char *desc, |
|
|
const char *desc, |
|
|
const u8 *err_for_them), |
|
|
const u8 *err_for_them), |
|
|
|
|
|
void (*billboardcb)(void *channel, bool perm, |
|
|
|
|
|
const char *happenings), |
|
|
...) |
|
|
...) |
|
|
{ |
|
|
{ |
|
|
va_list ap; |
|
|
va_list ap; |
|
|
struct subd *sd; |
|
|
struct subd *sd; |
|
|
|
|
|
|
|
|
va_start(ap, errcb); |
|
|
va_start(ap, billboardcb); |
|
|
sd = new_subd(ld, name, channel, base_log, msgname, msgcb, errcb, &ap); |
|
|
sd = new_subd(ld, name, channel, base_log, msgname, |
|
|
|
|
|
msgcb, errcb, billboardcb, &ap); |
|
|
va_end(ap); |
|
|
va_end(ap); |
|
|
return sd; |
|
|
return sd; |
|
|
} |
|
|
} |
|
|