Skip to content

Commit eb187e3

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 76b4ef8 commit eb187e3

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
@@ -367,9 +367,12 @@ where C::Target: chain::Filter,
367367
return Err(ChannelMonitorUpdateErr::PermanentFailure)},
368368
hash_map::Entry::Vacant(e) => e,
369369
};
370-
if let Err(e) = self.persister.persist_new_channel(funding_outpoint, &monitor) {
371-
log_error!(self.logger, "Failed to persist new channel data");
372-
return Err(e);
370+
let update_res = self.persister.persist_new_channel(funding_outpoint, &monitor);
371+
if update_res.is_err() {
372+
log_error!(self.logger, "Failed to persist new channel data: {:?}", update_res);
373+
}
374+
if update_res == Err(ChannelMonitorUpdateErr::PermanentFailure) {
375+
return update_res;
373376
}
374377
{
375378
let funding_txo = monitor.get_funding_txo();
@@ -380,7 +383,7 @@ where C::Target: chain::Filter,
380383
}
381384
}
382385
entry.insert(MonitorHolder { monitor });
383-
Ok(())
386+
update_res
384387
}
385388

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

0 commit comments

Comments
 (0)