From 729e5cf907c7b10ffa735ea7a1d861df031404a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoe=20Faltib=C3=A0?= Date: Tue, 27 Aug 2024 08:37:29 +0200 Subject: [PATCH] improve peer info: avoid writing empty lines --- src/disk.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/disk.rs b/src/disk.rs index 3b142e4..73ac2cb 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -91,7 +91,7 @@ pub(crate) fn persist_channel_peer( }; let mut tmp_path = path.to_path_buf(); tmp_path.set_extension("ptmp"); - fs::write(&tmp_path, format!("{}\n", peer_info).as_bytes())?; + fs::write(&tmp_path, peer_info.to_string().as_bytes())?; fs::rename(tmp_path, path)?; tracing::info!("persisted peer (pubkey: {pubkey}, addr: {address})"); Ok(()) @@ -106,7 +106,7 @@ pub(crate) fn delete_channel_peer(path: &Path, pubkey: String) -> Result<(), API .join("\n"); let mut tmp_path = path.to_path_buf(); tmp_path.set_extension("dtmp"); - fs::write(&tmp_path, format!("{}\n", updated_peer_info).as_bytes())?; + fs::write(&tmp_path, updated_peer_info.to_string().as_bytes())?; fs::rename(tmp_path, path)?; } Ok(())