Skip to content

Commit 65fcf57

Browse files
committed
f clarify error messages
1 parent 6bb4c53 commit 65fcf57

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl Readable for ChannelMonitorUpdate {
114114
}
115115

116116
/// An error enum representing a failure to persist a channel monitor update.
117-
#[derive(Clone, Debug)]
117+
#[derive(Clone, Copy, Debug, PartialEq)]
118118
pub enum ChannelMonitorUpdateErr {
119119
/// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
120120
/// our state failed, but is expected to succeed at some point in the future).

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEv
5757
use util::{byte_utils, events};
5858
use util::ser::{Readable, ReadableArgs, MaybeReadable, Writeable, Writer};
5959
use util::chacha20::{ChaCha20, ChaChaReader};
60-
use util::logger::Logger;
60+
use util::logger::{Logger, Level};
6161
use util::errors::APIError;
6262

6363
use prelude::*;
@@ -2683,6 +2683,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
26832683
Ok(msgs_monitor_option) => {
26842684
if let UpdateFulfillCommitFetch::NewClaim { msgs, monitor_update } = msgs_monitor_option {
26852685
if let Err(e) = self.chain_monitor.update_channel(chan.get().get_funding_txo().unwrap(), monitor_update) {
2686+
log_given_level!(self.logger, if e == ChannelMonitorUpdateErr::PermanentFailure { Level::Error } else { Level::Debug },
2687+
"Failed to update channel monitor with preimage {:?}: {:?}",
2688+
payment_preimage, e);
26862689
return Err(Some((
26872690
chan.get().get_counterparty_node_id(),
26882691
handle_monitor_err!(self, e, channel_state, chan, RAACommitmentOrder::CommitmentFirst, false, msgs.is_some()).unwrap_err(),
@@ -2708,7 +2711,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
27082711
},
27092712
Err((e, monitor_update)) => {
27102713
if let Err(e) = self.chain_monitor.update_channel(chan.get().get_funding_txo().unwrap(), monitor_update) {
2711-
log_error!(self.logger, "Critical error: failed to update channel monitor with preimage {:?}: {:?}",
2714+
log_given_level!(self.logger, if e == ChannelMonitorUpdateErr::PermanentFailure { Level::Error } else { Level::Info },
2715+
"Failed to update channel monitor with preimage {:?} immediately prior to force-close: {:?}",
27122716
payment_preimage, e);
27132717
}
27142718
let counterparty_node_id = chan.get().get_counterparty_node_id();

0 commit comments

Comments
 (0)