is_all_channels: rename to channel_id_is_all

Suggested-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-22 19:33:03 +10:30 committed by Christian Decker
parent 1954844fbf
commit 74e684cc0d
3 changed files with 12 additions and 13 deletions

View file

@ -43,15 +43,8 @@ u8 *towire_errorfmt(const tal_t *ctx,
return msg; return msg;
} }
bool is_all_channels(const struct channel_id *channel_id) bool channel_id_is_all(const struct channel_id *channel_id)
{ {
/* BOLT #1:
*
* A node receiving `error` MUST fail the channel referred to by the
* message, or if `channel_id` is zero, it MUST fail all channels and
* MUST close the connection. If no existing channel is referred to
* by the message, the receiver MUST ignore the message.
*/
return memeqzero(channel_id, sizeof(*channel_id)); return memeqzero(channel_id, sizeof(*channel_id));
} }
@ -86,7 +79,7 @@ char *sanitize_error(const tal_t *ctx, const u8 *errmsg,
} }
return tal_fmt(ctx, "channel %s: %.*s", return tal_fmt(ctx, "channel %s: %.*s",
is_all_channels(channel_id) channel_id_is_all(channel_id)
? "ALL" ? "ALL"
: type_to_string(ctx, struct channel_id, channel_id), : type_to_string(ctx, struct channel_id, channel_id),
(int)tal_len(data), (char *)data); (int)tal_len(data), (char *)data);

View file

@ -32,10 +32,16 @@ u8 *towire_errorfmtv(const tal_t *ctx,
const char *fmt, const char *fmt,
va_list ap); va_list ap);
/** /* BOLT #1:
* is_all_channels - True if channel_id is all zeroes. *
* A node receiving `error` MUST fail the channel referred to by the message,
* or if `channel_id` is zero, it MUST fail all channels and MUST close the
* connection.
*/ */
bool is_all_channels(const struct channel_id *channel_id); /**
* channel_id_is_all - True if channel_id is all zeroes.
*/
bool channel_id_is_all(const struct channel_id *channel_id);
/** /**
* sanitize_error - extract and sanitize contents of WIRE_ERROR. * sanitize_error - extract and sanitize contents of WIRE_ERROR.

View file

@ -267,7 +267,7 @@ static bool is_all_channel_error(const u8 *msg)
if (!fromwire_error(msg, msg, NULL, &channel_id, &data)) if (!fromwire_error(msg, msg, NULL, &channel_id, &data))
return false; return false;
tal_free(data); tal_free(data);
return is_all_channels(&channel_id); return channel_id_is_all(&channel_id);
} }
static struct io_plan *peer_close_after_error(struct io_conn *conn, static struct io_plan *peer_close_after_error(struct io_conn *conn,