forked from Qortal/qortal
Added member of group check
This commit is contained in:
parent
c58d2b5813
commit
d0139c24dc
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
|||||||
<ciyam-at.version>1.4.2</ciyam-at.version>
|
<ciyam-at.version>1.4.2</ciyam-at.version>
|
||||||
<commons-net.version>3.8.0</commons-net.version>
|
<commons-net.version>3.8.0</commons-net.version>
|
||||||
<commons-text.version>1.12.0</commons-text.version>
|
<commons-text.version>1.12.0</commons-text.version>
|
||||||
<commons-io.version>2.16.1</commons-io.version>
|
<commons-io.version>2.17.0</commons-io.version>
|
||||||
<commons-compress.version>1.27.1</commons-compress.version>
|
<commons-compress.version>1.27.1</commons-compress.version>
|
||||||
<commons-lang3.version>3.17.0</commons-lang3.version>
|
<commons-lang3.version>3.17.0</commons-lang3.version>
|
||||||
<dagger.version>1.2.2</dagger.version>
|
<dagger.version>1.2.2</dagger.version>
|
||||||
|
@ -9,6 +9,7 @@ import org.qortal.data.account.AccountData;
|
|||||||
import org.qortal.data.account.RewardShareData;
|
import org.qortal.data.account.RewardShareData;
|
||||||
import org.qortal.data.naming.NameData;
|
import org.qortal.data.naming.NameData;
|
||||||
import org.qortal.repository.DataException;
|
import org.qortal.repository.DataException;
|
||||||
|
import org.qortal.repository.GroupRepository;
|
||||||
import org.qortal.repository.NameRepository;
|
import org.qortal.repository.NameRepository;
|
||||||
import org.qortal.repository.Repository;
|
import org.qortal.repository.Repository;
|
||||||
import org.qortal.settings.Settings;
|
import org.qortal.settings.Settings;
|
||||||
@ -197,11 +198,11 @@ public class Account {
|
|||||||
|
|
||||||
/** Returns whether account can be considered a "minting account".
|
/** Returns whether account can be considered a "minting account".
|
||||||
* <p>
|
* <p>
|
||||||
* To be considered a "minting account", the account needs to pass at least one of these tests:<br>
|
* To be considered a "minting account", the account needs to pass all of these tests:<br>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>account's level is at least <tt>minAccountLevelToMint</tt> from blockchain config</li>
|
* <li>account's level is at least <tt>minAccountLevelToMint</tt> from blockchain config</li>
|
||||||
* <li>account's address have registered a name</li>
|
* <li>account's address have registered a name</li>
|
||||||
* <li>account has 'founder' flag set</li>
|
* <li>account's address is member of minter group</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return true if account can be considered "minting account"
|
* @return true if account can be considered "minting account"
|
||||||
@ -210,27 +211,52 @@ public class Account {
|
|||||||
public boolean canMint() throws DataException {
|
public boolean canMint() throws DataException {
|
||||||
AccountData accountData = this.repository.getAccountRepository().getAccount(this.address);
|
AccountData accountData = this.repository.getAccountRepository().getAccount(this.address);
|
||||||
NameRepository nameRepository = this.repository.getNameRepository();
|
NameRepository nameRepository = this.repository.getNameRepository();
|
||||||
|
GroupRepository groupRepository = this.repository.getGroupRepository();
|
||||||
|
|
||||||
int blockchainHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
int blockchainHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
||||||
int nameCheckHeight = BlockChain.getInstance().getOnlyMintWithNameHeight();
|
int nameCheckHeight = BlockChain.getInstance().getOnlyMintWithNameHeight();
|
||||||
int levelToMint = BlockChain.getInstance().getMinAccountLevelToMint();
|
int levelToMint = BlockChain.getInstance().getMinAccountLevelToMint();
|
||||||
int level = accountData.getLevel();
|
int level = accountData.getLevel();
|
||||||
|
int groupIdToMint = BlockChain.getInstance().getMintingGroupId();
|
||||||
|
int groupCheckHeight = BlockChain.getInstance().getGroupMemberCheckHeight();
|
||||||
|
|
||||||
String myAddress = accountData.getAddress();
|
String myAddress = accountData.getAddress();
|
||||||
List<NameData> myName = nameRepository.getNamesByOwner(myAddress);
|
List<NameData> myName = nameRepository.getNamesByOwner(myAddress);
|
||||||
|
boolean isMember = groupRepository.memberExists(groupIdToMint, myAddress);
|
||||||
|
|
||||||
if (accountData == null)
|
if (accountData == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Can only mint if level is at least minAccountLevelToMint< from blockchain config
|
||||||
if (blockchainHeight < nameCheckHeight && level >= levelToMint)
|
if (blockchainHeight < nameCheckHeight && level >= levelToMint)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Can only mint if have registered a name
|
// Can only mint if have registered a name
|
||||||
if (blockchainHeight >= nameCheckHeight && level >= levelToMint && !myName.isEmpty())
|
if (blockchainHeight >= nameCheckHeight && blockchainHeight < groupCheckHeight && level >= levelToMint && !myName.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Founders can always mint, unless they have a penalty
|
// Can only mint if have registered a name and is member of minter group id
|
||||||
if (Account.isFounder(accountData.getFlags()) && accountData.getBlocksMintedPenalty() == 0)
|
if (blockchainHeight >= groupCheckHeight && level >= levelToMint && !myName.isEmpty() && isMember)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Founders needs to pass same tests like minters
|
||||||
|
if (blockchainHeight < nameCheckHeight &&
|
||||||
|
Account.isFounder(accountData.getFlags()) &&
|
||||||
|
accountData.getBlocksMintedPenalty() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (blockchainHeight >= nameCheckHeight &&
|
||||||
|
blockchainHeight < groupCheckHeight &&
|
||||||
|
Account.isFounder(accountData.getFlags()) &&
|
||||||
|
accountData.getBlocksMintedPenalty() == 0 &&
|
||||||
|
!myName.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (blockchainHeight >= groupCheckHeight &&
|
||||||
|
Account.isFounder(accountData.getFlags()) &&
|
||||||
|
accountData.getBlocksMintedPenalty() == 0 &&
|
||||||
|
!myName.isEmpty() &&
|
||||||
|
isMember)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -83,7 +83,9 @@ public class BlockChain {
|
|||||||
enableTransferPrivsTimestamp,
|
enableTransferPrivsTimestamp,
|
||||||
cancelSellNameValidationTimestamp,
|
cancelSellNameValidationTimestamp,
|
||||||
disableRewardshareHeight,
|
disableRewardshareHeight,
|
||||||
onlyMintWithNameHeight
|
enableRewardshareHeight,
|
||||||
|
onlyMintWithNameHeight,
|
||||||
|
groupMemberCheckHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom transaction fees
|
// Custom transaction fees
|
||||||
@ -203,6 +205,7 @@ public class BlockChain {
|
|||||||
private int minAccountLevelToRewardShare;
|
private int minAccountLevelToRewardShare;
|
||||||
private int maxRewardSharesPerFounderMintingAccount;
|
private int maxRewardSharesPerFounderMintingAccount;
|
||||||
private int founderEffectiveMintingLevel;
|
private int founderEffectiveMintingLevel;
|
||||||
|
private int mintingGroupId;
|
||||||
|
|
||||||
/** Minimum time to retain online account signatures (ms) for block validity checks. */
|
/** Minimum time to retain online account signatures (ms) for block validity checks. */
|
||||||
private long onlineAccountSignaturesMinLifetime;
|
private long onlineAccountSignaturesMinLifetime;
|
||||||
@ -526,6 +529,10 @@ public class BlockChain {
|
|||||||
return this.onlineAccountSignaturesMaxLifetime;
|
return this.onlineAccountSignaturesMaxLifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMintingGroupId() {
|
||||||
|
return this.mintingGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
public CiyamAtSettings getCiyamAtSettings() {
|
public CiyamAtSettings getCiyamAtSettings() {
|
||||||
return this.ciyamAtSettings;
|
return this.ciyamAtSettings;
|
||||||
}
|
}
|
||||||
@ -620,10 +627,18 @@ public class BlockChain {
|
|||||||
return this.featureTriggers.get(FeatureTrigger.disableRewardshareHeight.name()).intValue();
|
return this.featureTriggers.get(FeatureTrigger.disableRewardshareHeight.name()).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getEnableRewardshareHeight() {
|
||||||
|
return this.featureTriggers.get(FeatureTrigger.enableRewardshareHeight.name()).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
public int getOnlyMintWithNameHeight() {
|
public int getOnlyMintWithNameHeight() {
|
||||||
return this.featureTriggers.get(FeatureTrigger.onlyMintWithNameHeight.name()).intValue();
|
return this.featureTriggers.get(FeatureTrigger.onlyMintWithNameHeight.name()).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGroupMemberCheckHeight() {
|
||||||
|
return this.featureTriggers.get(FeatureTrigger.groupMemberCheckHeight.name()).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
// More complex getters for aspects that change by height or timestamp
|
// More complex getters for aspects that change by height or timestamp
|
||||||
|
|
||||||
public long getRewardAtHeight(int ourHeight) {
|
public long getRewardAtHeight(int ourHeight) {
|
||||||
|
@ -99,10 +99,11 @@ public class RewardShareTransaction extends Transaction {
|
|||||||
@Override
|
@Override
|
||||||
public ValidationResult isValid() throws DataException {
|
public ValidationResult isValid() throws DataException {
|
||||||
final int disableRs = BlockChain.getInstance().getDisableRewardshareHeight();
|
final int disableRs = BlockChain.getInstance().getDisableRewardshareHeight();
|
||||||
|
final int enableRs = BlockChain.getInstance().getEnableRewardshareHeight();
|
||||||
int blockchainHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
int blockchainHeight = this.repository.getBlockRepository().getBlockchainHeight();
|
||||||
|
|
||||||
// Check if reward share is disabled.
|
// Check if reward share is disabled.
|
||||||
if (blockchainHeight >= disableRs)
|
if (blockchainHeight >= disableRs && blockchainHeight < enableRs)
|
||||||
return ValidationResult.GENERAL_TEMPORARY_DISABLED;
|
return ValidationResult.GENERAL_TEMPORARY_DISABLED;
|
||||||
|
|
||||||
// Check reward share given to recipient. Negative is potentially OK to end a current reward-share. Zero also fine.
|
// Check reward share given to recipient. Negative is potentially OK to end a current reward-share. Zero also fine.
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
"blockRewardBatchStartHeight": 1508000,
|
"blockRewardBatchStartHeight": 1508000,
|
||||||
"blockRewardBatchSize": 1000,
|
"blockRewardBatchSize": 1000,
|
||||||
"blockRewardBatchAccountsBlockCount": 25,
|
"blockRewardBatchAccountsBlockCount": 25,
|
||||||
|
"mintingGroupId": 99999,
|
||||||
"rewardsByHeight": [
|
"rewardsByHeight": [
|
||||||
{ "height": 1, "reward": 5.00 },
|
{ "height": 1, "reward": 5.00 },
|
||||||
{ "height": 259201, "reward": 4.75 },
|
{ "height": 259201, "reward": 4.75 },
|
||||||
@ -105,8 +106,10 @@
|
|||||||
"disableTransferPrivsTimestamp": 1706745000000,
|
"disableTransferPrivsTimestamp": 1706745000000,
|
||||||
"enableTransferPrivsTimestamp": 1709251200000,
|
"enableTransferPrivsTimestamp": 1709251200000,
|
||||||
"cancelSellNameValidationTimestamp": 1676986362069,
|
"cancelSellNameValidationTimestamp": 1676986362069,
|
||||||
"disableRewardshareHeight": 9999990,
|
"disableRewardshareHeight": 9999800,
|
||||||
"onlyMintWithNameHeight": 9999900
|
"enableRewardshareHeight": 9999850,
|
||||||
|
"onlyMintWithNameHeight": 9999900,
|
||||||
|
"groupMemberCheckHeight": 9999950
|
||||||
},
|
},
|
||||||
"checkpoints": [
|
"checkpoints": [
|
||||||
{ "height": 1136300, "signature": "3BbwawEF2uN8Ni5ofpJXkukoU8ctAPxYoFB7whq9pKfBnjfZcpfEJT4R95NvBDoTP8WDyWvsUvbfHbcr9qSZuYpSKZjUQTvdFf6eqznHGEwhZApWfvXu6zjGCxYCp65F4jsVYYJjkzbjmkCg5WAwN5voudngA23kMK6PpTNygapCzXt" }
|
{ "height": 1136300, "signature": "3BbwawEF2uN8Ni5ofpJXkukoU8ctAPxYoFB7whq9pKfBnjfZcpfEJT4R95NvBDoTP8WDyWvsUvbfHbcr9qSZuYpSKZjUQTvdFf6eqznHGEwhZApWfvXu6zjGCxYCp65F4jsVYYJjkzbjmkCg5WAwN5voudngA23kMK6PpTNygapCzXt" }
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
"blockRewardBatchStartHeight": 2000000,
|
"blockRewardBatchStartHeight": 2000000,
|
||||||
"blockRewardBatchSize": 1000,
|
"blockRewardBatchSize": 1000,
|
||||||
"blockRewardBatchAccountsBlockCount": 25,
|
"blockRewardBatchAccountsBlockCount": 25,
|
||||||
|
"mintingGroupId": 2,
|
||||||
"rewardsByHeight": [
|
"rewardsByHeight": [
|
||||||
{ "height": 1, "reward": 5.00 },
|
{ "height": 1, "reward": 5.00 },
|
||||||
{ "height": 259201, "reward": 4.75 },
|
{ "height": 259201, "reward": 4.75 },
|
||||||
@ -103,7 +104,9 @@
|
|||||||
"enableTransferPrivsTimestamp": 9999999999999,
|
"enableTransferPrivsTimestamp": 9999999999999,
|
||||||
"cancelSellNameValidationTimestamp": 9999999999999,
|
"cancelSellNameValidationTimestamp": 9999999999999,
|
||||||
"disableRewardshareHeight": 8450,
|
"disableRewardshareHeight": 8450,
|
||||||
"onlyMintWithNameHeight": 8500
|
"enableRewardshareHeight": 11400,
|
||||||
|
"onlyMintWithNameHeight": 8500,
|
||||||
|
"groupMemberCheckHeight": 11200
|
||||||
},
|
},
|
||||||
"genesisInfo": {
|
"genesisInfo": {
|
||||||
"version": 4,
|
"version": 4,
|
||||||
|
Loading…
Reference in New Issue
Block a user