Skip to content

Commit

Permalink
Add sync loading bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Duddino committed Jan 15, 2025
1 parent a8d6de7 commit 26ca6f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src-tauri/src/explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ where
pivx_rpc: PIVXRpc,
}

#[derive(Deserialize)]
struct ChainInfo {
verificationprogress: f64,
initial_block_downloading: bool,
}

type DefaultExplorer = Explorer<SqlLite>;

impl<D> Explorer<D>
Expand Down Expand Up @@ -203,4 +209,20 @@ where
.set_block_source(block_file_source);
Ok(())
}

pub async fn is_initial_sync(&self) -> crate::error::Result<bool> {
let chain_info: ChainInfo = self
.pivx_rpc
.call("getblockchaininfo", rpc_params![])
.await?;
Ok(chain_info.initial_block_downloading)
}

pub async fn get_sync_progress(&self) -> crate::error::Result<f64> {
let chain_info: ChainInfo = self
.pivx_rpc
.call("getblockchaininfo", rpc_params![])
.await?;
Ok(chain_info.verificationprogress)
}
}
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fn main() {
explorer_sync,
explorer_switch_to_rpc_source,
explorer_switch_to_blockfile_source,
explorer_is_initial_sync,
explorer_get_sync_progress,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down

0 comments on commit 26ca6f5

Please sign in to comment.