Skip to content

Commit 720519c

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 5323e73 commit 720519c

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 update_res = self.persister.persist_new_channel(funding_outpoint, &monitor);
376+
if update_res.is_err() {
377+
log_error!(self.logger, "Failed to persist new channel data: {:?}", update_res);
378+
}
379+
if update_res == Err(ChannelMonitorUpdateErr::PermanentFailure) {
380+
return update_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+
update_res
389392
}
390393

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

0 commit comments

Comments
 (0)