Skip to content

Commit

Permalink
fixup! compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CjS77 committed Feb 6, 2024
1 parent ae1b0c0 commit a41764d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion base_layer/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use tari_features::resolver::build_features;

fn main() {
build_features();
tari_common::build::ProtobufCompiler::new()
.include_paths(&["src/proto"])
.proto_paths(&[
Expand All @@ -33,5 +34,4 @@ fn main() {
.emit_rerun_if_changed_directives()
.compile()
.unwrap();
build_features();
}
12 changes: 7 additions & 5 deletions base_layer/core/src/consensus/consensus_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::{
consensus::network::NetworkConsensus,
proof_of_work::{Difficulty, PowAlgorithm},
transactions::{
tari_amount::{uT, MicroMinotari, T},
tari_amount::{uT, MicroMinotari},
transaction_components::{
OutputFeatures,
OutputFeaturesVersion,
Expand All @@ -49,7 +49,10 @@ use crate::{
weight::TransactionWeight,
},
};
#[cfg(not(tari_feature_mainnet_emission))]
use crate::transactions::tari_amount::T;

#[cfg(tari_feature_mainnet_emission)]
const ANNUAL_BLOCKS: u64 = 30 /* blocks/hr */ * 24 /* hr /d */ * 366 /* days / yr */;
/// This is the inner struct used to control all consensus values.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -924,8 +927,6 @@ impl ConsensusConstantsBuilder {

#[cfg(test)]
mod test {
use std::convert::TryFrom;

use crate::{
consensus::{
emission::{Emission, EmissionSchedule},
Expand All @@ -936,7 +937,9 @@ mod test {
transaction_components::{OutputType, RangeProofType},
},
};
use crate::transactions::tari_amount::T;
#[cfg(not(tari_feature_mainnet_emission))]
use std::convert::TryFrom;


#[test]
fn hybrid_pow_constants_are_well_formed() {
Expand Down Expand Up @@ -993,7 +996,6 @@ mod test {

#[test]
#[cfg(not(tari_feature_mainnet_emission))]

fn esmeralda_schedule() {
let esmeralda = ConsensusConstants::esmeralda();
let schedule = EmissionSchedule::new(
Expand Down
14 changes: 7 additions & 7 deletions base_layer/core/src/consensus/emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::cmp;

use crate::transactions::tari_amount::MicroMinotari;

pub trait Emission {
Expand Down Expand Up @@ -151,7 +149,7 @@ impl EmissionSchedule {
///
/// Input : `k`: A string representing a floating point number of (nearly) arbitrary precision, and less than one.
///
/// Returns: An array of powers of negative two when when applied as a shift right and sum operation is very
/// Returns: An array of powers of negative two when applied as a shift right and sum operation is very
/// close to (1-k)*n.
///
/// None - If k is not a valid floating point number less than one.
Expand Down Expand Up @@ -281,7 +279,7 @@ impl<'a> EmissionRate<'a> {
/// Then we calculate k.R = (1 - e).R = R - e.R = R - (0.5 * R + 0.25 * R) = R - R >> 1 - R >> 2
#[cfg(not(tari_feature_mainnet_emission))]
fn next_reward(&mut self) {
let reward = cmp::max(self.next_decay_reward(), self.schedule.tail);
let reward = std::cmp::max(self.next_decay_reward(), self.schedule.tail);
self.reward = reward;
}

Expand Down Expand Up @@ -353,11 +351,12 @@ impl Emission for EmissionSchedule {

#[cfg(test)]
mod test {
use num_traits::abs_sub;
use crate::{
consensus::emission::{Emission, EmissionSchedule},
transactions::tari_amount::{uT, MicroMinotari, T},
consensus::emission::{EmissionSchedule},
transactions::tari_amount::{MicroMinotari, T},
};
#[cfg(not(tari_feature_mainnet_emission))]
use crate::consensus::emission::Emission;

#[test]
#[cfg(not(tari_feature_mainnet_emission))]
Expand Down Expand Up @@ -497,6 +496,7 @@ mod test {
#[allow(clippy::identity_op)]
#[cfg(not(tari_feature_mainnet_emission))]
fn emission() {
use crate::transactions::tari_amount::uT;
let emission = EmissionSchedule::new(1 * T, &[1, 2], 100 * uT);
let mut emission = emission.iter();
// decay is 1 - 0.25 - 0.125 = 0.625
Expand Down
2 changes: 0 additions & 2 deletions base_layer/core/tests/helpers/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ use tokio::sync::{broadcast, watch};

use crate::helpers::{block_builders::{append_block, create_genesis_block}, nodes::{create_network_with_multiple_base_nodes_with_config, NodeInterfaces}, sample_blockchains};

static EMISSION: [u64; 2] = [10, 10];

/// Helper function to initialize header sync with a single peer
pub fn initialize_sync_headers_with_ping_pong_data(
local_node_interfaces: &NodeInterfaces,
Expand Down
1 change: 0 additions & 1 deletion base_layer/core/tests/tests/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,6 @@ async fn test_reorg() {
mempool.process_reorg(vec![], vec![reorg_block4.into()]).await.unwrap();
}

static EMISSION: [u64; 2] = [10, 10];
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[allow(clippy::too_many_lines)]
#[allow(clippy::identity_op)]
Expand Down
3 changes: 1 addition & 2 deletions base_layer/core/tests/tests/node_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tari_core::{
},
blocks::{ChainBlock, NewBlock},
chain_storage::BlockchainDatabaseConfig,
consensus::{ConsensusConstantsBuilder, ConsensusManager, ConsensusManagerBuilder, NetworkConsensus},
consensus::{ConsensusManager, ConsensusManagerBuilder, NetworkConsensus},
mempool::TxStorageResponse,
proof_of_work::{randomx_factory::RandomXFactory, Difficulty, PowAlgorithm},
transactions::{
Expand Down Expand Up @@ -220,7 +220,6 @@ async fn propagate_and_forward_many_valid_blocks() {
dan_node.shutdown().await;
}

static EMISSION: [u64; 2] = [10, 10];
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[allow(clippy::too_many_lines)]
async fn propagate_and_forward_invalid_block_hash() {
Expand Down
3 changes: 1 addition & 2 deletions base_layer/core/tests/tests/node_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use tari_core::{
SyncValidators,
},
chain_storage::BlockchainDatabaseConfig,
consensus::{ConsensusConstantsBuilder, ConsensusManagerBuilder},
consensus::{ConsensusManagerBuilder},
mempool::MempoolServiceConfig,
proof_of_work::{randomx_factory::RandomXFactory, Difficulty},
test_helpers::blockchain::create_test_blockchain_db,
Expand Down Expand Up @@ -66,7 +66,6 @@ use crate::helpers::{
},
};

static EMISSION: [u64; 2] = [10, 10];
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_listening_lagging() {
let network = Network::LocalNet;
Expand Down

0 comments on commit a41764d

Please sign in to comment.