diff --git a/finality-aleph/src/party/backup.rs b/finality-aleph/src/party/backup.rs index f1bb9584d3..4184bdf270 100644 --- a/finality-aleph/src/party/backup.rs +++ b/finality-aleph/src/party/backup.rs @@ -1,14 +1,13 @@ use std::{ fmt, fs, fs::File, - io, - io::{Cursor, Read, Write}, + io::{Error as IoError, Read, Result as IoResult}, path::{Path, PathBuf}, pin::Pin, str::FromStr, }; -use futures::io::{AllowStdIo, AsyncRead, AsyncWrite}; +use futures::io::{empty, sink, AllowStdIo, AsyncRead, AsyncWrite, Cursor}; use log::debug; const BACKUP_FILE_EXTENSION: &str = ".abfts"; @@ -16,7 +15,7 @@ const BACKUP_FILE_EXTENSION: &str = ".abfts"; #[derive(Debug)] pub enum BackupLoadError { BackupIncomplete(Vec), - IOError(io::Error), + IOError(IoError), } impl fmt::Display for BackupLoadError { @@ -35,25 +34,16 @@ impl fmt::Display for BackupLoadError { } } -impl From for BackupLoadError { - fn from(err: io::Error) -> Self { +impl From for BackupLoadError { + fn from(err: IoError) -> Self { Self::IOError(err) } } impl std::error::Error for BackupLoadError {} -// Both the `Both` traits are only necessary for backwards compatibility with old ABFT. -// TODO(A0-4271): Remove these when removing support for ABFT 0.33 and -// check whether the implementations should also be replaced with purely async ones. -pub trait BothRead: Read + AsyncRead {} -impl BothRead for T {} - -pub trait BothWrite: Write + AsyncWrite {} -impl BothWrite for T {} - -pub type Saver = Pin>; -pub type Loader = Pin>; +pub type Saver = Pin>; +pub type Loader = Pin>; pub type ABFTBackup = (Saver, Loader); /// Find all `*.abfts` files at `session_path` and return their indexes sorted, if all are present. @@ -78,7 +68,7 @@ fn load_backup(session_path: &Path, session_idxs: &[usize]) -> Result, current_session: u32) -> io::Result<()> { +pub fn remove_old_backups(path: Option, current_session: u32) -> IoResult<()> { if let Some(path) = path { if !path.exists() { return Ok(());