Skip to content

Commit 3966e82

Browse files
committed
Handle Persister returning TemporaryFailure for new channels
Previously, if a Persister returned a TemporaryFailure error when we tried to persist a new channel, the ChainMonitor wouldn't track the new ChannelMonitor at all, generating a PermanentFailure later when the updating is restored. This fixes that by correctly storing the ChannelMonitor on TemporaryFailures, allowing later update restoration to happen normally. This is (indirectly) tested in the next commit where we use Persister to return all monitor-update errors.
1 parent 5dbf644 commit 3966e82

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,12 @@ where C::Target: chain::Filter,
373373
return Err(ChannelMonitorUpdateErr::PermanentFailure)},
374374
hash_map::Entry::Vacant(e) => e,
375375
};
376-
if let Err(e) = self.persister.persist_new_channel(funding_outpoint, &monitor) {
377-
log_error!(self.logger, "Failed to persist new channel data");
378-
return Err(e);
376+
let update_res = self.persister.persist_new_channel(funding_outpoint, &monitor);
377+
if update_res.is_err() {
378+
log_error!(self.logger, "Failed to persist new channel data: {:?}", update_res);
379+
}
380+
if update_res == Err(ChannelMonitorUpdateErr::PermanentFailure) {
381+
return update_res;
379382
}
380383
{
381384
let funding_txo = monitor.get_funding_txo();
@@ -386,7 +389,7 @@ where C::Target: chain::Filter,
386389
}
387390
}
388391
entry.insert(MonitorHolder { monitor });
389-
Ok(())
392+
update_res
390393
}
391394

392395
/// Note that we persist the given `ChannelMonitor` update while holding the

0 commit comments

Comments
 (0)