Skip to content

Commit

Permalink
Merge pull request #347 from autonomys/network-status-indicator
Browse files Browse the repository at this point in the history
Add network status indicator
  • Loading branch information
nazar-pc authored Dec 5, 2024
2 parents be89406 + 9c53d27 commit 2dcfdfc
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 76 deletions.
79 changes: 28 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ parity-scale-codec = "3.6.12"
parking_lot = "0.12.3"
relm4 = "0.9.1"
relm4-components = { version = "0.9.1", default-features = false }
relm4-icons = "0.10.0-beta.0"
relm4-icons = "0.10.0-beta.2"
reqwest = { version = "0.12.8", default-features = false, features = ["json", "rustls-tls"] }
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", default-features = false }
sc-client-db = { git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", default-features = false }
Expand All @@ -82,8 +82,8 @@ sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev =
sc-utils = { git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", default-features = false }
schnellru = "0.2.3"
semver = "1.0.23"
serde = { version = "1.0.213", features = ["derive"] }
serde_json = "1.0.132"
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.133"
simple_moving_average = "1.0.2"
sp-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", default-features = false }
sp-consensus = { git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", default-features = false }
Expand Down Expand Up @@ -126,7 +126,7 @@ ksni = "0.2.2"

[build-dependencies]
fluent-static-codegen = "0.5.0"
relm4-icons-build = "0.10.0-beta.0"
relm4-icons-build = "0.10.0-beta.2"

[target.'cfg(windows)'.build-dependencies]
winres = "0.1.12"
Expand Down
24 changes: 15 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,26 @@ fn main() {
None,
None::<&str>,
[
"ssd",
"size-horizontally",
"cross",
"cross-small",
"checkmark",
"wallet2",
"warning",
"grid-filled",
"puzzle-piece",
"pause",
"menu-large",
"processor",
"speedometer2",
"speedometer3",
"speedometer4",
"grid-filled",
"size-horizontally",
"speedometer-low",
"speedometer-medium",
"speedometer-high",
"ssd",
"strength-bars-1",
"strength-nars-2",
"strength-bars-3",
"strength-bars-4",
"strength-bars-5",
"strength-bars-6",
"wallet2",
"warning-outline",
],
);
}
2 changes: 2 additions & 0 deletions res/translations/de-DE/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ running_title = Wird ausgeführt
running_node_title = {$chain_name} Konsens-Node
running_node_title_tooltip = Klicken, um im Dateimanager zu öffnen
running_node_free_disk_space_tooltip = Freier Speicherplatz: {$size} verbleibend
# TODO: Translate
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_status_connecting = Verbindung zum Netzwerk wird hergestellt, bester Block #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocks/s
running_node_status_syncing_speed_hours_eta = , {NUMBER($a_blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocks/s (~{NUMBER($b_hours_remaining, minimumFractionDigits: 2, maximumFractionDigits: 2)} hours remaining)
Expand Down
1 change: 1 addition & 0 deletions res/translations/en/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ running_title = Running
running_node_title = {$chain_name} consensus node
running_node_title_tooltip = Click to open in file manager
running_node_free_disk_space_tooltip = Free disk space: {$size} remaining
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_status_connecting = Connecting to the network, best block #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocks/s
running_node_status_syncing_speed_hours_eta = , {NUMBER($a_blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocks/s (~{NUMBER($b_hours_remaining, minimumFractionDigits: 2, maximumFractionDigits: 2)} hours remaining)
Expand Down
2 changes: 2 additions & 0 deletions res/translations/es/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ configuration_dialog_button_cancel = Cancelar
running_title = Ejecutando
running_node_title = {$chain_name} nodo de consenso
running_node_title_tooltip = Abrir sistema de archivos
# TODO: Translate
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_free_disk_space_tooltip = Espacio libre en disco: {$size} restante
running_node_status_connecting = Conectando a la red, mejor bloque #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} bloques/s
Expand Down
2 changes: 2 additions & 0 deletions res/translations/fr/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ configuration_dialog_button_cancel = Annuler
running_title = En cours
running_node_title = {$chain_name} Nœud de la blockchain
running_node_title_tooltip = Cliquez pour ouvrir dans le gestionnaire de fichiers
# TODO: Translate
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_free_disk_space_tooltip = Espace disque libre restant : {$size}
running_node_status_connecting = Connexion au réseau, meilleur bloc #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocs/s
Expand Down
2 changes: 2 additions & 0 deletions res/translations/rs/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ configuration_dialog_button_cancel = Otkaži
running_title = U radu
running_node_title = {$chain_name} konsenzus čvor
running_node_title_tooltip = Kliknite da otvorite u upravitelju datotekama
# TODO: Translate
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_free_disk_space_tooltip = Slobodan prostor na disku: preostalo {$size}
running_node_status_connecting = Povezivanje sa mrežom, najbolji blok #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blokova/s
Expand Down
1 change: 1 addition & 0 deletions res/translations/ru-RU/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ configuration_dialog_button_cancel = Отмена
running_title = Запущено
running_node_title = Узел блокчейна {$chain_name}
running_node_title_tooltip = Нажмите, чтобы открыть в файловом менеджере
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} подключенных пиров, нажмите для подробностей про нужные P2P порты
running_node_free_disk_space_tooltip = Осталось свободного места на диске: {$size}
running_node_status_connecting = Подключение к сети, лучший блок #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} блоков/сек
Expand Down
1 change: 1 addition & 0 deletions res/translations/uk-UA/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ configuration_dialog_button_cancel = Скасувати
running_title = Запущено
running_node_title = {$chain_name} вузол консенсусу
running_node_title_tooltip = Натисніть щоб відкрити в файловому менеджері
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} пірів підключено, натисніть для деталей про необхідні P2P порти
running_node_free_disk_space_tooltip = Вільний дисковий простір: {$size} remaining
running_node_status_connecting = Підключення до мережі, кращий блок #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} блоки/с
Expand Down
2 changes: 2 additions & 0 deletions res/translations/zh-CN/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ configuration_dialog_button_cancel = 取消
running_title = 运行中
running_node_title = {$chain_name} 共识节点
running_node_title_tooltip = 在文件管理器中打开
# TODO: Translate
running_node_connections_tooltip = {$connected_peers}/{$expected_peers} peers connected, click for details about required P2P ports
running_node_free_disk_space_tooltip = 空闲磁盘大小: {$size}
running_node_status_connecting = 连接网络中,最新区块 #{$block_number}
running_node_status_syncing_speed_no_eta = , {NUMBER($blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocks/s
Expand Down
21 changes: 21 additions & 0 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ enum LoadedConsensusChainNode {
#[derive(Debug, Clone)]
pub enum NodeNotification {
SyncStateUpdate(SyncState),
ConnectedPeersUpdate(u32),
BlockImported(BlockImportedNotification),
}

Expand Down Expand Up @@ -561,6 +562,26 @@ async fn run(
}
})
});
let _on_connected_peers_change_handler_id = consensus_node.on_connected_peers_change({
let notifications_sender = notifications_sender.clone();

Arc::new(move |&connected_peers| {
let notification = NodeNotification::ConnectedPeersUpdate(connected_peers);

let mut notifications_sender = notifications_sender.clone();

if let Err(error) = notifications_sender
.try_send(BackendNotification::Node(notification))
.or_else(|error| {
tokio::task::block_in_place(|| {
Handle::current().block_on(notifications_sender.send(error.into_inner()))
})
})
{
warn!(%error, "Failed to send sync state backend notification");
}
})
});
let _on_imported_block_handler_id = consensus_node.on_block_imported({
let notifications_sender = notifications_sender.clone();

Expand Down
Loading

0 comments on commit 2dcfdfc

Please sign in to comment.