mirror of
https://github.com/tig-pool-nk/tig-monorepo.git
synced 2026-02-21 17:37:21 +08:00
Require a minimum number of nonces.
This commit is contained in:
parent
a1d2134c3d
commit
958ef783a4
@ -18,10 +18,6 @@ pub async fn submit_precommit<T: Context>(
|
||||
return Err(anyhow!("Invalid settings.player_id. Must be {}", player_id));
|
||||
}
|
||||
|
||||
if num_nonces == 0 {
|
||||
return Err(anyhow!("Invalid num_nonces. Must be greater than 0"));
|
||||
}
|
||||
|
||||
let config = ctx.get_config().await;
|
||||
|
||||
let latest_block_id = ctx.get_latest_block_id().await;
|
||||
@ -44,6 +40,15 @@ pub async fn submit_precommit<T: Context>(
|
||||
return Err(anyhow!("Invalid challenge '{}'", settings.challenge_id));
|
||||
}
|
||||
|
||||
// verify min nonces
|
||||
let min_nonces = config.benchmarks.min_nonces[&settings.challenge_id];
|
||||
if num_nonces < min_nonces {
|
||||
return Err(anyhow!(
|
||||
"Invalid num_nonces. Must be at least {}",
|
||||
min_nonces
|
||||
));
|
||||
}
|
||||
|
||||
// verify algorithm is active
|
||||
if !ctx
|
||||
.get_algorithm_state(&settings.algorithm_id)
|
||||
|
||||
@ -68,6 +68,7 @@ serializable_struct_with_getters! {
|
||||
min_per_nonce_fee: PreciseNumber,
|
||||
min_base_fee: PreciseNumber,
|
||||
runtime_configs: HashMap<AlgorithmType, RuntimeConfig>,
|
||||
min_nonces: HashMap<String, u32>,
|
||||
}
|
||||
}
|
||||
serializable_struct_with_getters! {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user