Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 2e14e91

Browse files
committed
better target difficulty
1 parent a748687 commit 2e14e91

File tree

4 files changed

+66
-49
lines changed

4 files changed

+66
-49
lines changed

Cargo.lock

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ version = "0.2.12"
66
[dependencies]
77
anyhow = "*"
88
clap = { version = "4.5.0", features = ["derive"] }
9-
minotari_app_grpc = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
9+
minotari_app_grpc = { git = "http://github.com/tari-project/tari" }
1010
num-format = "0.4.4"
1111
serde = { version = "1.0.130", features = ["derive"] }
1212
serde_json = "1.0.68"
1313
sha3 = "0.10"
14-
tari_common = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
15-
tari_common_types = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
16-
tari_core = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info", default-features = false, features = [
14+
tari_common = { git = "http://github.com/tari-project/tari" }
15+
tari_common_types = { git = "http://github.com/tari-project/tari" }
16+
tari_core = { git = "https://github.com/tari-project/tari", default-features = false, features = [
1717
"transactions",
1818
] }
1919
tari_crypto = { version = "0.21", features = ["borsh"] }
20-
tari_key_manager = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
21-
tari_script = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
22-
tari_shutdown = { git = "http://github.com/stringhandler/tari", branch = "st-add-p2pool-tip-info" }
20+
tari_key_manager = { git = "http://github.com/tari-project/tari" }
21+
tari_script = { git = "http://github.com/tari-project/tari" }
22+
tari_shutdown = { git = "https://github.com/tari-project/tari.git" }
2323
tari_utilities = "0.8"
2424

2525
libsqlite3-sys = { version = "0.25.1", features = ["bundled"] }

src/main.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ async fn run_template_height_watcher(config: ConfigFile, shutdown: ShutdownSigna
639639
if last_template_time.elapsed() > Duration::from_secs(config.template_refresh_secs) {
640640
info!(target: LOG_TARGET, "Template refresh time elapsed. Dumping block template.");
641641
must_refresh = true;
642-
last_template_time = Instant::now();
643642
}
644643

645644
curr_node_height = height_data.height;
@@ -672,6 +671,7 @@ async fn run_template_height_watcher(config: ConfigFile, shutdown: ShutdownSigna
672671
continue;
673672
},
674673
};
674+
last_template_time = Instant::now();
675675
// clear_block_template_cache().await;
676676
replace_block_template_cache(template).await;
677677
println!("Block template refreshed");
@@ -933,6 +933,7 @@ async fn get_template_from_client(
933933
node_client.get_new_block(NewBlockTemplate::default()),
934934
)
935935
.await??;
936+
// dbg!(&block_result);
936937
let block = block_result.result.block.unwrap();
937938
let mut header: BlockHeader = block
938939
.clone()
@@ -948,9 +949,24 @@ async fn get_template_from_client(
948949
block.clone().header.unwrap().timestamp.to_string(),
949950
header.mining_hash().clone().to_string()
950951
);
952+
println!(
953+
"New template, difficulty: {}, minerdata {}",
954+
block_result.target_difficulty,
955+
block_result
956+
.result
957+
.miner_data
958+
.as_ref()
959+
.map(|m| m.target_difficulty)
960+
.unwrap_or_default()
961+
);
951962
// return Ok(());
952963
return Ok(BlockTemplateData {
953-
target_difficulty: block_result.target_difficulty,
964+
target_difficulty: block_result
965+
.result
966+
.miner_data
967+
.as_ref()
968+
.map(|m| m.target_difficulty)
969+
.unwrap_or(block_result.target_difficulty),
954970
block,
955971
header,
956972
mining_hash,

src/node_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub enum ClientType {
135135
P2Pool(TariAddress),
136136
}
137137

138+
#[derive(Debug)]
138139
pub struct NewBlockResult {
139140
pub result: GetNewBlockResult,
140141
pub target_difficulty: u64,

0 commit comments

Comments
 (0)