mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Fix off-by-one error when reducing account level during block orphaning.
Added test to cover above. Modified test-chain-v2.json so Dilbert starts with level 5, not 8, to reduce number of blocks minted during tests.
This commit is contained in:
@@ -192,6 +192,17 @@ public class Account {
|
||||
|
||||
// Minting blocks
|
||||
|
||||
/** Returns whether account can be considered a "minting account".
|
||||
* <p>
|
||||
* To be considered a "minting account", the account needs to pass at least one of these tests:<br>
|
||||
* <ul>
|
||||
* <li>account's level is at least <tt>minAccountLevelToMint</tt> from blockchain config</li>
|
||||
* <li>account has 'founder' flag set</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return true if account can be considered "minting account"
|
||||
* @throws DataException
|
||||
*/
|
||||
public boolean canMint() throws DataException {
|
||||
Integer level = this.getLevel();
|
||||
if (level != null && level >= BlockChain.getInstance().getMinAccountLevelToMint())
|
||||
@@ -203,6 +214,17 @@ public class Account {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns whether account can build reward-shares.
|
||||
* <p>
|
||||
* To be able to create reward-shares, the account needs to pass at least one of these tests:<br>
|
||||
* <ul>
|
||||
* <li>account's level is at least <tt>minAccountLevelToRewardShare</tt> from blockchain config</li>
|
||||
* <li>account has 'founder' flag set</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return true if account can be considered "minting account"
|
||||
* @throws DataException
|
||||
*/
|
||||
public boolean canRewardShare() throws DataException {
|
||||
Integer level = this.getLevel();
|
||||
if (level != null && level >= BlockChain.getInstance().getMinAccountLevelToRewardShare())
|
||||
|
@@ -1584,7 +1584,7 @@ public class Block {
|
||||
|
||||
final int effectiveBlocksMinted = cumulativeBlocksByLevel.get(accountData.getInitialLevel()) + accountData.getBlocksMinted();
|
||||
|
||||
for (int newLevel = maximumLevel; newLevel > 0; --newLevel)
|
||||
for (int newLevel = maximumLevel; newLevel >= 0; --newLevel)
|
||||
if (effectiveBlocksMinted >= cumulativeBlocksByLevel.get(newLevel)) {
|
||||
if (newLevel < accountData.getLevel()) {
|
||||
// Account has decreased in level!
|
||||
|
Reference in New Issue
Block a user