Skip to content

Commit

Permalink
Merge pull request #169 from subspace/pause-plotting
Browse files Browse the repository at this point in the history
Add button to pause plotting
  • Loading branch information
nazar-pc authored Mar 21, 2024
2 parents 3aafee3 + f2d8eb8 commit b12ff08
Show file tree
Hide file tree
Showing 8 changed files with 423 additions and 221 deletions.
105 changes: 61 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 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 GUI application for farming on Subspace Network"
license = "0BSD"
version = "0.1.10"
version = "0.1.11"
authors = ["Nazar Mokrynskyi <[email protected]>"]
repository = "https://github.com/subspace/space-acres"
edition = "2021"
Expand Down Expand Up @@ -62,7 +62,7 @@ pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b
parity-scale-codec = "3.6.9"
parking_lot = "0.12.1"
relm4 = "0.7.0-rc.1"
relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "grid-filled", "menu-large", "processor", "puzzle-piece", "size-horizontally", "ssd", "wallet2", "warning"] }
relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "grid-filled", "menu-large", "pause", "processor", "puzzle-piece", "size-horizontally", "ssd", "wallet2", "warning"] }
relm4-components = { version = "0.7.0-rc.1", default-features = false }
reqwest = { version = "0.11.25", default-features = false, features = ["json", "rustls-tls"] }
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
Expand All @@ -72,25 +72,25 @@ sc-informant = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500
sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
sc-storage-monitor = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
semver = "1.0.22"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
simple_moving_average = "1.0.2"
sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "21194a8d07e1068b08f89fb5fca31a6c827b0416" }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "b970b6a7d65bc99963a45b05a93a2b41bf2bbd11" }
supports-color = "3.0.0"
thiserror = "1.0.57"
thread-priority = "0.16.0"
Expand Down
19 changes: 18 additions & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod utils;
use crate::backend::config::{Config, ConfigError, RawConfig};
use crate::backend::farmer::maybe_node_client::MaybeNodeRpcClient;
use crate::backend::farmer::{
DiskFarm, Farmer, FarmerNotification, FarmerOptions, InitialFarmState,
DiskFarm, Farmer, FarmerAction, FarmerNotification, FarmerOptions, InitialFarmState,
};
use crate::backend::networking::{create_network, NetworkOptions};
use crate::backend::node::{
Expand Down Expand Up @@ -231,6 +231,8 @@ pub enum BackendNotification {
pub enum BackendAction {
/// Config was created or updated
NewConfig { raw_config: RawConfig },
/// Farmer action
Farmer(FarmerAction),
}

struct LoadedBackend {
Expand Down Expand Up @@ -299,6 +301,12 @@ pub async fn create(
// Try to load config and start again
continue 'load;
}
BackendAction::Farmer(farmer_action) => {
warn!(
?farmer_action,
"Farmer action is not expected before initialization, ignored"
);
}
}
}

Expand Down Expand Up @@ -550,6 +558,8 @@ async fn run(
})
});

let mut farmer_action_sender = farmer.action_sender();

// Order is important here, we want to destroy dependents first and only then corresponding
// dependencies to avoid unnecessary errors and warnings in logs
let networking_fut = networking_fut;
Expand All @@ -562,6 +572,7 @@ async fn run(
process_backend_actions(
&config_file_path,
backend_action_receiver,
&mut farmer_action_sender,
&mut notifications_sender,
)
.await
Expand Down Expand Up @@ -991,6 +1002,7 @@ async fn create_farmer(
async fn process_backend_actions(
config_file_path: &Path,
backend_action_receiver: &mut mpsc::Receiver<BackendAction>,
farmer_action_sender: &mut mpsc::Sender<FarmerAction>,
notifications_sender: &mut mpsc::Sender<BackendNotification>,
) {
while let Some(action) = backend_action_receiver.next().await {
Expand All @@ -1013,6 +1025,11 @@ async fn process_backend_actions(
error!(%error, "Failed to send config save result notification");
}
}
BackendAction::Farmer(farmer_action) => {
if let Err(error) = farmer_action_sender.send(farmer_action).await {
error!(%error, "Failed to forward farmer action");
}
}
}
}
}
Expand Down
Loading

0 comments on commit b12ff08

Please sign in to comment.