Skip to content

Commit d902289

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 482c13a commit d902289

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
@@ -372,9 +372,12 @@ where C::Target: chain::Filter,
372372
return Err(ChannelMonitorUpdateErr::PermanentFailure)},
373373
hash_map::Entry::Vacant(e) => e,
374374
};
375-
if let Err(e) = self.persister.persist_new_channel(funding_outpoint, &monitor) {
376-
log_error!(self.logger, "Failed to persist new channel data");
377-
return Err(e);
375+
let persist_res = self.persister.persist_new_channel(funding_outpoint, &monitor);
376+
if persist_res.is_err() {
377+
log_error!(self.logger, "Failed to persist new channel data: {:?}", persist_res);
378+
}
379+
if persist_res == Err(ChannelMonitorUpdateErr::PermanentFailure) {
380+
return persist_res;
378381
}
379382
{
380383
let funding_txo = monitor.get_funding_txo();
@@ -385,7 +388,7 @@ where C::Target: chain::Filter,
385388
}
386389
}
387390
entry.insert(MonitorHolder { monitor });
388-
Ok(())
391+
persist_res
389392
}
390393

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

0 commit comments

Comments
 (0)