From 3cf254cd9e59a41b59d23d318273e922473bb66b Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 20 Dec 2023 23:37:28 +0200 Subject: [PATCH] Import locking fix from upstream --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/backend/farmer.rs | 39 ++++++++++++--------------------------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8dd491f1..d9337eea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10580,7 +10580,7 @@ dependencies = [ [[package]] name = "space-acres" -version = "0.0.10" +version = "0.0.11" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 3378ee13..cc0659f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "space-acres" description = "Space Acres is an opinionated unofficial GUI application for farming on Subspace Network" license = "0BSD" -version = "0.0.10" +version = "0.0.11" authors = ["Nazar Mokrynskyi "] repository = "https://github.com/nazar-pc/space-acres" edition = "2021" diff --git a/src/backend/farmer.rs b/src/backend/farmer.rs index 2d97d2ba..a73b12fd 100644 --- a/src/backend/farmer.rs +++ b/src/backend/farmer.rs @@ -22,7 +22,7 @@ use subspace_core_primitives::{PublicKey, Record, SectorIndex}; use subspace_erasure_coding::ErasureCoding; use subspace_farmer::piece_cache::{CacheWorker, PieceCache}; use subspace_farmer::single_disk_farm::{ - SingleDiskFarm, SingleDiskFarmError, SingleDiskFarmOptions, SingleDiskFarmSummary, + SingleDiskFarm, SingleDiskFarmError, SingleDiskFarmOptions, }; use subspace_farmer::utils::farmer_piece_getter::FarmerPieceGetter; use subspace_farmer::utils::piece_validator::SegmentCommitmentPieceValidator; @@ -300,7 +300,17 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu } }; - print_disk_farm_info(disk_farm.directory, disk_farm_index); + let info = single_disk_farm.info(); + println!("Single disk farm {disk_farm_index}:"); + println!(" ID: {}", info.id()); + println!(" Genesis hash: 0x{}", hex::encode(info.genesis_hash())); + println!(" Public key: 0x{}", hex::encode(info.public_key())); + println!( + " Allocated space: {} ({})", + bytesize::to_string(info.allocated_space(), true), + bytesize::to_string(info.allocated_space(), false) + ); + println!(" Directory: {}", disk_farm.directory.display()); single_disk_farms.push(single_disk_farm); } @@ -506,28 +516,3 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu handlers, }) } - -fn print_disk_farm_info(directory: PathBuf, disk_farm_index: usize) { - println!("Single disk farm {disk_farm_index}:"); - match SingleDiskFarm::collect_summary(directory) { - SingleDiskFarmSummary::Found { info, directory } => { - println!(" ID: {}", info.id()); - println!(" Genesis hash: 0x{}", hex::encode(info.genesis_hash())); - println!(" Public key: 0x{}", hex::encode(info.public_key())); - println!( - " Allocated space: {} ({})", - bytesize::to_string(info.allocated_space(), true), - bytesize::to_string(info.allocated_space(), false) - ); - println!(" Directory: {}", directory.display()); - } - SingleDiskFarmSummary::NotFound { directory } => { - println!(" Plot directory: {}", directory.display()); - println!(" No farm found here yet"); - } - SingleDiskFarmSummary::Error { directory, error } => { - println!(" Directory: {}", directory.display()); - println!(" Failed to open farm info: {error}"); - } - } -}