@@ -15,6 +15,61 @@ pub struct P2PoolClient {
1515 base_url : String ,
1616}
1717
18+ #[ derive( Debug , Clone , Deserialize ) ]
19+ pub struct ChainInfo {
20+ pub genesis_blockhash : Option < String > ,
21+ pub chain_tip_height : Option < u64 > ,
22+ pub total_work : String ,
23+ pub chain_tip_blockhash : Option < String > ,
24+ pub top_candidate_height : Option < u64 > ,
25+ pub top_candidate_blockhash : Option < String > ,
26+ }
27+
28+ #[ derive( Debug , Clone , Deserialize ) ]
29+ pub struct PeerInfo {
30+ pub peer_id : String ,
31+ }
32+
33+ #[ derive( Debug , Clone , Deserialize ) ]
34+ pub struct SharesResponse {
35+ pub from_height : u64 ,
36+ pub to_height : u64 ,
37+ pub shares : Vec < ShareInfo > ,
38+ }
39+
40+ #[ derive( Debug , Clone , Deserialize ) ]
41+ pub struct ShareInfo {
42+ pub blockhash : String ,
43+ pub prev_blockhash : String ,
44+ pub height : u64 ,
45+ pub miner_address : String ,
46+ pub timestamp : u64 ,
47+ pub bits : String ,
48+ pub uncles : Vec < UncleInfo > ,
49+ }
50+
51+ #[ derive( Debug , Clone , Deserialize ) ]
52+ pub struct UncleInfo {
53+ pub blockhash : String ,
54+ pub prev_blockhash : String ,
55+ pub miner_address : String ,
56+ pub timestamp : u64 ,
57+ pub height : u64 ,
58+ }
59+
60+ #[ derive( Debug , Clone , Deserialize ) ]
61+ pub struct ShareDetail {
62+ pub blockhash : String ,
63+ pub height : Option < u64 > ,
64+ pub status : String ,
65+ pub parent : String ,
66+ pub uncles : Vec < String > ,
67+ pub miner_address : String ,
68+ pub merkle_root : String ,
69+ pub bits : String ,
70+ pub time : String ,
71+ }
72+
1873impl P2PoolClient {
1974 pub fn new ( ) -> Self {
2075 let client = Client :: builder ( )
@@ -50,7 +105,6 @@ impl P2PoolClient {
50105 Ok ( text)
51106 }
52107
53- // ✏️ CHANGED: renamed from fetch_metrics_raw, added basic_auth param
54108 pub async fn fetch_metrics ( & self , basic_auth : Option < & str > ) -> Result < String , reqwest:: Error > {
55109 let url = format ! ( "{}/metrics" , self . base_url) ;
56110
@@ -172,61 +226,6 @@ impl Default for P2PoolClient {
172226 }
173227}
174228
175- #[ derive( Debug , Clone , Deserialize ) ]
176- pub struct ChainInfo {
177- pub genesis_blockhash : Option < String > ,
178- pub chain_tip_height : Option < u64 > ,
179- pub total_work : String ,
180- pub chain_tip_blockhash : Option < String > ,
181- pub top_candidate_height : Option < u64 > ,
182- pub top_candidate_blockhash : Option < String > ,
183- }
184-
185- #[ derive( Debug , Clone , Deserialize ) ]
186- pub struct PeerInfo {
187- pub peer_id : String ,
188- }
189-
190- #[ derive( Debug , Clone , Deserialize ) ]
191- pub struct SharesResponse {
192- pub from_height : u64 ,
193- pub to_height : u64 ,
194- pub shares : Vec < ShareInfo > ,
195- }
196-
197- #[ derive( Debug , Clone , Deserialize ) ]
198- pub struct ShareInfo {
199- pub blockhash : String ,
200- pub prev_blockhash : String ,
201- pub height : u64 ,
202- pub miner_address : String ,
203- pub timestamp : u64 ,
204- pub bits : String ,
205- pub uncles : Vec < UncleInfo > ,
206- }
207-
208- #[ derive( Debug , Clone , Deserialize ) ]
209- pub struct UncleInfo {
210- pub blockhash : String ,
211- pub prev_blockhash : String ,
212- pub miner_address : String ,
213- pub timestamp : u64 ,
214- pub height : u64 ,
215- }
216-
217- #[ derive( Debug , Clone , Deserialize ) ]
218- pub struct ShareDetail {
219- pub blockhash : String ,
220- pub height : Option < u64 > ,
221- pub status : String ,
222- pub parent : String ,
223- pub uncles : Vec < String > ,
224- pub miner_address : String ,
225- pub merkle_root : String ,
226- pub bits : String ,
227- pub time : String ,
228- }
229-
230229#[ cfg( test) ]
231230mod tests {
232231 use super :: * ;
0 commit comments