mirror of
https://github.com/tig-foundation/tig-monorepo.git
synced 2026-02-21 10:27:49 +08:00
Fix set_coinbase not exported.
Some checks are pending
Test Workspace / Test Workspace (push) Waiting to run
Some checks are pending
Test Workspace / Test Workspace (push) Waiting to run
This commit is contained in:
parent
64b228f394
commit
4029d4fcc2
@ -34,8 +34,10 @@ pub async fn set_coinbase<T: Context>(
|
||||
}
|
||||
}
|
||||
|
||||
if coinbase.values().any(|&v| v <= 0.0) {
|
||||
return Err(anyhow!("Fraction cannot be zero or negative"));
|
||||
if coinbase.values().any(|&v| v <= 0.0 || v > 1.0) {
|
||||
return Err(anyhow!(
|
||||
"Fraction must be greater than 0.0 and less than or equal to 1.0"
|
||||
));
|
||||
}
|
||||
|
||||
if coinbase.values().cloned().sum::<f64>() > 1.0 {
|
||||
@ -82,12 +84,14 @@ pub async fn set_delegatees<T: Context>(
|
||||
}
|
||||
}
|
||||
|
||||
if delegatees.values().any(|&v| v <= 0.0) {
|
||||
return Err(anyhow!("Fraction to delegate cannot be zero or negative"));
|
||||
if delegatees.values().any(|&v| v <= 0.0 || v > 1.0) {
|
||||
return Err(anyhow!(
|
||||
"Fraction must be greater than 0.0 and less than or equal to 1.0"
|
||||
));
|
||||
}
|
||||
|
||||
if delegatees.values().cloned().sum::<f64>() > 1.0 {
|
||||
return Err(anyhow!("Total fraction to delegate cannot exceed 1.0"));
|
||||
return Err(anyhow!("Total fraction cannot exceed 1.0"));
|
||||
}
|
||||
|
||||
for delegatee in delegatees.keys() {
|
||||
|
||||
@ -149,12 +149,17 @@ pub(crate) async fn update(cache: &mut AddBlockCache) {
|
||||
|x| x.value.clone(),
|
||||
);
|
||||
|
||||
if opow_data.reward == zero {
|
||||
continue;
|
||||
}
|
||||
|
||||
let shared_amount = if opow_data.delegated_weighted_deposit == zero {
|
||||
zero.clone()
|
||||
} else {
|
||||
opow_data.reward * PreciseNumber::from_f64(opow_data.reward_share)
|
||||
};
|
||||
let coinbase_amount = opow_data.reward - shared_amount;
|
||||
|
||||
for (output, fraction) in opow_data.coinbase.iter() {
|
||||
let player_data = active_players_block_data.get_mut(output).unwrap();
|
||||
let fraction = PreciseNumber::from_f64(*fraction);
|
||||
|
||||
@ -5,7 +5,7 @@ use context::*;
|
||||
pub use contracts::{
|
||||
algorithms::{submit_algorithm, submit_binary, submit_breakthrough},
|
||||
benchmarks::{submit_benchmark, submit_fraud, submit_precommit, submit_proof},
|
||||
players::{set_delegatees, set_reward_share, set_vote},
|
||||
players::{set_coinbase, set_delegatees, set_reward_share, set_vote},
|
||||
};
|
||||
|
||||
pub async fn add_block<T: Context>(ctx: &T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user