Skip to content

Commit 6018a1c

Browse files
authored
Merge pull request dmnd-pool#109 from Fi3/FixShareSubmitWhenExceedUpstreamCapacity
Fix share submit when exceed upstream capacity
2 parents fc4494c + 0ec9e0f commit 6018a1c

5 files changed

Lines changed: 43 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "demand-cli"
3-
version = "0.1.16"
3+
version = "0.1.17"
44
edition = "2021"
55

66
[dependencies]

src/ingress/sv1_ingress.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{net::{IpAddr, SocketAddr}, sync::Arc};
1+
use std::{
2+
net::{IpAddr, SocketAddr},
3+
sync::Arc,
4+
};
25

36
use crate::{
47
config::Configuration,
@@ -96,7 +99,7 @@ impl Downstream {
9699
if Configuration::sv1_ingress_log() {
97100
info!("Sending msg to upstream: {}", message);
98101
}
99-
if ! is_subscribed {
102+
if !is_subscribed {
100103
if message.contains("mining.subscribe") {
101104
is_subscribed = true;
102105
if message.contains("LUXminer") {
@@ -158,7 +161,7 @@ impl Downstream {
158161
}
159162
}
160163

161-
#[derive(Debug,Clone,Copy)]
164+
#[derive(Debug, Clone, Copy)]
162165
enum Firmware {
163166
Luxor,
164167
Other,

src/translator/downstream/downstream.rs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,40 @@ impl IsServer<'static> for Downstream {
510510
}
511511
}
512512
Ok(false) => {
513-
warn!("Share rejected: Exceeded 70 shares/min limit");
514-
self.stats_sender.update_rejected_shares(self.connection_id);
515-
false
513+
warn!("Share will not be sent upstream: Exceeded 70 shares/min limit");
514+
if let Some(job) = self
515+
.recent_jobs
516+
.get_matching_job(job_id_as_number.expect("checked above"))
517+
{
518+
request.job_id = job.job_id.clone();
519+
//check share is valid
520+
if let Some(met_difficulty) = validate_share(
521+
&request,
522+
&job,
523+
&self.difficulty_mgmt.current_difficulties,
524+
self.extranonce1.clone(),
525+
self.version_rolling_mask.clone(),
526+
) {
527+
info!(
528+
"Share for Job {} and difficulty {} is accepted",
529+
request.job_id, met_difficulty
530+
);
531+
// TODO here stats sender should update accepted shares that are not sent
532+
// upstream
533+
true
534+
} else {
535+
error!("Share rejected: Invalid share");
536+
self.stats_sender.update_rejected_shares(self.connection_id);
537+
false
538+
}
539+
} else {
540+
error!(
541+
"Share rejected: can not find job with id {}",
542+
request.job_id
543+
);
544+
self.stats_sender.update_rejected_shares(self.connection_id);
545+
false
546+
}
516547
}
517548
Err(e) => {
518549
error!("Failed to record share: {e:?}");

src/translator/downstream/notify.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ pub async fn start_notify(
8989
}
9090
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
9191
}
92-
if let Err(e) =
93-
start_update(task_manager, downstream.clone(), connection_id).await
94-
{
92+
if let Err(e) = start_update(task_manager, downstream.clone(), connection_id).await {
9593
warn!("Translator impossible to start update task: {e}");
9694
} else if authorized_in_time {
9795
// Get the mask after initialization since is set by configure message

0 commit comments

Comments
 (0)