mirror of
https://github.com/tig-foundation/tig-monorepo.git
synced 2026-02-21 18:37:48 +08:00
Require min solution ratio.
This commit is contained in:
parent
ca35a60126
commit
a1d2134c3d
@ -93,6 +93,7 @@ pub struct AddBlockCache {
|
||||
pub active_players_block_data: HashMap<String, PlayerBlockData>,
|
||||
pub active_opow_block_data: HashMap<String, OPoWBlockData>,
|
||||
pub active_challenges_block_data: HashMap<String, ChallengeBlockData>,
|
||||
pub active_challenges_prev_block_data: HashMap<String, ChallengeBlockData>,
|
||||
pub active_algorithms_state: HashMap<String, AlgorithmState>,
|
||||
pub active_algorithms_details: HashMap<String, AlgorithmDetails>,
|
||||
pub active_algorithms_block_data: HashMap<String, AlgorithmBlockData>,
|
||||
|
||||
@ -11,6 +11,7 @@ pub(crate) async fn update(cache: &mut AddBlockCache) {
|
||||
block_details,
|
||||
block_data,
|
||||
active_challenges_block_data,
|
||||
active_challenges_prev_block_data,
|
||||
active_algorithms_state,
|
||||
active_algorithms_details,
|
||||
active_algorithms_block_data,
|
||||
@ -136,7 +137,12 @@ pub(crate) async fn update(cache: &mut AddBlockCache) {
|
||||
let mut max_qualifiers_by_player = max_qualifiers_by_player.clone();
|
||||
let mut curr_frontier_index = 0;
|
||||
let challenge_data = active_challenges_block_data.get_mut(challenge_id).unwrap();
|
||||
for (settings, &num_solutions, _) in solutions.iter() {
|
||||
let prev_solution_ratio = active_challenges_prev_block_data
|
||||
.get(challenge_id)
|
||||
.map(|x| x.average_solution_ratio)
|
||||
.unwrap_or_default();
|
||||
let min_solution_ratio = prev_solution_ratio * config.opow.min_solution_ratio_factor;
|
||||
for (settings, &num_solutions, &num_nonces) in solutions.iter() {
|
||||
let BenchmarkSettings {
|
||||
player_id,
|
||||
algorithm_id,
|
||||
@ -164,7 +170,12 @@ pub(crate) async fn update(cache: &mut AddBlockCache) {
|
||||
let algorithm_data = active_algorithms_block_data.get_mut(algorithm_id).unwrap();
|
||||
|
||||
let max_qualifiers = max_qualifiers_by_player.get(player_id).unwrap().clone();
|
||||
let num_qualifiers = num_solutions.min(max_qualifiers);
|
||||
let solution_ratio = num_solutions as f64 / num_nonces as f64;
|
||||
let num_qualifiers = if solution_ratio >= min_solution_ratio {
|
||||
num_solutions.min(max_qualifiers)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
max_qualifiers_by_player.insert(player_id.clone(), max_qualifiers - num_qualifiers);
|
||||
|
||||
if num_qualifiers > 0 {
|
||||
|
||||
@ -112,6 +112,7 @@ serializable_struct_with_getters! {
|
||||
deposit_to_cutoff_ratio: f64,
|
||||
max_coinbase_outputs: usize,
|
||||
coinbase_update_period: u32,
|
||||
min_solution_ratio_factor: f64,
|
||||
}
|
||||
}
|
||||
serializable_struct_with_getters! {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user