Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanLabGit committed Feb 13, 2024
1 parent 975a364 commit 8399aae
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use subspace_erasure_coding::ErasureCoding;
use subspace_farmer::piece_cache::PieceCache;
use subspace_farmer::single_disk_farm::farming::FarmingNotification;
use subspace_farmer::single_disk_farm::{
SectorPlottingDetails, SectorUpdate, SingleDiskFarm, SingleDiskFarmError, SingleDiskFarmOptions,
SectorPlottingDetails, SectorExpirationDetails, SectorUpdate, SingleDiskFarm, SingleDiskFarmError, SingleDiskFarmOptions,
};
use subspace_farmer::utils::farmer_piece_getter::FarmerPieceGetter;
use subspace_farmer::utils::piece_validator::SegmentCommitmentPieceValidator;
Expand Down Expand Up @@ -664,6 +664,11 @@ where

info!("Finished collecting already plotted pieces successfully");

for (_, single_disk_farm) in single_disk_farms.iter().enumerate() {
farmer_metrics.update_farm_size(single_disk_farm.id(), single_disk_farm.total_sectors_count() as i64);
farmer_metrics.update_farm_plotted(single_disk_farm.id(), single_disk_farm.plotted_sectors_count().await as u64);
}

let mut single_disk_farms_stream = single_disk_farms
.into_iter()
.enumerate()
Expand Down Expand Up @@ -699,15 +704,7 @@ where
let farmer_metrics = farmer_metrics.clone();

move |(_sector_index, sector_state)| match sector_state {
SectorUpdate::Plotting(SectorPlottingDetails::Starting {
progress,
last_queued, ..
}) => {
if *last_queued {
farmer_metrics.update_sector_progress(&single_disk_farm_id, 100.0);
} else {
farmer_metrics.update_sector_progress(&single_disk_farm_id, *progress);
};
SectorUpdate::Plotting(SectorPlottingDetails::Starting { .. }) => {
farmer_metrics.sector_plotting.inc();
}
SectorUpdate::Plotting(SectorPlottingDetails::Downloading) => {
Expand Down Expand Up @@ -740,6 +737,17 @@ where
on_plotted_sector_callback(plotted_sector, old_plotted_sector);
farmer_metrics.observe_sector_plotting_time(&single_disk_farm_id, time);
farmer_metrics.sector_plotted.inc();
if let Some(_) = &old_plotted_sector {
farmer_metrics.update_farm_replotted(&single_disk_farm_id, 1);
} else {
farmer_metrics.update_farm_plotted(&single_disk_farm_id, 1);
}
}
SectorUpdate::Expiration(SectorExpirationDetails::AboutToExpire) => {
farmer_metrics.update_farm_expired(&single_disk_farm_id, 1);
}
SectorUpdate::Expiration(SectorExpirationDetails::Expired) => {
farmer_metrics.update_farm_expired(&single_disk_farm_id, 1);
}
_ => {}
}
Expand Down Expand Up @@ -838,4 +846,4 @@ fn derive_libp2p_keypair(schnorrkel_sk: &schnorrkel::SecretKey) -> Keypair {
);

Keypair::from(keypair)
}
}

0 comments on commit 8399aae

Please sign in to comment.