Skip to content

Commit

Permalink
improve peer info: avoid writing empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Aug 27, 2024
1 parent f196bd8 commit 729e5cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand All @@ -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(())
Expand Down

0 comments on commit 729e5cf

Please sign in to comment.