Skip to content

Fix loading glitches #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion client/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct ServerInfo {
pub network: String,
pub tip: ChainAnchor,
pub chain: ChainInfo,
pub ready: bool,
pub progress: f32,
}

Expand Down Expand Up @@ -1593,12 +1594,17 @@ fn get_space_key(space_or_hash: &str) -> Result<SpaceKey, ErrorObjectOwned> {
}


async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainAnchor) -> anyhow::Result<ServerInfo> {
async fn get_server_info(
client: &reqwest::Client,
rpc: &BitcoinRpc,
tip: ChainAnchor,
) -> anyhow::Result<ServerInfo> {
#[derive(Deserialize)]
struct Info {
pub chain: String,
pub headers: u32,
pub blocks: u32,
pub headerssynced: Option<bool>,
}

let info: Info = rpc
Expand All @@ -1621,6 +1627,7 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
blocks: info.blocks,
headers: info.headers,
},
ready: info.headerssynced.unwrap_or(true),
progress: calc_progress(start_block, tip.height, info.headers),
})
}
Loading