Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
36730ddb6d
  1. 22
      gossipd/gossip.c
  2. 3
      gossipd/gossip_wire.csv
  3. 20
      lightningd/gossip_control.c

22
gossipd/gossip.c

@ -60,6 +60,7 @@
#if DEVELOPER #if DEVELOPER
static u32 max_scids_encode_bytes = -1U; static u32 max_scids_encode_bytes = -1U;
static bool suppress_gossip = false;
#endif #endif
struct local_update { struct local_update {
@ -908,6 +909,11 @@ static bool maybe_queue_gossip(struct peer *peer)
if (peer->gossip_timer) if (peer->gossip_timer)
return false; return false;
#if DEVELOPER
if (suppress_gossip)
return false;
#endif
next = next_broadcast(peer->daemon->rstate->broadcasts, next = next_broadcast(peer->daemon->rstate->broadcasts,
peer->gossip_timestamp_min, peer->gossip_timestamp_min,
peer->gossip_timestamp_max, 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); status_trace("Set max_scids_encode_bytes to %u", max_scids_encode_bytes);
return daemon_conn_read_next(conn, &daemon->master); 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 */ #endif /* DEVELOPER */
static void gossip_send_keepalive_update(struct routing_state *rstate, 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: case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
return dev_set_max_scids_encode_size(conn, daemon, return dev_set_max_scids_encode_size(conn, daemon,
daemon->master.msg_in); daemon->master.msg_in);
case WIRE_GOSSIP_DEV_SUPPRESS:
return dev_gossip_suppress(conn, daemon,
daemon->master.msg_in);
#else #else
case WIRE_GOSSIP_PING: case WIRE_GOSSIP_PING:
case WIRE_GOSSIP_QUERY_SCIDS: case WIRE_GOSSIP_QUERY_SCIDS:
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER: case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
case WIRE_GOSSIP_QUERY_CHANNEL_RANGE: case WIRE_GOSSIP_QUERY_CHANNEL_RANGE:
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE: case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIP_DEV_SUPPRESS:
break; break;
#endif /* !DEVELOPER */ #endif /* !DEVELOPER */

3
gossipd/gossip_wire.csv

@ -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 # master -> gossipd: a potential funding outpoint was spent, please forget the eventual channel
gossip_outpoint_spent,3024 gossip_outpoint_spent,3024
gossip_outpoint_spent,,short_channel_id,struct short_channel_id gossip_outpoint_spent,,short_channel_id,struct short_channel_id
# master -> gossipd: stop gossip timers.
gossip_dev_suppress,3032

Can't render this file because it has a wrong number of fields in line 6.

20
lightningd/gossip_control.c

@ -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_QUERY_CHANNEL_RANGE:
case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER: case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER:
case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE: case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIP_DEV_SUPPRESS:
/* This is a reply, so never gets through to here. */ /* This is a reply, so never gets through to here. */
case WIRE_GOSSIP_GET_UPDATE_REPLY: case WIRE_GOSSIP_GET_UPDATE_REPLY:
case WIRE_GOSSIP_GETNODES_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" "Set {max} bytes of short_channel_ids per reply_channel_range"
}; };
AUTODATA(json_command, &dev_set_max_scids_encode_size); 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 */ #endif /* DEVELOPER */

Loading…
Cancel
Save