Limit scope of variable failcode. Remove dead code.

This commit is contained in:
practicalswift 2018-03-05 17:43:40 +01:00 committed by Rusty Russell
parent b557e7b0fc
commit f9bd43f266

View file

@ -399,7 +399,6 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
const char *localfail) const char *localfail)
{ {
struct onionreply *reply; struct onionreply *reply;
enum onion_type failcode;
struct secret *path_secrets; struct secret *path_secrets;
struct wallet_payment *payment; struct wallet_payment *payment;
struct routing_failure* fail = NULL; struct routing_failure* fail = NULL;
@ -429,7 +428,6 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
/* This gives more details than a generic failure message */ /* This gives more details than a generic failure message */
if (localfail) { if (localfail) {
fail = local_routing_failure(tmpctx, ld, hout, payment); fail = local_routing_failure(tmpctx, ld, hout, payment);
failcode = fail->failcode;
failmsg = localfail; failmsg = localfail;
retry_plausible = true; retry_plausible = true;
report_to_gossipd = true; report_to_gossipd = true;
@ -449,7 +447,6 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
tal_hex(tmpctx, hout->failuremsg)); tal_hex(tmpctx, hout->failuremsg));
/* Cannot report failure. */ /* Cannot report failure. */
fail = NULL; fail = NULL;
failcode = WIRE_PERMANENT_NODE_FAILURE;
/* Select a channel to mark unroutable by random */ /* Select a channel to mark unroutable by random */
random_mark_channel_unroutable(hout->key.channel->log, random_mark_channel_unroutable(hout->key.channel->log,
ld->gossip, ld->gossip,
@ -461,7 +458,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
* report anything else */ * report anything else */
report_to_gossipd = false; report_to_gossipd = false;
} else { } else {
failcode = fromwire_peektype(reply->msg); enum onion_type failcode = fromwire_peektype(reply->msg);
log_info(hout->key.channel->log, log_info(hout->key.channel->log,
"htlc %"PRIu64" " "htlc %"PRIu64" "
"failed from %ith node " "failed from %ith node "