@@ -66,9 +66,16 @@ pub(crate) type Responder<T> = oneshot::Sender<T>;
6666
6767#[ derive( Debug , Clone , Serialize , Deserialize ) ]
6868pub struct ServerInfo {
69- pub chain : String ,
69+ pub network : String ,
7070 pub tip : ChainAnchor ,
71- pub progress : Option < f32 > ,
71+ pub chain : ChainInfo ,
72+ pub progress : f32 ,
73+ }
74+
75+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
76+ pub struct ChainInfo {
77+ blocks : u32 ,
78+ headers : u32 ,
7279}
7380
7481#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -1083,7 +1090,7 @@ impl AsyncChainState {
10831090 rpc,
10841091 chain_state,
10851092 )
1086- . await ?;
1093+ . await ?;
10871094
10881095 Ok ( block
10891096 . block_meta
@@ -1205,7 +1212,7 @@ impl AsyncChainState {
12051212 rpc,
12061213 chain_state,
12071214 )
1208- . await ;
1215+ . await ;
12091216 let _ = resp. send ( res) ;
12101217 }
12111218 ChainStateCommand :: GetTxMeta { txid, resp } => {
@@ -1267,7 +1274,7 @@ impl AsyncChainState {
12671274 File :: open ( anchors_path)
12681275 . or_else ( |e| Err ( anyhow ! ( "Could not open anchors file: {}" , e) ) ) ?,
12691276 )
1270- . or_else ( |e| Err ( anyhow ! ( "Could not read anchors file: {}" , e) ) ) ?;
1277+ . or_else ( |e| Err ( anyhow ! ( "Could not read anchors file: {}" , e) ) ) ?;
12711278 return Ok ( anchors) ;
12721279 }
12731280
@@ -1569,6 +1576,7 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
15691576 struct Info {
15701577 pub chain : String ,
15711578 pub headers : u32 ,
1579+ pub blocks : u32 ,
15721580 }
15731581
15741582 let info: Info = rpc
@@ -1577,12 +1585,16 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
15771585 . map_err ( |e| anyhow ! ( "Could not retrieve blockchain info ({})" , e) ) ?;
15781586
15791587 Ok ( ServerInfo {
1580- chain : info. chain ,
1588+ network : info. chain ,
15811589 tip,
1590+ chain : ChainInfo {
1591+ blocks : info. blocks ,
1592+ headers : info. headers ,
1593+ } ,
15821594 progress : if info. headers >= tip. height {
1583- Some ( tip. height as f32 / info. headers as f32 )
1595+ tip. height as f32 / info. headers as f32
15841596 } else {
1585- None
1586- }
1597+ 0.0
1598+ } ,
15871599 } )
15881600}
0 commit comments