Browse Source

is_all_channels: rename to channel_id_is_all

Suggested-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
74e684cc0d
  1. 11
      common/wire_error.c
  2. 10
      common/wire_error.h
  3. 2
      gossipd/gossip.c

11
common/wire_error.c

@ -43,15 +43,8 @@ u8 *towire_errorfmt(const tal_t *ctx,
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));
}
@ -86,7 +79,7 @@ char *sanitize_error(const tal_t *ctx, const u8 *errmsg,
}
return tal_fmt(ctx, "channel %s: %.*s",
is_all_channels(channel_id)
channel_id_is_all(channel_id)
? "ALL"
: type_to_string(ctx, struct channel_id, channel_id),
(int)tal_len(data), (char *)data);

10
common/wire_error.h

@ -32,10 +32,16 @@ u8 *towire_errorfmtv(const tal_t *ctx,
const char *fmt,
va_list ap);
/* 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.
*/
/**
* is_all_channels - True if channel_id is all zeroes.
* channel_id_is_all - True if channel_id is all zeroes.
*/
bool is_all_channels(const struct channel_id *channel_id);
bool channel_id_is_all(const struct channel_id *channel_id);
/**
* sanitize_error - extract and sanitize contents of WIRE_ERROR.

2
gossipd/gossip.c

@ -267,7 +267,7 @@ static bool is_all_channel_error(const u8 *msg)
if (!fromwire_error(msg, msg, NULL, &channel_id, &data))
return false;
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,

Loading…
Cancel
Save