Skip to content

Commit

Permalink
feat: Display time-locked balance in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aszepieniec committed Mar 9, 2024
1 parent 497f446 commit f3007d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/bin/dashboard_src/overview_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use super::screen::Screen;

#[derive(Debug, Clone)]
pub struct OverviewData {
synced_balance: Option<NeptuneCoins>,
available_balance: Option<NeptuneCoins>,
timelocked_balance: Option<NeptuneCoins>,
confirmations: Option<BlockHeight>,
synchronization_percentage: Option<f64>,

Expand Down Expand Up @@ -66,7 +67,8 @@ pub struct OverviewData {
impl OverviewData {
pub fn new(network: Network, listen_address: Option<SocketAddr>) -> Self {
Self {
synced_balance: Default::default(),
available_balance: Default::default(),
timelocked_balance: Default::default(),
confirmations: Default::default(),
synchronization_percentage: Default::default(),
network,
Expand All @@ -93,7 +95,8 @@ impl OverviewData {
}
pub fn test() -> Self {
OverviewData {
synced_balance: Some(NeptuneCoins::zero()),
available_balance: Some(NeptuneCoins::zero()),
timelocked_balance: Some(NeptuneCoins::zero()),
confirmations: Some(17.into()),
synchronization_percentage: Some(99.5),

Expand Down Expand Up @@ -202,7 +205,8 @@ impl OverviewScreen {
own_overview_data.peer_count=resp.peer_count;
own_overview_data.authenticated_peer_count=Some(0);
own_overview_data.syncing=resp.syncing;
own_overview_data.synced_balance = Some(resp.synced_balance);
own_overview_data.available_balance = Some(resp.available_balance);
own_overview_data.timelocked_balance = Some(resp.timelocked_balance);
own_overview_data.is_mining = resp.is_mining;
own_overview_data.confirmations = resp.confirmations;
}
Expand Down Expand Up @@ -358,13 +362,17 @@ impl Widget for OverviewScreen {

// balance
lines.push(format!(
"synced balance: {} {}",
dashifnotset!(data.synced_balance),
"available balance: {} {}",
dashifnotset!(data.available_balance),
match data.confirmations {
Some(c) => format!("({} confirmations)", c),
None => " ".to_string(),
},
));
lines.push(format!(
"time-locked balance: {}",
dashifnotset!(data.timelocked_balance),
));
lines.push(format!(
"synchronization: {}",
match data.synchronization_percentage {
Expand Down
6 changes: 4 additions & 2 deletions src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ use crate::models::state::{GlobalStateLock, UtxoReceiverData};
pub struct DashBoardOverviewDataFromClient {
pub tip_header: BlockHeader,
pub syncing: bool,
pub synced_balance: NeptuneCoins,
pub available_balance: NeptuneCoins,
pub timelocked_balance: NeptuneCoins,
pub mempool_size: usize,
pub mempool_tx_count: usize,

Expand Down Expand Up @@ -433,7 +434,8 @@ impl RPC for NeptuneRPCServer {
DashBoardOverviewDataFromClient {
tip_header,
syncing,
synced_balance: wallet_status.synced_unspent_available_amount(now),
available_balance: wallet_status.synced_unspent_available_amount(now),
timelocked_balance: wallet_status.synced_unspent_timelocked_amount(now),
mempool_size,
mempool_tx_count,
peer_count,
Expand Down

0 comments on commit f3007d6

Please sign in to comment.