diff --git a/applications/minotari_app_grpc/src/conversions/mod.rs b/applications/minotari_app_grpc/src/conversions/mod.rs index efd583fcc3..be41626cc8 100644 --- a/applications/minotari_app_grpc/src/conversions/mod.rs +++ b/applications/minotari_app_grpc/src/conversions/mod.rs @@ -22,7 +22,7 @@ mod aggregate_body; mod base_node_state; -mod block; +pub mod block; mod block_header; mod chain_metadata; mod com_and_pub_signature; diff --git a/applications/minotari_miner/src/run_miner.rs b/applications/minotari_miner/src/run_miner.rs index 7a1306c2ac..7d200f5017 100644 --- a/applications/minotari_miner/src/run_miner.rs +++ b/applications/minotari_miner/src/run_miner.rs @@ -22,8 +22,17 @@ use std::{convert::TryFrom, str::FromStr, sync::Arc, thread, time::Instant}; +use crate::{ + cli::Cli, + config::MinerConfig, + errors::{err_empty, MinerError}, + miner::{Miner, MiningReport}, + stratum::stratum_controller::controller::Controller, +}; use futures::stream::StreamExt; use log::*; +use minotari_app_grpc::tari_rpc::pow_algo::PowAlgos; +use minotari_app_grpc::tari_rpc::PowAlgo; use minotari_app_grpc::{ authentication::ClientAuthenticationInterceptor, tari_rpc::{ @@ -65,14 +74,6 @@ use tari_utilities::hex::Hex; use tokio::{sync::Mutex, time::sleep}; use tonic::transport::{Certificate, ClientTlsConfig, Endpoint}; -use crate::{ - cli::Cli, - config::MinerConfig, - errors::{err_empty, MinerError}, - miner::{Miner, MiningReport}, - stratum::stratum_controller::controller::Controller, -}; - pub const LOG_TARGET: &str = "minotari::miner::main"; pub const LOG_TARGET_FILE: &str = "minotari::logging::miner::main"; @@ -178,7 +179,7 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> { &wallet_payment_address, &consensus_manager, ) - .await + .await { err @ Err(MinerError::GrpcConnection(_)) | err @ Err(MinerError::GrpcStatus(_)) => { // Any GRPC error we will try to reconnect with a standard delay @@ -191,31 +192,31 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> { base_node_client = nc.base_node_client; p2pool_node_client = nc.p2pool_node_client; break; - }, + } Err(err) => { error!(target: LOG_TARGET, "Connection error: {:?}", err); continue; - }, + } } } - }, + } Err(MinerError::MineUntilHeightReached(h)) => { warn!( target: LOG_TARGET, "Prescribed blockchain height {} reached. Aborting ...", h ); return Ok(()); - }, + } Err(MinerError::MinerLostBlock(h)) => { warn!( target: LOG_TARGET, "Height {} already mined by other node. Restarting ...", h ); - }, + } Err(err) => { error!(target: LOG_TARGET, "Error: {:?}", err); sleep(config.wait_timeout()).await; - }, + } Ok(submitted) => { info!(target: LOG_TARGET, "💰 Found block"); if submitted { @@ -226,7 +227,7 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> { return Ok(()); } } - }, + } } } } @@ -247,7 +248,7 @@ async fn connect(config: &MinerConfig) -> Result { `--enable-grpc` or enable it in the config."; println!("{}", msg); return Err(e); - }, + } }; // init client to sha p2pool grpc if enabled @@ -261,7 +262,7 @@ async fn connect(config: &MinerConfig) -> Result { `--enable-grpc` or enable it in the config."; println!("{}", msg); return Err(e); - }, + } }; } @@ -380,7 +381,7 @@ async fn get_new_block( wallet_payment_address, consensus_manager, ) - .await + .await } async fn get_new_block_base_node( @@ -430,8 +431,8 @@ async fn get_new_block_base_node( config.range_proof_type, PaymentId::Empty, ) - .await - .map_err(|e| MinerError::CoinbaseError(e.to_string()))?; + .await + .map_err(|e| MinerError::CoinbaseError(e.to_string()))?; debug!(target: LOG_TARGET, "Coinbase kernel: {}", coinbase_kernel); debug!(target: LOG_TARGET, "Coinbase output: {}", coinbase_output); @@ -456,7 +457,7 @@ async fn get_new_block_p2pool_node( sha_p2pool_client: &mut ShaP2PoolGrpcClient, ) -> Result { let block_result = sha_p2pool_client - .get_new_block(GetNewBlockRequest::default()) + .get_new_block(GetNewBlockRequest { pow: Some(PowAlgo { pow_algo: i32::from(PowAlgos::Sha3x) }) }) .await? .into_inner(); let new_block_result = block_result.block.ok_or_else(|| err_empty("block result"))?; @@ -514,7 +515,7 @@ async fn mining_cycle( wallet_payment_address, consensus_manager, ) - .await?; + .await?; let block = block_result.block; let header = block.clone().header.ok_or_else(|| err_empty("block.header"))?; @@ -567,7 +568,7 @@ async fn mining_cycle( mined_block, wallet_payment_address, ) - .await?; + .await?; block_submitted = true; break; } else {