diff --git a/src/main/java/org/tron/core/db/DynamicPropertiesStore.java b/src/main/java/org/tron/core/db/DynamicPropertiesStore.java index de194d08cfb..6ab364438a0 100755 --- a/src/main/java/org/tron/core/db/DynamicPropertiesStore.java +++ b/src/main/java/org/tron/core/db/DynamicPropertiesStore.java @@ -61,6 +61,8 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking private static final byte[] NON_EXISTENT_ACCOUNT_TRANSFER_MIN = "NON_EXISTENT_ACCOUNT_TRANSFER_MIN" .getBytes(); + private static final byte[] OPERATING_TIME_INTERVAL = "OPERATING_TIME_INTERVAL".getBytes(); + @Autowired private DynamicPropertiesStore(@Qualifier("properties") String dbName) { super(dbName); @@ -172,6 +174,14 @@ private DynamicPropertiesStore(@Qualifier("properties") String dbName) { this.saveNonExistentAccountTransferLimit(1_000_000L); } + + try { + this.getOperatingTimeInterval(); + } catch (IllegalArgumentException e) { + this.saveOperatingTimeInterval(10_000L); + } + + try { this.getBlockFilledSlotsNumber(); } catch (IllegalArgumentException e) { @@ -402,6 +412,22 @@ public long getNonExistentAccountTransferMin() { () -> new IllegalArgumentException("not found NON_EXISTENT_ACCOUNT_TRANSFER_MIN")); } + + public void saveOperatingTimeInterval(long time) { + logger.debug("NON_EXISTENT_ACCOUNT_TRANSFER_MIN:" + time); + this.put(OPERATING_TIME_INTERVAL, + new BytesCapsule(ByteArray.fromLong(time))); + } + + public long getOperatingTimeInterval() { + return Optional.ofNullable(this.dbSource.getData(OPERATING_TIME_INTERVAL)) + .map(ByteArray::toLong) + .orElseThrow( + () -> new IllegalArgumentException("not found OPERATING_TIME_INTERVAL")); + } + + + public void saveBlockFilledSlots(int[] blockFilledSlots) { logger.debug("blockFilledSlots:" + intArrayToString(blockFilledSlots)); this.put(BLOCK_FILLED_SLOTS, diff --git a/src/main/java/org/tron/core/db/Manager.java b/src/main/java/org/tron/core/db/Manager.java index ebba1637dcd..f2f73df2663 100644 --- a/src/main/java/org/tron/core/db/Manager.java +++ b/src/main/java/org/tron/core/db/Manager.java @@ -467,7 +467,7 @@ private void consumeBandwidth(TransactionCapsule trx) throws ValidateBandwidthEx long now = getHeadBlockTimeStamp(); long latestOperationTime = accountCapsule.getLatestOperationTime(); //10 * 1000 - if (now - latestOperationTime >= 10_000L) { + if (now - latestOperationTime >= dynamicPropertiesStore.getOperatingTimeInterval()) { accountCapsule.setLatestOperationTime(now); this.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); return;