Skip to content

Commit a2a90ee

Browse files
committed
Ignore .tmp files when loading ChannelMonitors in persister
If we are in the middle of persisting an update to a `ChannelMonitor` when we shutdown (or crash), we'll start up with a .tmp file lying around. We should ignore it, as failure to return from the update call should have prevented the `ChannelManager` from taking any irrevocable action based on the update. We're somewhat protected from any filesystem inconsistency behavior as the `ChannelManager` will refuse to load if we're outright missing `ChannelMonitor`s. Fixes #1330.
1 parent e43cfe1 commit a2a90ee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning-persister/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ impl FilesystemPersister {
122122
"Invalid ChannelMonitor file name",
123123
));
124124
}
125+
if filename.unwrap().ends_with(".tmp") {
126+
// If we were in the middle of committing an new update and crashed, it should be
127+
// safe to ignore the update - we should never have returned to the caller and
128+
// irrevocably committed to the new state in any way.
129+
continue;
130+
}
125131

126132
let txid = Txid::from_hex(filename.unwrap().split_at(64).0);
127133
if txid.is_err() {

0 commit comments

Comments
 (0)