Skip to content

Commit

Permalink
Merge pull request #88 from nazar-pc/sectors-visualization
Browse files Browse the repository at this point in the history
Sectors visualization
  • Loading branch information
nazar-pc authored Jan 23, 2024
2 parents 0b9b1a3 + 8e7d5f2 commit dfb4031
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 352 deletions.
84 changes: 42 additions & 42 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.17"
version = "0.0.18"
authors = ["Nazar Mokrynskyi <nazar@mokrynskyi.com>"]
repository = "https://github.com/nazar-pc/space-acres"
edition = "2021"
Expand Down Expand Up @@ -52,9 +52,9 @@ names = "0.14.0"
pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
parity-scale-codec = "3.6.9"
parking_lot = "0.12.1"
relm4 = { version = "0.7.0-beta.2", git = "https://github.com/Relm4/Relm4", rev = "f216c7f5ba1324413cb16e45c37e0b9297473ec2" }
relm4 = { version = "0.7.0-beta.2", git = "https://github.com/Relm4/Relm4", rev = "e189eee06b887470e0fd65cbaf6d7c0161bed5ea" }
relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "menu-large", "size-horizontally", "ssd", "wallet2"] }
relm4-components = { version = "0.7.0-beta.2", git = "https://github.com/Relm4/Relm4", rev = "f216c7f5ba1324413cb16e45c37e0b9297473ec2", default-features = false }
relm4-components = { version = "0.7.0-beta.2", git = "https://github.com/Relm4/Relm4", rev = "e189eee06b887470e0fd65cbaf6d7c0161bed5ea", default-features = false }
reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls"] }
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-client-db = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
Expand All @@ -63,24 +63,24 @@ sc-informant = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b
sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-storage-monitor = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
semver = "1.0.21"
serde = { version = "1.0.194", features = ["derive"]}
serde_json = "1.0.111"
sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "91829422a9c4cc5e8576b864bfc4ab83b752a8ce" }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "7ac659062299f1911011aee5f1eb431805cf2883" }
supports-color = "2.0.0"
thiserror = "1.0.50"
tokio = { version = "1.34.0", features = ["fs", "time"] }
Expand Down
61 changes: 61 additions & 0 deletions res/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,64 @@ progressbar progress {
.error-label {
color: #ff3800;
}

farm-sectors > child {
padding: 0;
}

farm-sector {
animation-iteration-count: infinite;
animation-direction: alternate;
background-color: #727272;
min-width: 5px;
min-height: 5px;
margin: 1px;
}

farm-sector.plotted {
background-color: #9fc4ff;
}

farm-sector.about-to-expire {
background-color: #ffd678;
}

farm-sector.expired {
background-color: #ff877c;
}

@keyframes animate-downloading {
to {
background-color: #499249;
}
}

farm-sector.downloading {
animation-duration: 1s;
animation-name: animate-downloading;
}

@keyframes animate-encoding {
to {
background-color: #ff5365;
}
}

farm-sector.encoding {
animation-duration: 0.2s;
animation-name: animate-encoding;
}

@keyframes animate-writing {
from {
background-color: #727272;
}
to {
background-color: #9fc4ff;
}
}

farm-sector.writing {
animation-duration: 1s;
animation-name: animate-writing;
}
53 changes: 9 additions & 44 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ mod utils;

use crate::backend::config::{Config, ConfigError, RawConfig};
use crate::backend::farmer::maybe_node_client::MaybeNodeRpcClient;
use crate::backend::farmer::{DiskFarm, Farmer, FarmerOptions, PlottingState};
use crate::backend::farmer::{
DiskFarm, Farmer, FarmerNotification, FarmerOptions, InitialFarmState,
};
use crate::backend::networking::{create_network, NetworkOptions};
use crate::backend::node::{
dsn_bootstrap_nodes, BlockImported, ChainInfo, ChainSpec, ConsensusNode, SyncState,
Expand Down Expand Up @@ -69,18 +71,6 @@ pub enum NodeNotification {
BlockImported(BlockImported),
}

#[derive(Debug, Clone)]
pub enum FarmerNotification {
PlottingStateUpdate {
farm_index: usize,
state: PlottingState,
},
PieceCacheSyncProgress {
/// Progress so far in %
progress: f32,
},
}

/// Notification messages send from backend about its operation
#[derive(Debug)]
pub enum BackendNotification {
Expand All @@ -104,7 +94,7 @@ pub enum BackendNotification {
raw_config: RawConfig,
best_block_number: BlockNumber,
reward_address_balance: Balance,
initial_plotting_states: Vec<PlottingState>,
initial_farm_states: Vec<InitialFarmState>,
farm_during_initial_plotting: bool,
chain_info: ChainInfo,
},
Expand Down Expand Up @@ -315,7 +305,7 @@ async fn run(
raw_config,
best_block_number: consensus_node.best_block_number(),
reward_address_balance: consensus_node.account_balance(&config.reward_address),
initial_plotting_states: farmer.initial_plotting_states().to_vec(),
initial_farm_states: farmer.initial_farm_states().to_vec(),
farm_during_initial_plotting: farmer.farm_during_initial_plotting(),
chain_info: consensus_node.chain_info().clone(),
})
Expand Down Expand Up @@ -362,46 +352,21 @@ async fn run(
}
})
});
let _on_plotting_state_change_handler_id = farmer.on_plotting_state_change({
let _on_farmer_notification_handler_id = farmer.on_notification({
let notifications_sender = notifications_sender.clone();

Arc::new(move |&farm_index, &plotting_state| {
let notification = FarmerNotification::PlottingStateUpdate {
farm_index,
state: plotting_state,
};

let mut notifications_sender = notifications_sender.clone();

if let Err(error) = notifications_sender
.try_send(BackendNotification::Farmer(notification))
.or_else(|error| {
tokio::task::block_in_place(|| {
Handle::current().block_on(notifications_sender.send(error.into_inner()))
})
})
{
warn!(%error, "Failed to send plotting state backend notification");
}
})
});
let _on_piece_cache_sync_progress_handler_id = farmer.on_piece_cache_sync_progress({
let notifications_sender = notifications_sender.clone();

Arc::new(move |&progress| {
let notification = FarmerNotification::PieceCacheSyncProgress { progress };

Arc::new(move |notification| {
let mut notifications_sender = notifications_sender.clone();

if let Err(error) = notifications_sender
.try_send(BackendNotification::Farmer(notification))
.try_send(BackendNotification::Farmer(notification.clone()))
.or_else(|error| {
tokio::task::block_in_place(|| {
Handle::current().block_on(notifications_sender.send(error.into_inner()))
})
})
{
warn!(%error, "Failed to send piece cache sync progress backend notification");
warn!(%error, "Failed to send farmer backend notification");
}
})
});
Expand Down
Loading

0 comments on commit dfb4031

Please sign in to comment.