Avoid retrying over recently failed channels
[rust-lightning] / lightning-persister / src / lib.rs
index a5cbe2f9213e315401be9c0a8bfcc018f7c72a78..ef914700a16302c0e5dacad1414d3e0e8c1eb03c 100644 (file)
@@ -124,6 +124,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() {