Account for leftover fee budget when retrying via `check_retry_payment`
[rust-lightning] / lightning-persister / src / fs_store.rs
index 638e74e650607f09bb806b4776777a5ad3a954eb..81f9709c45467d4e6725ef83f11ba10a33734b68 100644 (file)
@@ -26,7 +26,7 @@ macro_rules! call {
 }
 
 #[cfg(target_os = "windows")]
-fn path_to_windows_str<T: AsRef<OsStr>>(path: T) -> Vec<u16> {
+fn path_to_windows_str<T: AsRef<OsStr>>(path: &T) -> Vec<u16> {
        path.as_ref().encode_wide().chain(Some(0)).collect()
 }
 
@@ -164,8 +164,8 @@ impl KVStore for FilesystemStore {
                                let res = if dest_file_path.exists() {
                                        call!(unsafe {
                                                windows_sys::Win32::Storage::FileSystem::ReplaceFileW(
-                                                       path_to_windows_str(dest_file_path.clone()).as_ptr(),
-                                                       path_to_windows_str(tmp_file_path).as_ptr(),
+                                                       path_to_windows_str(&dest_file_path).as_ptr(),
+                                                       path_to_windows_str(&tmp_file_path).as_ptr(),
                                                        std::ptr::null(),
                                                        windows_sys::Win32::Storage::FileSystem::REPLACEFILE_IGNORE_MERGE_ERRORS,
                                                        std::ptr::null_mut() as *const core::ffi::c_void,
@@ -175,8 +175,8 @@ impl KVStore for FilesystemStore {
                                } else {
                                        call!(unsafe {
                                                windows_sys::Win32::Storage::FileSystem::MoveFileExW(
-                                                       path_to_windows_str(tmp_file_path).as_ptr(),
-                                                       path_to_windows_str(dest_file_path.clone()).as_ptr(),
+                                                       path_to_windows_str(&tmp_file_path).as_ptr(),
+                                                       path_to_windows_str(&dest_file_path).as_ptr(),
                                                        windows_sys::Win32::Storage::FileSystem::MOVEFILE_WRITE_THROUGH
                                                        | windows_sys::Win32::Storage::FileSystem::MOVEFILE_REPLACE_EXISTING,
                                                        )
@@ -263,8 +263,8 @@ impl KVStore for FilesystemStore {
 
                                        call!(unsafe {
                                                windows_sys::Win32::Storage::FileSystem::MoveFileExW(
-                                                       path_to_windows_str(dest_file_path).as_ptr(),
-                                                       path_to_windows_str(trash_file_path.clone()).as_ptr(),
+                                                       path_to_windows_str(&dest_file_path).as_ptr(),
+                                                       path_to_windows_str(&trash_file_path).as_ptr(),
                                                        windows_sys::Win32::Storage::FileSystem::MOVEFILE_WRITE_THROUGH
                                                        | windows_sys::Win32::Storage::FileSystem::MOVEFILE_REPLACE_EXISTING,
                                                        )
@@ -515,3 +515,17 @@ mod tests {
                added_monitors.clear();
        }
 }
+
+#[cfg(ldk_bench)]
+/// Benches
+pub mod bench {
+       use criterion::Criterion;
+
+       /// Bench!
+       pub fn bench_sends(bench: &mut Criterion) {
+               let store_a = super::FilesystemStore::new("bench_filesystem_store_a".into());
+               let store_b = super::FilesystemStore::new("bench_filesystem_store_b".into());
+               lightning::ln::channelmanager::bench::bench_two_sends(
+                       bench, "bench_filesystem_persisted_sends", store_a, store_b);
+       }
+}