Merge pull request #1332 from TheBlueMatt/2022-02-persister-ignore-tmp
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Sat, 26 Feb 2022 01:30:29 +0000 (01:30 +0000)
committerGitHub <noreply@github.com>
Sat, 26 Feb 2022 01:30:29 +0000 (01:30 +0000)
Ignore .tmp files when loading ChannelMonitors in persister

lightning-persister/src/lib.rs

index 558f4b8fe3cee9d56b75b2230f203ccca6608e9c..b8212f0fc705b3bac8e6925df3f0a1deb375116b 100644 (file)
@@ -122,6 +122,12 @@ impl FilesystemPersister {
                                        "Invalid ChannelMonitor file name",
                                ));
                        }
+                       if filename.unwrap().ends_with(".tmp") {
+                               // If we were in the middle of committing an new update and crashed, it should be
+                               // safe to ignore the update - we should never have returned to the caller and
+                               // irrevocably committed to the new state in any way.
+                               continue;
+                       }
 
                        let txid = Txid::from_hex(filename.unwrap().split_at(64).0);
                        if txid.is_err() {