Skip to content

Commit afee145

Browse files
committed
fix(mechanism): optimize name of proposal
1 parent ad1c591 commit afee145

12 files changed

Lines changed: 38 additions & 38 deletions

File tree

actuator/src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public boolean execute(Object result) throws ContractExeException {
133133

134134
private void addTotalWeight(ResourceCode resourceCode, DynamicPropertiesStore dynamicStore,
135135
long frozenBalance, long increment) {
136-
long weight = dynamicStore.allowNewRewardEnable() ? increment : frozenBalance / TRX_PRECISION;
136+
long weight = dynamicStore.allowNewReward() ? increment : frozenBalance / TRX_PRECISION;
137137
switch (resourceCode) {
138138
case BANDWIDTH:
139139
dynamicStore.addTotalNetWeight(weight);

actuator/src/main/java/org/tron/core/actuator/UnfreezeBalanceActuator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public boolean execute(Object result) throws ContractExeException {
237237

238238
}
239239

240-
long weight = dynamicStore.allowNewRewardEnable() ? decrease : -unfreezeBalance / TRX_PRECISION;
240+
long weight = dynamicStore.allowNewReward() ? decrease : -unfreezeBalance / TRX_PRECISION;
241241
switch (unfreezeBalanceContract.getResource()) {
242242
case BANDWIDTH:
243243
dynamicStore

actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,18 +560,18 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
560560
}
561561
break;
562562
}
563-
case ALLOW_NEW_REWARD_ALGO: {
563+
case ALLOW_NEW_REWARD: {
564564
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_6)) {
565565
throw new ContractValidateException(
566-
"Bad chain parameter id [ALLOW_NEW_REWARD_ALGO]");
566+
"Bad chain parameter id [ALLOW_NEW_REWARD]");
567567
}
568-
if (dynamicPropertiesStore.allowNewRewardEnable()) {
568+
if (dynamicPropertiesStore.allowNewReward()) {
569569
throw new ContractValidateException(
570-
"New reward algorithm has been valid.");
570+
"New reward has been valid.");
571571
}
572572
if (value != 1) {
573573
throw new ContractValidateException(
574-
"This value[ALLOW_NEW_REWARD_ALGO] is only allowed to be 1");
574+
"This value[ALLOW_NEW_REWARD] is only allowed to be 1");
575575
}
576576
break;
577577
}
@@ -650,7 +650,7 @@ public enum ProposalType { // current value, value range
650650
ALLOW_TVM_LONDON(63), // 0, 1
651651
ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX(65), // 0, 1
652652
ALLOW_ASSET_OPTIMIZATION(66), // 0, 1
653-
ALLOW_NEW_REWARD_ALGO(67), // 0, 1
653+
ALLOW_NEW_REWARD(67), // 0, 1
654654
MEMO_FEE(68); // 0, [0, 1000_000_000]
655655

656656
private long code;

chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public long calculateGlobalEnergyLimit(AccountCapsule accountCapsule) {
133133
long energyWeight = frozeBalance / TRX_PRECISION;
134134
long totalEnergyLimit = dynamicPropertiesStore.getTotalEnergyCurrentLimit();
135135
long totalEnergyWeight = dynamicPropertiesStore.getTotalEnergyWeight();
136-
if (dynamicPropertiesStore.allowNewRewardEnable() && totalEnergyWeight <= 0) {
136+
if (dynamicPropertiesStore.allowNewReward() && totalEnergyWeight <= 0) {
137137
return 0;
138138
} else {
139139
assert totalEnergyWeight > 0;

chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,10 @@ private DynamicPropertiesStore(@Value("properties") String dbName) {
863863
}
864864

865865
try {
866-
this.getAllowNewRewardEnable();
866+
this.getAllowNewReward();
867867
} catch (IllegalArgumentException e) {
868-
this.saveAllowNewRewardEnable(CommonParameter.getInstance().getAllowNewRewardEnable());
869-
if (CommonParameter.getInstance().getAllowNewRewardEnable() == 1) {
868+
this.saveAllowNewReward(CommonParameter.getInstance().getAllowNewReward());
869+
if (CommonParameter.getInstance().getAllowNewReward() == 1) {
870870
this.put(NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE,
871871
new BytesCapsule(ByteArray.fromLong(getCurrentCycleNumber())));
872872
}
@@ -2156,7 +2156,7 @@ public void updateNextMaintenanceTime(long blockTime) {
21562156
public void addTotalNetWeight(long amount) {
21572157
long totalNetWeight = getTotalNetWeight();
21582158
totalNetWeight += amount;
2159-
if (allowNewRewardEnable()) {
2159+
if (allowNewReward()) {
21602160
totalNetWeight = Math.max(0, totalNetWeight);
21612161
}
21622162
saveTotalNetWeight(totalNetWeight);
@@ -2166,7 +2166,7 @@ public void addTotalNetWeight(long amount) {
21662166
public void addTotalEnergyWeight(long amount) {
21672167
long totalEnergyWeight = getTotalEnergyWeight();
21682168
totalEnergyWeight += amount;
2169-
if (allowNewRewardEnable()) {
2169+
if (allowNewReward()) {
21702170
totalEnergyWeight = Math.max(0, totalEnergyWeight);
21712171
}
21722172
saveTotalEnergyWeight(totalEnergyWeight);
@@ -2176,7 +2176,7 @@ public void addTotalEnergyWeight(long amount) {
21762176
public void addTotalTronPowerWeight(long amount) {
21772177
long totalWeight = getTotalTronPowerWeight();
21782178
totalWeight += amount;
2179-
if (allowNewRewardEnable()) {
2179+
if (allowNewReward()) {
21802180
totalWeight = Math.max(0, totalWeight);
21812181
}
21822182
saveTotalTronPowerWeight(totalWeight);
@@ -2581,19 +2581,19 @@ public void saveMemoFeeHistory(String value) {
25812581
this.put(MEMO_FEE_HISTORY, new BytesCapsule(ByteArray.fromString(value)));
25822582
}
25832583

2584-
public long getAllowNewRewardEnable() {
2584+
public long getAllowNewReward() {
25852585
return Optional.ofNullable(getUnchecked(ALLOW_NEW_REWARD))
25862586
.map(BytesCapsule::getData)
25872587
.map(ByteArray::toLong)
2588-
.orElseThrow(() -> new IllegalArgumentException("not found AllowNewRewardEnable"));
2588+
.orElseThrow(() -> new IllegalArgumentException("not found AllowNewReward"));
25892589
}
25902590

2591-
public void saveAllowNewRewardEnable(long newReward) {
2591+
public void saveAllowNewReward(long newReward) {
25922592
this.put(ALLOW_NEW_REWARD, new BytesCapsule(ByteArray.fromLong(newReward)));
25932593
}
25942594

2595-
public boolean allowNewRewardEnable() {
2596-
return getAllowNewRewardEnable() == 1;
2595+
public boolean allowNewReward() {
2596+
return getAllowNewReward() == 1;
25972597
}
25982598

25992599
private static class DynamicResourceProperties {

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ public class CommonParameter {
563563

564564
@Getter
565565
@Setter
566-
public long allowNewRewardEnable = 0L;
566+
public long allowNewReward = 0L;
567567

568568
@Getter
569569
@Setter

common/src/main/java/org/tron/core/Constant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public class Constant {
307307

308308
public static final String ALLOW_ACCOUNT_ASSET_OPTIMIZATION = "committee.allowAccountAssetOptimization";
309309
public static final String ALLOW_ASSET_OPTIMIZATION = "committee.allowAssetOptimization";
310-
public static final String ALLOW_NEW_REWARD_ENABLE = "committee.allowNewRewardEnable";
310+
public static final String ALLOW_NEW_REWARD = "committee.allowNewReward";
311311
public static final String MEMO_FEE = "committee.memoFee";
312312

313313
public static final String LOCAL_HOST = "127.0.0.1";

framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ public Protocol.ChainParameters getChainParameters() {
10991099
.build());
11001100

11011101
builder.addChainParameter(Protocol.ChainParameters.ChainParameter.newBuilder()
1102-
.setKey("getAllowNewRewardEnable")
1103-
.setValue(dbManager.getDynamicPropertiesStore().getAllowNewRewardEnable())
1102+
.setKey("getAllowNewReward")
1103+
.setValue(dbManager.getDynamicPropertiesStore().getAllowNewReward())
11041104
.build());
11051105

11061106
builder.addChainParameter(Protocol.ChainParameters.ChainParameter.newBuilder()

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static void clearParam() {
215215
PARAMETER.shutdownBlockCount = -1;
216216
PARAMETER.blockCacheTimeout = 60;
217217
PARAMETER.allowNewRewardAlgorithm = 0;
218-
PARAMETER.allowNewRewardEnable = 0;
218+
PARAMETER.allowNewReward = 0;
219219
PARAMETER.memoFee = 0;
220220
}
221221

@@ -1036,13 +1036,13 @@ public static void setParam(final String[] args, final String confFileName) {
10361036
PARAMETER.blockCacheTimeout = config.getLong(Constant.BLOCK_CACHE_TIMEOUT);
10371037
}
10381038

1039-
if (config.hasPath(Constant.ALLOW_NEW_REWARD_ENABLE)) {
1040-
PARAMETER.allowNewRewardEnable = config.getLong(Constant.ALLOW_NEW_REWARD_ENABLE);
1041-
if (PARAMETER.allowNewRewardEnable > 1) {
1042-
PARAMETER.allowNewRewardEnable = 1;
1039+
if (config.hasPath(Constant.ALLOW_NEW_REWARD)) {
1040+
PARAMETER.allowNewReward = config.getLong(Constant.ALLOW_NEW_REWARD);
1041+
if (PARAMETER.allowNewReward > 1) {
1042+
PARAMETER.allowNewReward = 1;
10431043
}
1044-
if (PARAMETER.allowNewRewardEnable < 0) {
1045-
PARAMETER.allowNewRewardEnable = 0;
1044+
if (PARAMETER.allowNewReward < 0) {
1045+
PARAMETER.allowNewReward = 0;
10461046
}
10471047
}
10481048

framework/src/main/java/org/tron/core/consensus/ProposalService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ public static boolean process(Manager manager, ProposalCapsule proposalCapsule)
284284
manager.getDynamicPropertiesStore().setAllowAssetOptimization(entry.getValue());
285285
break;
286286
}
287-
case ALLOW_NEW_REWARD_ALGO: {
287+
case ALLOW_NEW_REWARD: {
288288
manager.getDynamicPropertiesStore().saveNewRewardAlgorithmEffectiveCycle();
289-
manager.getDynamicPropertiesStore().saveAllowNewRewardEnable(entry.getValue());
289+
manager.getDynamicPropertiesStore().saveAllowNewReward(entry.getValue());
290290
break;
291291
}
292292
case MEMO_FEE: {

0 commit comments

Comments
 (0)