@@ -66,9 +66,16 @@ pub(crate) type Responder<T> = oneshot::Sender<T>;
66
66
67
67
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
68
68
pub struct ServerInfo {
69
- pub chain : String ,
69
+ pub network : String ,
70
70
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 ,
72
79
}
73
80
74
81
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -1083,7 +1090,7 @@ impl AsyncChainState {
1083
1090
rpc,
1084
1091
chain_state,
1085
1092
)
1086
- . await ?;
1093
+ . await ?;
1087
1094
1088
1095
Ok ( block
1089
1096
. block_meta
@@ -1205,7 +1212,7 @@ impl AsyncChainState {
1205
1212
rpc,
1206
1213
chain_state,
1207
1214
)
1208
- . await ;
1215
+ . await ;
1209
1216
let _ = resp. send ( res) ;
1210
1217
}
1211
1218
ChainStateCommand :: GetTxMeta { txid, resp } => {
@@ -1267,7 +1274,7 @@ impl AsyncChainState {
1267
1274
File :: open ( anchors_path)
1268
1275
. or_else ( |e| Err ( anyhow ! ( "Could not open anchors file: {}" , e) ) ) ?,
1269
1276
)
1270
- . or_else ( |e| Err ( anyhow ! ( "Could not read anchors file: {}" , e) ) ) ?;
1277
+ . or_else ( |e| Err ( anyhow ! ( "Could not read anchors file: {}" , e) ) ) ?;
1271
1278
return Ok ( anchors) ;
1272
1279
}
1273
1280
@@ -1569,6 +1576,7 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
1569
1576
struct Info {
1570
1577
pub chain : String ,
1571
1578
pub headers : u32 ,
1579
+ pub blocks : u32 ,
1572
1580
}
1573
1581
1574
1582
let info: Info = rpc
@@ -1577,12 +1585,16 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
1577
1585
. map_err ( |e| anyhow ! ( "Could not retrieve blockchain info ({})" , e) ) ?;
1578
1586
1579
1587
Ok ( ServerInfo {
1580
- chain : info. chain ,
1588
+ network : info. chain ,
1581
1589
tip,
1590
+ chain : ChainInfo {
1591
+ blocks : info. blocks ,
1592
+ headers : info. headers ,
1593
+ } ,
1582
1594
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
1584
1596
} else {
1585
- None
1586
- }
1597
+ 0.0
1598
+ } ,
1587
1599
} )
1588
1600
}
0 commit comments