mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 16:44:20 +01:00
gossipd: test that fromwire from lightningd messages succeeds.
Also tiny drive-by cleanup for gossip_disable_local_channels to modern form. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1340,10 +1340,12 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
|
|||||||
double fuzz;
|
double fuzz;
|
||||||
struct siphash_seed seed;
|
struct siphash_seed seed;
|
||||||
|
|
||||||
fromwire_gossip_getroute_request(msg,
|
if (!fromwire_gossip_getroute_request(msg,
|
||||||
&source, &destination,
|
&source, &destination,
|
||||||
&msatoshi, &riskfactor, &final_cltv,
|
&msatoshi, &riskfactor,
|
||||||
&fuzz, &seed);
|
&final_cltv, &fuzz, &seed))
|
||||||
|
master_badmsg(WIRE_GOSSIP_GETROUTE_REQUEST, msg);
|
||||||
|
|
||||||
status_trace("Trying to find a route from %s to %s for %"PRIu64" msatoshi",
|
status_trace("Trying to find a route from %s to %s for %"PRIu64" msatoshi",
|
||||||
pubkey_to_hexstr(tmpctx, &source),
|
pubkey_to_hexstr(tmpctx, &source),
|
||||||
pubkey_to_hexstr(tmpctx, &destination), msatoshi);
|
pubkey_to_hexstr(tmpctx, &destination), msatoshi);
|
||||||
@@ -1398,7 +1400,8 @@ static struct io_plan *getchannels_req(struct io_conn *conn, struct daemon *daem
|
|||||||
struct chan *chan;
|
struct chan *chan;
|
||||||
struct short_channel_id *scid;
|
struct short_channel_id *scid;
|
||||||
|
|
||||||
fromwire_gossip_getchannels_request(msg, msg, &scid);
|
if (!fromwire_gossip_getchannels_request(msg, msg, &scid))
|
||||||
|
master_badmsg(WIRE_GOSSIP_GETCHANNELS_REQUEST, msg);
|
||||||
|
|
||||||
entries = tal_arr(tmpctx, struct gossip_getchannels_entry, 0);
|
entries = tal_arr(tmpctx, struct gossip_getchannels_entry, 0);
|
||||||
if (scid) {
|
if (scid) {
|
||||||
@@ -1449,7 +1452,8 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon,
|
|||||||
const struct gossip_getnodes_entry **nodes;
|
const struct gossip_getnodes_entry **nodes;
|
||||||
struct pubkey *id;
|
struct pubkey *id;
|
||||||
|
|
||||||
fromwire_gossip_getnodes_request(tmpctx, msg, &id);
|
if (!fromwire_gossip_getnodes_request(tmpctx, msg, &id))
|
||||||
|
master_badmsg(WIRE_GOSSIP_GETNODES_REQUEST, msg);
|
||||||
|
|
||||||
nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, 0);
|
nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, 0);
|
||||||
if (id) {
|
if (id) {
|
||||||
@@ -1789,14 +1793,13 @@ static void gossip_refresh_network(struct daemon *daemon)
|
|||||||
static void gossip_disable_local_channels(struct daemon *daemon)
|
static void gossip_disable_local_channels(struct daemon *daemon)
|
||||||
{
|
{
|
||||||
struct node *local_node = get_node(daemon->rstate, &daemon->id);
|
struct node *local_node = get_node(daemon->rstate, &daemon->id);
|
||||||
size_t i;
|
|
||||||
|
|
||||||
/* We don't have a local_node, so we don't have any channels yet
|
/* We don't have a local_node, so we don't have any channels yet
|
||||||
* either */
|
* either */
|
||||||
if (!local_node)
|
if (!local_node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < tal_count(local_node->chans); i++)
|
for (size_t i = 0; i < tal_count(local_node->chans); i++)
|
||||||
local_node->chans[i]->local_disabled = true;
|
local_node->chans[i]->local_disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user