Skip to content

Commit d5ec945

Browse files
authored
fix: return min results (#7098)
Description --- fixes gprc call network state to always return results even if all the algos are not enabled <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved error handling when retrieving target difficulty for proof-of-work algorithms, ensuring the network state is returned even if some values cannot be determined. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent d98e56b commit d5ec945

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

applications/minotari_node/src/grpc/base_node_grpc_server.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use tari_core::{
6262
consensus::{emission::Emission, ConsensusManager, NetworkConsensus},
6363
iterators::NonOverlappingIntegerPairIter,
6464
mempool::{service::LocalMempoolService, TxStorageResponse},
65-
proof_of_work::PowAlgorithm,
65+
proof_of_work::{Difficulty, PowAlgorithm},
6666
transactions::{
6767
generate_coinbase_with_wallet_output,
6868
transaction_components::{
@@ -424,7 +424,8 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
424424
e.to_string()
425425
);
426426
obscure_error_if_true(report_error_flag, Status::internal(e.to_string()))
427-
})?;
427+
})
428+
.unwrap_or(Difficulty::min());
428429
let target_time = constants.pow_target_block_interval(PowAlgorithm::Sha3x);
429430
let estimated_hash_rate = target_difficulty.as_u64().checked_div(target_time).unwrap_or(0);
430431
self.data_cache
@@ -450,7 +451,8 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
450451
e.to_string()
451452
);
452453
obscure_error_if_true(report_error_flag, Status::internal(e.to_string()))
453-
})?;
454+
})
455+
.unwrap_or(Difficulty::min());
454456
let target_time = constants.pow_target_block_interval(PowAlgorithm::RandomXM);
455457
let estimated_hash_rate = target_difficulty.as_u64().checked_div(target_time).unwrap_or(0);
456458
self.data_cache
@@ -477,7 +479,8 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
477479
e.to_string()
478480
);
479481
obscure_error_if_true(report_error_flag, Status::internal(e.to_string()))
480-
})?;
482+
})
483+
.unwrap_or(Difficulty::min());
481484
let target_time = constants.pow_target_block_interval(PowAlgorithm::RandomXT);
482485
let estimated_hash_rate = target_difficulty.as_u64().checked_div(target_time).unwrap_or(0);
483486
self.data_cache

0 commit comments

Comments
 (0)