Skip to content

Commit 6c20014

Browse files
authored
Merge pull request #5267 from lxcmyf/release_v4.7.2
feat(freezeV2): optimize msg format
2 parents dc4c7fb + 7b50828 commit 6c20014

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public boolean execute(Object result) throws ContractExeException {
6161

6262
AccountCapsule ownerCapsule = accountStore
6363
.get(delegateResourceContract.getOwnerAddress().toByteArray());
64-
64+
DynamicPropertiesStore dynamicStore = chainBaseManager.getDynamicPropertiesStore();
6565
long delegateBalance = delegateResourceContract.getBalance();
6666
boolean lock = delegateResourceContract.getLock();
67-
long lockPeriod = delegateResourceContract.getLockPeriod();
67+
long lockPeriod = getLockPeriod(dynamicStore, delegateResourceContract);
6868
byte[] receiverAddress = delegateResourceContract.getReceiverAddress().toByteArray();
6969

7070
// delegate resource to receiver
@@ -219,7 +219,7 @@ public boolean validate() throws ContractValidateException {
219219

220220
boolean lock = delegateResourceContract.getLock();
221221
if (lock && dynamicStore.supportMaxDelegateLockPeriod()) {
222-
long lockPeriod = delegateResourceContract.getLockPeriod();
222+
long lockPeriod = getLockPeriod(dynamicStore, delegateResourceContract);
223223
long maxDelegateLockPeriod = dynamicStore.getMaxDelegateLockPeriod();
224224
if (lockPeriod < 0 || lockPeriod > maxDelegateLockPeriod) {
225225
throw new ContractValidateException(
@@ -257,6 +257,16 @@ public boolean validate() throws ContractValidateException {
257257
return true;
258258
}
259259

260+
private long getLockPeriod(DynamicPropertiesStore dynamicStore,
261+
DelegateResourceContract delegateResourceContract) {
262+
long lockPeriod = delegateResourceContract.getLockPeriod();
263+
if (dynamicStore.supportMaxDelegateLockPeriod()) {
264+
return lockPeriod == 0 ? DELEGATE_PERIOD / 3000 : lockPeriod;
265+
} else {
266+
return 0;
267+
}
268+
}
269+
260270
private void validRemainTime(ResourceCode resourceCode, long lockPeriod, long expireTime,
261271
long now) throws ContractValidateException {
262272
long remainTime = expireTime - now;
@@ -294,7 +304,7 @@ private void delegateResource(byte[] ownerAddress, byte[] receiverAddress, boole
294304
long expireTime = 0;
295305
if (lock) {
296306
if (dynamicPropertiesStore.supportMaxDelegateLockPeriod()) {
297-
expireTime = now + (lockPeriod == 0 ? DELEGATE_PERIOD : lockPeriod * 3 * 1000);
307+
expireTime = now + lockPeriod * 3 * 1000;
298308
} else {
299309
expireTime = now + DELEGATE_PERIOD;
300310
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
717717
if (value <= maxDelegateLockPeriod || value > 10512000L) {
718718
throw new ContractValidateException(
719719
"This value[MAX_DELEGATE_LOCK_PERIOD] is only allowed to be greater than "
720-
+ maxDelegateLockPeriod + "and less than or equal to 10512000 !");
720+
+ maxDelegateLockPeriod + " and less than or equal to 10512000 !");
721721
}
722722
if (dynamicPropertiesStore.getUnfreezeDelayDays() == 0) {
723723
throw new ContractValidateException(

0 commit comments

Comments
 (0)