@@ -61,10 +61,10 @@ public boolean execute(Object result) throws ContractExeException {
61
61
62
62
AccountCapsule ownerCapsule = accountStore
63
63
.get (delegateResourceContract .getOwnerAddress ().toByteArray ());
64
-
64
+ DynamicPropertiesStore dynamicStore = chainBaseManager . getDynamicPropertiesStore ();
65
65
long delegateBalance = delegateResourceContract .getBalance ();
66
66
boolean lock = delegateResourceContract .getLock ();
67
- long lockPeriod = delegateResourceContract . getLockPeriod ();
67
+ long lockPeriod = getLockPeriod (dynamicStore , delegateResourceContract );
68
68
byte [] receiverAddress = delegateResourceContract .getReceiverAddress ().toByteArray ();
69
69
70
70
// delegate resource to receiver
@@ -219,7 +219,7 @@ public boolean validate() throws ContractValidateException {
219
219
220
220
boolean lock = delegateResourceContract .getLock ();
221
221
if (lock && dynamicStore .supportMaxDelegateLockPeriod ()) {
222
- long lockPeriod = delegateResourceContract . getLockPeriod ();
222
+ long lockPeriod = getLockPeriod (dynamicStore , delegateResourceContract );
223
223
long maxDelegateLockPeriod = dynamicStore .getMaxDelegateLockPeriod ();
224
224
if (lockPeriod < 0 || lockPeriod > maxDelegateLockPeriod ) {
225
225
throw new ContractValidateException (
@@ -257,6 +257,16 @@ public boolean validate() throws ContractValidateException {
257
257
return true ;
258
258
}
259
259
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
+
260
270
private void validRemainTime (ResourceCode resourceCode , long lockPeriod , long expireTime ,
261
271
long now ) throws ContractValidateException {
262
272
long remainTime = expireTime - now ;
@@ -294,7 +304,7 @@ private void delegateResource(byte[] ownerAddress, byte[] receiverAddress, boole
294
304
long expireTime = 0 ;
295
305
if (lock ) {
296
306
if (dynamicPropertiesStore .supportMaxDelegateLockPeriod ()) {
297
- expireTime = now + ( lockPeriod == 0 ? DELEGATE_PERIOD : lockPeriod * 3 * 1000 ) ;
307
+ expireTime = now + lockPeriod * 3 * 1000 ;
298
308
} else {
299
309
expireTime = now + DELEGATE_PERIOD ;
300
310
}
0 commit comments