Skip to content

Commit 63d37c5

Browse files
committed
update/fix ServerStandardChannelInfo share accounting
1 parent a7f1fc1 commit 63d37c5

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

stratum-apps/src/monitoring/http_server.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ async fn handle_prometheus_metrics(State(state): State<ServerState>) -> Response
800800
if let Some(ref metric) = state.metrics.sv2_server_shares_accepted_total {
801801
metric
802802
.with_label_values(&[&channel_id, user])
803-
.set(channel.shares_accepted as f64);
803+
.set(channel.shares_acknowledged as f64);
804804
}
805805
if let (Some(ref metric), Some(hashrate)) = (
806806
&state.metrics.sv2_server_channel_hashrate,
@@ -1015,9 +1015,10 @@ mod tests {
10151015
nominal_hashrate: hashrate,
10161016
target_hex: "00ff".into(),
10171017
extranonce_prefix_hex: "bb".into(),
1018-
shares_accepted: 20,
1019-
share_work_sum: 200.0,
1018+
shares_acknowledged: 20,
10201019
shares_submitted: 22,
1020+
shares_rejected: 1,
1021+
share_work_sum: 200.0,
10211022
best_diff: 80.0,
10221023
blocks_found: 0,
10231024
}

stratum-apps/src/monitoring/server.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ pub struct ServerStandardChannelInfo {
3535
pub nominal_hashrate: Option<f32>,
3636
pub target_hex: String,
3737
pub extranonce_prefix_hex: String,
38-
pub shares_accepted: u32,
39-
pub share_work_sum: f64,
38+
pub shares_acknowledged: u32,
4039
pub shares_submitted: u32,
40+
pub shares_rejected: u32,
41+
pub share_work_sum: f64,
4142
pub best_diff: f64,
4243
pub blocks_found: u32,
4344
}
@@ -134,14 +135,26 @@ mod tests {
134135
nominal_hashrate: hashrate,
135136
target_hex: "00ff".into(),
136137
extranonce_prefix_hex: "bb".into(),
137-
shares_accepted: 20,
138-
share_work_sum: 200.0,
138+
shares_acknowledged: 20,
139139
shares_submitted: 22,
140+
shares_rejected: 1,
141+
share_work_sum: 200.0,
140142
best_diff: 80.0,
141143
blocks_found: 0,
142144
}
143145
}
144146

147+
#[test]
148+
fn server_standard_channel_info_serializes_share_accounting_fields() {
149+
let channel = create_server_standard_channel_info(7, Some(50.0));
150+
let json = serde_json::to_value(channel).unwrap();
151+
152+
assert_eq!(json["shares_acknowledged"], 20);
153+
assert_eq!(json["shares_rejected"], 1);
154+
assert_eq!(json["share_work_sum"], 200.0);
155+
assert!(json.get("shares_accepted").is_none());
156+
}
157+
145158
// ── ServerInfo unit tests ───────────────────────────────────────
146159

147160
#[test]

0 commit comments

Comments
 (0)