Skip to content

Commit

Permalink
Merge pull request #113 from nazar-pc/fix-farming-message
Browse files Browse the repository at this point in the history
Remove `farm_during_initial_plotting` workaround, make "farming" message depend on node sync state
  • Loading branch information
nazar-pc authored Feb 4, 2024
2 parents 9969db3 + 3d7210d commit 9645080
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/backend/farmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,7 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu

let mut single_disk_farms = Vec::with_capacity(disk_farms.len());

// TODO: Restore normal value once incentivization starts on 3h
let farm_during_initial_plotting = if false {
false
} else {
should_farm_during_initial_plotting()
};
let farm_during_initial_plotting = should_farm_during_initial_plotting();
let mut plotting_thread_pool_core_indices = thread_pool_core_indices(None, None);
let mut replotting_thread_pool_core_indices = {
let mut replotting_thread_pool_core_indices = thread_pool_core_indices(None, None);
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ impl RunningView {

match node_notification {
NodeNotification::SyncStateUpdate(sync_state) => {
self.node_synced = sync_state.is_synced();
let new_synced = sync_state.is_synced();
if self.node_synced != new_synced {
self.farms
.broadcast(FarmWidgetInput::NodeSynced(new_synced));
}
self.node_synced = new_synced;
}
NodeNotification::BlockImported(imported_block) => {
if !self.node_synced {
Expand Down
14 changes: 13 additions & 1 deletion src/frontend/running/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub(super) enum FarmWidgetInput {
},
FarmingNotification(FarmingNotification),
PieceCacheSynced(bool),
NodeSynced(bool),
}

#[derive(Debug)]
Expand All @@ -101,6 +102,7 @@ pub(super) struct FarmWidget {
last_sector_plotted: Option<SectorIndex>,
plotting_state: PlottingState,
is_piece_cache_synced: bool,
is_node_synced: bool,
farm_during_initial_plotting: bool,
sectors_grid: gtk::GridView,
sectors: HashMap<SectorIndex, gtk::Box>,
Expand Down Expand Up @@ -240,10 +242,16 @@ impl FactoryComponent for FarmWidget {
match kind {
PlottingKind::Initial => {
if self.farm_during_initial_plotting {
let farming = if self.is_node_synced {
"farming"
} else {
"not farming"
};
format!(
"Initial plotting {:.2}%{}, farming",
"Initial plotting {:.2}%{}, {}",
progress,
plotting_speed,
farming
)
} else {
format!(
Expand Down Expand Up @@ -333,6 +341,7 @@ impl FactoryComponent for FarmWidget {
last_sector_plotted: None,
plotting_state: PlottingState::Idle,
is_piece_cache_synced: false,
is_node_synced: false,
farm_during_initial_plotting: init.farm_during_initial_plotting,
sectors_grid,
sectors: HashMap::from_iter((SectorIndex::MIN..).zip(sectors)),
Expand Down Expand Up @@ -427,6 +436,9 @@ impl FarmWidget {
FarmWidgetInput::PieceCacheSynced(synced) => {
self.is_piece_cache_synced = synced;
}
FarmWidgetInput::NodeSynced(synced) => {
self.is_node_synced = synced;
}
}
}

Expand Down

0 comments on commit 9645080

Please sign in to comment.