Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions integration-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 18 additions & 17 deletions miner-apps/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions miner-apps/translator/src/lib/sv1/sv1_server/difficulty_manager.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use std::sync::Arc;

use crate::sv1::sv1_server::PendingTargetUpdate;
use crate::sv1::sv1_server::{
PendingTargetUpdate, SV1_MIN_DIFFICULTY_FOR_INTEGER_POWER_OF_TWO_ROUNDING,
};

use stratum_apps::{
stratum_core::{
bitcoin::Target,
channels_sv2::{target::hash_rate_to_target, Vardiff},
mining_sv2::{SetTarget, UpdateChannel},
parsers_sv2::Mining,
stratum_translation::sv2_to_sv1::build_sv1_set_difficulty_from_sv2_target,
stratum_translation::sv2_to_sv1::build_sv1_set_difficulty_from_sv2_target_with_integer_power_of_two_rounding,
},
utils::types::{ChannelId, DownstreamId, Hashrate},
};
Expand Down Expand Up @@ -159,7 +161,12 @@ impl Sv1Server {
// Process immediate set_difficulty updates (for new_target >= upstream_target)
for (_channel_id, downstream_id, target) in immediate_updates {
// Send set_difficulty message immediately
if let Ok(set_difficulty_msg) = build_sv1_set_difficulty_from_sv2_target(target) {
if let Ok(set_difficulty_msg) =
build_sv1_set_difficulty_from_sv2_target_with_integer_power_of_two_rounding(
target,
SV1_MIN_DIFFICULTY_FOR_INTEGER_POWER_OF_TWO_ROUNDING,
)
{
let downstream_id = downstream_id.unwrap_or(0);
if let Some(sender) = self
.sv1_server_io
Expand Down Expand Up @@ -432,7 +439,10 @@ impl Sv1Server {
) {
for update in difficulty_updates {
let set_difficulty_msg =
match build_sv1_set_difficulty_from_sv2_target(update.new_target) {
match build_sv1_set_difficulty_from_sv2_target_with_integer_power_of_two_rounding(
update.new_target,
SV1_MIN_DIFFICULTY_FOR_INTEGER_POWER_OF_TWO_ROUNDING,
) {
Ok(msg) => msg,
Err(e) => {
error!(
Expand Down
Loading
Loading