Skip to content

Commit 6daa12b

Browse files
f Failure->PathFailure
1 parent 75f4976 commit 6daa12b

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
3333
use lightning::routing::utxo::UtxoLookup;
3434
use lightning::routing::router::Router;
3535
use lightning::routing::scoring::{Score, WriteableScore};
36-
use lightning::util::events::{Event, EventHandler, EventsProvider, Failure};
36+
use lightning::util::events::{Event, EventHandler, EventsProvider, PathFailure};
3737
use lightning::util::logger::Logger;
3838
use lightning::util::persist::Persister;
3939
use lightning_rapid_gossip_sync::RapidGossipSync;
@@ -216,7 +216,7 @@ fn handle_network_graph_update<L: Deref>(
216216
network_graph: &NetworkGraph<L>, event: &Event
217217
) where L::Target: Logger {
218218
if let Event::PaymentPathFailed {
219-
failure: Failure::OnPath { network_update: Some(ref upd) }, .. } = event
219+
failure: PathFailure::OnPath { network_update: Some(ref upd) }, .. } = event
220220
{
221221
network_graph.handle_network_update(upd);
222222
}
@@ -673,7 +673,7 @@ mod tests {
673673
use lightning::routing::router::{DefaultRouter, RouteHop};
674674
use lightning::routing::scoring::{ChannelUsage, Score};
675675
use lightning::util::config::UserConfig;
676-
use lightning::util::events::{Event, Failure, MessageSendEventsProvider, MessageSendEvent};
676+
use lightning::util::events::{Event, PathFailure, MessageSendEventsProvider, MessageSendEvent};
677677
use lightning::util::ser::Writeable;
678678
use lightning::util::test_utils;
679679
use lightning::util::persist::KVStorePersister;
@@ -1365,7 +1365,7 @@ mod tests {
13651365
payment_id: None,
13661366
payment_hash: PaymentHash([42; 32]),
13671367
payment_failed_permanently: false,
1368-
failure: Failure::OnPath { network_update: None },
1368+
failure: PathFailure::OnPath { network_update: None },
13691369
path: path.clone(),
13701370
short_channel_id: Some(scored_scid),
13711371
retry: None,
@@ -1385,7 +1385,7 @@ mod tests {
13851385
payment_id: None,
13861386
payment_hash: PaymentHash([42; 32]),
13871387
payment_failed_permanently: true,
1388-
failure: Failure::OnPath { network_update: None },
1388+
failure: PathFailure::OnPath { network_update: None },
13891389
path: path.clone(),
13901390
short_channel_id: None,
13911391
retry: None,

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::util::enforcing_trait_impls::EnforcingSigner;
2424
use crate::util::scid_utils;
2525
use crate::util::test_utils;
2626
use crate::util::test_utils::{panicking, TestChainMonitor};
27-
use crate::util::events::{Event, Failure, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose};
27+
use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose};
2828
use crate::util::errors::APIError;
2929
use crate::util::config::UserConfig;
3030
use crate::util::ser::{ReadableArgs, Writeable};
@@ -1843,7 +1843,7 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
18431843
}
18441844

18451845
if let Some(chan_closed) = conditions.expected_blamed_chan_closed {
1846-
if let Failure::OnPath { network_update: Some(upd) } = failure {
1846+
if let PathFailure::OnPath { network_update: Some(upd) } = failure {
18471847
match upd {
18481848
NetworkUpdate::ChannelUpdateMessage { ref msg } if !chan_closed => {
18491849
if let Some(scid) = conditions.expected_blamed_scid {

lightning/src/ln/functional_tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::ln::msgs;
3131
use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
3232
use crate::util::enforcing_trait_impls::EnforcingSigner;
3333
use crate::util::test_utils;
34-
use crate::util::events::{Event, Failure, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose, ClosureReason, HTLCDestination};
34+
use crate::util::events::{Event, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination};
3535
use crate::util::errors::APIError;
3636
use crate::util::ser::{Writeable, ReadableArgs};
3737
use crate::util::config::UserConfig;
@@ -3240,7 +3240,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
32403240
// If we delivered B's RAA we got an unknown preimage error, not something
32413241
// that we should update our routing table for.
32423242
if !deliver_bs_raa {
3243-
if let Failure::OnPath { network_update: Some(_) } = failure { } else { panic!("Unexpected path failure") }
3243+
if let PathFailure::OnPath { network_update: Some(_) } = failure { } else { panic!("Unexpected path failure") }
32443244
}
32453245
},
32463246
_ => panic!("Unexpected event"),
@@ -3252,7 +3252,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
32523252
_ => panic!("Unexpected event"),
32533253
}
32543254
match events[2] {
3255-
Event::PaymentPathFailed { ref payment_hash, failure: Failure::OnPath { network_update: Some(_) }, .. } => {
3255+
Event::PaymentPathFailed { ref payment_hash, failure: PathFailure::OnPath { network_update: Some(_) }, .. } => {
32563256
assert!(failed_htlcs.insert(payment_hash.0));
32573257
},
32583258
_ => panic!("Unexpected event"),
@@ -3264,7 +3264,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
32643264
_ => panic!("Unexpected event"),
32653265
}
32663266
match events[4] {
3267-
Event::PaymentPathFailed { ref payment_hash, failure: Failure::OnPath { network_update: Some(_) }, .. } => {
3267+
Event::PaymentPathFailed { ref payment_hash, failure: PathFailure::OnPath { network_update: Some(_) }, .. } => {
32683268
assert!(failed_htlcs.insert(payment_hash.0));
32693269
},
32703270
_ => panic!("Unexpected event"),
@@ -5153,7 +5153,7 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
51535153
} else {
51545154
assert!(!payment_failed_permanently);
51555155
}
5156-
if let Failure::OnPath { network_update: Some(_) } = failure {
5156+
if let PathFailure::OnPath { network_update: Some(_) } = failure {
51575157
as_updates += 1;
51585158
}
51595159
} else if let &Event::PaymentFailed { .. } = event {
@@ -5179,7 +5179,7 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
51795179
} else {
51805180
assert!(!payment_failed_permanently);
51815181
}
5182-
if let Failure::OnPath { network_update: Some(_) } = failure {
5182+
if let PathFailure::OnPath { network_update: Some(_) } = failure {
51835183
bs_updates += 1;
51845184
}
51855185
} else if let &Event::PaymentFailed { .. } = event {
@@ -5693,7 +5693,7 @@ fn test_fail_holding_cell_htlc_upon_free() {
56935693
let events = nodes[0].node.get_and_clear_pending_events();
56945694
assert_eq!(events.len(), 2);
56955695
match &events[0] {
5696-
&Event::PaymentPathFailed { ref payment_id, ref payment_hash, ref payment_failed_permanently, failure: Failure::OnPath { network_update: None }, ref short_channel_id, .. } => {
5696+
&Event::PaymentPathFailed { ref payment_id, ref payment_hash, ref payment_failed_permanently, failure: PathFailure::OnPath { network_update: None }, ref short_channel_id, .. } => {
56975697
assert_eq!(PaymentId(our_payment_hash.0), *payment_id.as_ref().unwrap());
56985698
assert_eq!(our_payment_hash.clone(), *payment_hash);
56995699
assert_eq!(*payment_failed_permanently, false);
@@ -5782,7 +5782,7 @@ fn test_free_and_fail_holding_cell_htlcs() {
57825782
let events = nodes[0].node.get_and_clear_pending_events();
57835783
assert_eq!(events.len(), 2);
57845784
match &events[0] {
5785-
&Event::PaymentPathFailed { ref payment_id, ref payment_hash, ref payment_failed_permanently, failure: Failure::OnPath { network_update: None }, ref short_channel_id, .. } => {
5785+
&Event::PaymentPathFailed { ref payment_id, ref payment_hash, ref payment_failed_permanently, failure: PathFailure::OnPath { network_update: None }, ref short_channel_id, .. } => {
57865786
assert_eq!(payment_id_2, *payment_id.as_ref().unwrap());
57875787
assert_eq!(payment_hash_2.clone(), *payment_hash);
57885788
assert_eq!(*payment_failed_permanently, false);
@@ -6683,7 +6683,7 @@ fn test_channel_failed_after_message_with_badonion_node_perm_bits_set() {
66836683
// Expect a PaymentPathFailed event with a ChannelFailure network update for the channel between
66846684
// the node originating the error to its next hop.
66856685
match events_5[0] {
6686-
Event::PaymentPathFailed { error_code, failure: Failure::OnPath { network_update: Some(NetworkUpdate::ChannelFailure { short_channel_id, is_permanent }) }, ..
6686+
Event::PaymentPathFailed { error_code, failure: PathFailure::OnPath { network_update: Some(NetworkUpdate::ChannelFailure { short_channel_id, is_permanent }) }, ..
66876687
} => {
66886688
assert_eq!(short_channel_id, chan_2.0.contents.short_channel_id);
66896689
assert!(is_permanent);

lightning/src/ln/onion_route_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::ln::features::{InitFeatures, InvoiceFeatures};
2323
use crate::ln::msgs;
2424
use crate::ln::msgs::{ChannelMessageHandler, ChannelUpdate};
2525
use crate::ln::wire::Encode;
26-
use crate::util::events::{Event, Failure, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
26+
use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure};
2727
use crate::util::ser::{Writeable, Writer};
2828
use crate::util::test_utils;
2929
use crate::util::config::{UserConfig, ChannelConfig};
@@ -167,7 +167,7 @@ fn run_onion_failure_test_with_fail_intercept<F1,F2,F3>(_name: &str, test_case:
167167

168168
let events = nodes[0].node.get_and_clear_pending_events();
169169
assert_eq!(events.len(), 2);
170-
if let &Event::PaymentPathFailed { ref payment_failed_permanently, ref short_channel_id, ref error_code, failure: Failure::OnPath { ref network_update }, .. } = &events[0] {
170+
if let &Event::PaymentPathFailed { ref payment_failed_permanently, ref short_channel_id, ref error_code, failure: PathFailure::OnPath { ref network_update }, .. } = &events[0] {
171171
assert_eq!(*payment_failed_permanently, !expected_retryable);
172172
assert_eq!(*error_code, expected_error_code);
173173
if expected_channel_update.is_some() {

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl OutboundPayments {
793793
payment_id: Some(payment_id),
794794
payment_hash,
795795
payment_failed_permanently: false,
796-
failure: events::Failure::InitialSend { err: e },
796+
failure: events::PathFailure::InitialSend { err: e },
797797
path,
798798
short_channel_id: failed_scid,
799799
retry: None,
@@ -1255,7 +1255,7 @@ impl OutboundPayments {
12551255
payment_id: Some(*payment_id),
12561256
payment_hash: payment_hash.clone(),
12571257
payment_failed_permanently: !payment_retryable,
1258-
failure: events::Failure::OnPath { network_update },
1258+
failure: events::PathFailure::OnPath { network_update },
12591259
path: path.clone(),
12601260
short_channel_id,
12611261
retry,

lightning/src/ln/payment_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::ln::outbound_payment::Retry;
2424
use crate::routing::gossip::{EffectiveCapacity, RoutingFees};
2525
use crate::routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RouteParameters};
2626
use crate::routing::scoring::ChannelUsage;
27-
use crate::util::events::{ClosureReason, Event, Failure, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
27+
use crate::util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure};
2828
use crate::util::test_utils;
2929
use crate::util::errors::APIError;
3030
use crate::util::ser::Writeable;
@@ -2139,7 +2139,7 @@ fn retry_multi_path_single_failed_payment() {
21392139
assert_eq!(events.len(), 1);
21402140
match events[0] {
21412141
Event::PaymentPathFailed { payment_hash: ev_payment_hash, payment_failed_permanently: false,
2142-
failure: Failure::InitialSend { err: APIError::ChannelUnavailable { err: ref err_msg }},
2142+
failure: PathFailure::InitialSend { err: APIError::ChannelUnavailable { err: ref err_msg }},
21432143
short_channel_id: Some(expected_scid), .. } =>
21442144
{
21452145
assert_eq!(payment_hash, ev_payment_hash);
@@ -2215,7 +2215,7 @@ fn immediate_retry_on_failure() {
22152215
assert_eq!(events.len(), 1);
22162216
match events[0] {
22172217
Event::PaymentPathFailed { payment_hash: ev_payment_hash, payment_failed_permanently: false,
2218-
failure: Failure::InitialSend { err: APIError::ChannelUnavailable { err: ref err_msg }},
2218+
failure: PathFailure::InitialSend { err: APIError::ChannelUnavailable { err: ref err_msg }},
22192219
short_channel_id: Some(expected_scid), .. } =>
22202220
{
22212221
assert_eq!(payment_hash, ev_payment_hash);

lightning/src/util/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl_writeable_tlv_based_enum!(PaymentPurpose,
8888
/// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
8989
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
9090
#[derive(Clone, Debug, Eq, PartialEq)]
91-
pub enum Failure {
91+
pub enum PathFailure {
9292
/// We failed to initially send the payment and no HTLC was committed to. Contains the relevant
9393
/// error.
9494
InitialSend {
@@ -106,7 +106,7 @@ pub enum Failure {
106106
},
107107
}
108108

109-
impl_writeable_tlv_based_enum_upgradable!(Failure,
109+
impl_writeable_tlv_based_enum_upgradable!(PathFailure,
110110
(0, OnPath) => {
111111
(0, network_update, upgradable_option),
112112
},
@@ -689,7 +689,7 @@ pub enum Event {
689689
/// applied to the [`NetworkGraph`].
690690
///
691691
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
692-
failure: Failure,
692+
failure: PathFailure,
693693
/// The payment path that failed.
694694
path: Vec<RouteHop>,
695695
/// The channel responsible for the failed payment path.
@@ -1240,7 +1240,7 @@ impl MaybeReadable for Event {
12401240
(11, payment_id, option),
12411241
(13, failure_opt, upgradable_option),
12421242
});
1243-
let failure = failure_opt.unwrap_or_else(|| Failure::OnPath { network_update });
1243+
let failure = failure_opt.unwrap_or_else(|| PathFailure::OnPath { network_update });
12441244
Ok(Some(Event::PaymentPathFailed {
12451245
payment_id,
12461246
payment_hash,

0 commit comments

Comments
 (0)