mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: dev-suppress-gossip.
Useful for testing that we only get an update via the error message. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
162879d6a2
commit
36730ddb6d
@ -60,6 +60,7 @@
|
||||
|
||||
#if DEVELOPER
|
||||
static u32 max_scids_encode_bytes = -1U;
|
||||
static bool suppress_gossip = false;
|
||||
#endif
|
||||
|
||||
struct local_update {
|
||||
@ -908,6 +909,11 @@ static bool maybe_queue_gossip(struct peer *peer)
|
||||
if (peer->gossip_timer)
|
||||
return false;
|
||||
|
||||
#if DEVELOPER
|
||||
if (suppress_gossip)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
next = next_broadcast(peer->daemon->rstate->broadcasts,
|
||||
peer->gossip_timestamp_min,
|
||||
peer->gossip_timestamp_max,
|
||||
@ -1731,6 +1737,18 @@ static struct io_plan *dev_set_max_scids_encode_size(struct io_conn *conn,
|
||||
status_trace("Set max_scids_encode_bytes to %u", max_scids_encode_bytes);
|
||||
return daemon_conn_read_next(conn, &daemon->master);
|
||||
}
|
||||
|
||||
static struct io_plan *dev_gossip_suppress(struct io_conn *conn,
|
||||
struct daemon *daemon,
|
||||
const u8 *msg)
|
||||
{
|
||||
if (!fromwire_gossip_dev_suppress(msg))
|
||||
master_badmsg(WIRE_GOSSIP_DEV_SUPPRESS, msg);
|
||||
|
||||
status_unusual("Suppressing all gossip");
|
||||
suppress_gossip = true;
|
||||
return daemon_conn_read_next(conn, &daemon->master);
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
static void gossip_send_keepalive_update(struct routing_state *rstate,
|
||||
@ -2126,12 +2144,16 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
|
||||
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
|
||||
return dev_set_max_scids_encode_size(conn, daemon,
|
||||
daemon->master.msg_in);
|
||||
case WIRE_GOSSIP_DEV_SUPPRESS:
|
||||
return dev_gossip_suppress(conn, daemon,
|
||||
daemon->master.msg_in);
|
||||
#else
|
||||
case WIRE_GOSSIP_PING:
|
||||
case WIRE_GOSSIP_QUERY_SCIDS:
|
||||
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
|
||||
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
|
||||
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
|
||||
case WIRE_GOSSIP_DEV_SUPPRESS:
|
||||
break;
|
||||
#endif /* !DEVELOPER */
|
||||
|
||||
|
@ -160,3 +160,6 @@ gossip_mark_channel_unroutable,,channel,struct short_channel_id
|
||||
# master -> gossipd: a potential funding outpoint was spent, please forget the eventual channel
|
||||
gossip_outpoint_spent,3024
|
||||
gossip_outpoint_spent,,short_channel_id,struct short_channel_id
|
||||
|
||||
# master -> gossipd: stop gossip timers.
|
||||
gossip_dev_suppress,3032
|
||||
|
|
@ -115,6 +115,7 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
|
||||
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
|
||||
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
|
||||
case WIRE_GOSSIP_DEV_SUPPRESS:
|
||||
/* This is a reply, so never gets through to here. */
|
||||
case WIRE_GOSSIP_GET_UPDATE_REPLY:
|
||||
case WIRE_GOSSIP_GETNODES_REPLY:
|
||||
@ -594,4 +595,23 @@ static const struct json_command dev_set_max_scids_encode_size = {
|
||||
"Set {max} bytes of short_channel_ids per reply_channel_range"
|
||||
};
|
||||
AUTODATA(json_command, &dev_set_max_scids_encode_size);
|
||||
|
||||
static void json_dev_suppress_gossip(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
if (!param(cmd, buffer, params, NULL))
|
||||
return;
|
||||
|
||||
subd_send_msg(cmd->ld->gossip, take(towire_gossip_dev_suppress(NULL)));
|
||||
|
||||
command_success(cmd, null_response(cmd));
|
||||
}
|
||||
|
||||
static const struct json_command dev_suppress_gossip = {
|
||||
"dev-suppress-gossip",
|
||||
json_dev_suppress_gossip,
|
||||
"Stop this node from sending any more gossip."
|
||||
};
|
||||
AUTODATA(json_command, &dev_suppress_gossip);
|
||||
#endif /* DEVELOPER */
|
||||
|
Loading…
Reference in New Issue
Block a user