mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
Merge branch 'master' into add-proof-balance
This commit is contained in:
@@ -86,6 +86,14 @@ pub fn process_mine<'a, 'info>(
|
||||
return Err(OreError::HashInvalid.into());
|
||||
}
|
||||
|
||||
// Reject spam transactions.
|
||||
let t: i64 = clock.unix_timestamp;
|
||||
let t_target = proof.last_hash_at.saturating_add(ONE_MINUTE);
|
||||
let t_spam = t_target.saturating_sub(TOLERANCE);
|
||||
if t.lt(&t_spam) {
|
||||
return Err(OreError::Spam.into());
|
||||
}
|
||||
|
||||
// Validate hash satisfies the minimnum difficulty.
|
||||
let hash = solution.to_hash();
|
||||
let difficulty = hash.difficulty();
|
||||
@@ -102,10 +110,9 @@ pub fn process_mine<'a, 'info>(
|
||||
// If user has greater than or equal to the max stake on the network, they receive 2x multiplier.
|
||||
// Any stake less than this will receives between 1x and 2x multipler. The multipler is only active
|
||||
// if the miner's last stake deposit was more than one minute ago.
|
||||
let t = clock.unix_timestamp;
|
||||
if config.max_stake.gt(&0)
|
||||
if config.max_stake.gt(&0)
|
||||
&& proof.balance.gt(&0)
|
||||
&& proof.last_stake_at.saturating_add(ONE_MINUTE).le(&t)
|
||||
&& proof.balance > 0
|
||||
{
|
||||
let staking_reward = (reward as u128)
|
||||
.checked_mul(proof.balance.min(config.max_stake) as u128)
|
||||
@@ -115,13 +122,6 @@ pub fn process_mine<'a, 'info>(
|
||||
reward = reward.checked_add(staking_reward).unwrap();
|
||||
}
|
||||
|
||||
// Reject spam transactions.
|
||||
let t_target = proof.last_hash_at.saturating_add(ONE_MINUTE);
|
||||
let t_spam = t_target.saturating_sub(TOLERANCE);
|
||||
if t.lt(&t_spam) {
|
||||
return Err(OreError::Spam.into());
|
||||
}
|
||||
|
||||
// Apply liveness penalty.
|
||||
let t_liveness = t_target.saturating_add(TOLERANCE);
|
||||
if t.gt(&t_liveness) {
|
||||
|
||||
Reference in New Issue
Block a user