-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces PR #727 #733
Merged
Merged
Replaces PR #727 #733
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
1b9c51d
Merge pull request #11 from stratum-mining/dev
GitGab19 023984b
Merge branch 'stratum-mining:dev' into dev
GitGab19 9cec29c
Merge branch 'stratum-mining:dev' into dev
GitGab19 3dcd85d
automatic diff management enhancement + fix #712
GitGab19 2fabdfe
invalid-job-id error added
GitGab19 08c49fb
fix
GitGab19 764ae99
'invalid-job-id' added into SubmitShares.Error doc
GitGab19 4100000
Fix issue #730
GitGab19 9251f0e
Mempool update timout management
GitGab19 6029ad7
fmt fix
GitGab19 88c7c41
clippy fix
GitGab19 12b3e05
MG fixes
GitGab19 e67a00e
panic if TP is not responding
GitGab19 bdd1064
fmt fixes
GitGab19 2519367
clippy fix
GitGab19 583d23a
last changes
GitGab19 8db76f8
automatic diff management enhancement + fix #712
GitGab19 798b842
invalid-job-id error added
GitGab19 d94fa27
fix
GitGab19 90158fa
'invalid-job-id' added into SubmitShares.Error doc
GitGab19 6362640
Fix issue #730
GitGab19 c365c88
Mempool update timout management
GitGab19 2c70690
fmt fix
GitGab19 180db6d
clippy fix
GitGab19 a14c364
MG fixes
GitGab19 788481b
panic if TP is not responding
GitGab19 78f5208
fmt fixes
GitGab19 e13d166
clippy fix
GitGab19 4b5f3df
last changes
GitGab19 b4f62d3
Merge branch 'dev' of https://github.com/GitGab19/stratum into dev
GitGab19 b1f815b
last fixes
GitGab19 22f43fe
last changes
GitGab19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ use super::{Downstream, DownstreamMessages, SetDownstreamTarget}; | |
use super::super::error::{Error, ProxyResult}; | ||
use roles_logic_sv2::utils::Mutex; | ||
use std::{ops::Div, sync::Arc}; | ||
use tracing::error; | ||
use v1::json_rpc; | ||
|
||
use stratum_common::bitcoin::util::uint::Uint256; | ||
|
@@ -212,7 +211,7 @@ impl Downstream { | |
} | ||
|
||
let delta_time = timestamp_secs - d.difficulty_mgmt.timestamp_of_last_update; | ||
if delta_time == 0 { | ||
if delta_time <= 15 { | ||
return Ok(None); | ||
} | ||
tracing::debug!("\nDELTA TIME: {:?}", delta_time); | ||
|
@@ -225,7 +224,7 @@ impl Downstream { | |
) { | ||
Ok(hashrate) => hashrate as f32, | ||
Err(e) => { | ||
error!("{:?} -> Probably min_individual_miner_hashrate parameter was not set properly in config file. New hashrate will be automatically adjusted to match the real one.", e); | ||
tracing::debug!("{:?} -> Probably min_individual_miner_hashrate parameter was not set properly in config file. New hashrate will be automatically adjusted to match the real one.", e); | ||
d.difficulty_mgmt.min_individual_miner_hashrate * realized_share_per_min as f32 / d.difficulty_mgmt.shares_per_minute | ||
} | ||
}; | ||
|
@@ -244,21 +243,33 @@ impl Downstream { | |
|| (hashrate_delta_percentage >= 30.0) && (delta_time >= 240) | ||
|| (hashrate_delta_percentage >= 15.0) && (delta_time >= 300) | ||
{ | ||
if realized_share_per_min < 0.01 { | ||
if realized_share_per_min == 0.0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a float are you sure that is safe to change from < to == If yes write a comment that explain why |
||
new_miner_hashrate = match delta_time { | ||
dt if dt < 30 => d.difficulty_mgmt.min_individual_miner_hashrate / 2.0, | ||
dt if dt < 60 => d.difficulty_mgmt.min_individual_miner_hashrate / 3.0, | ||
_ => d.difficulty_mgmt.min_individual_miner_hashrate / 5.0, | ||
dt if dt <= 30 => d.difficulty_mgmt.min_individual_miner_hashrate / 1.5, | ||
dt if dt < 60 => d.difficulty_mgmt.min_individual_miner_hashrate / 2.0, | ||
_ => d.difficulty_mgmt.min_individual_miner_hashrate / 3.0, | ||
}; | ||
hashrate_delta = | ||
new_miner_hashrate - d.difficulty_mgmt.min_individual_miner_hashrate; | ||
} | ||
if (realized_share_per_min > 0.0) && (hashrate_delta_percentage > 1000.0) { | ||
new_miner_hashrate = match delta_time { | ||
dt if dt <= 30 => d.difficulty_mgmt.min_individual_miner_hashrate * 10.0, | ||
dt if dt < 60 => d.difficulty_mgmt.min_individual_miner_hashrate * 5.0, | ||
_ => d.difficulty_mgmt.min_individual_miner_hashrate * 3.0, | ||
}; | ||
hashrate_delta = | ||
new_miner_hashrate - d.difficulty_mgmt.min_individual_miner_hashrate; | ||
} | ||
d.difficulty_mgmt.min_individual_miner_hashrate = new_miner_hashrate; | ||
d.difficulty_mgmt.timestamp_of_last_update = timestamp_secs; | ||
d.difficulty_mgmt.submits_since_last_update = 0; | ||
// update channel hashrate (read by upstream) | ||
d.upstream_difficulty_config.super_safe_lock(|c| { | ||
if c.channel_nominal_hashrate + hashrate_delta > 0.0 { | ||
c.channel_nominal_hashrate += hashrate_delta; | ||
} else { | ||
c.channel_nominal_hashrate = 0.0; | ||
} | ||
}); | ||
Ok(Some(new_miner_hashrate)) | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment that exaplain why the unwrap is safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
Going forward, IMO we should try to keep some discipline around the usage of
unwrap
, because we are getting some criticism from the community.for example: #723 (comment)