Skip to content

Commit 27ab5ef

Browse files
authored
Merge pull request #698 from tronprotocol/feature/add_dynamic_parameter
add OPERATING_TIME_INTERVAL parameter
2 parents f5e5c61 + 47f63fe commit 27ab5ef

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/org/tron/core/db/DynamicPropertiesStore.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
6161
private static final byte[] NON_EXISTENT_ACCOUNT_TRANSFER_MIN = "NON_EXISTENT_ACCOUNT_TRANSFER_MIN"
6262
.getBytes();
6363

64+
private static final byte[] OPERATING_TIME_INTERVAL = "OPERATING_TIME_INTERVAL".getBytes();
65+
6466
@Autowired
6567
private DynamicPropertiesStore(@Qualifier("properties") String dbName) {
6668
super(dbName);
@@ -172,6 +174,14 @@ private DynamicPropertiesStore(@Qualifier("properties") String dbName) {
172174
this.saveNonExistentAccountTransferLimit(1_000_000L);
173175
}
174176

177+
178+
try {
179+
this.getOperatingTimeInterval();
180+
} catch (IllegalArgumentException e) {
181+
this.saveOperatingTimeInterval(10_000L);
182+
}
183+
184+
175185
try {
176186
this.getBlockFilledSlotsNumber();
177187
} catch (IllegalArgumentException e) {
@@ -402,6 +412,22 @@ public long getNonExistentAccountTransferMin() {
402412
() -> new IllegalArgumentException("not found NON_EXISTENT_ACCOUNT_TRANSFER_MIN"));
403413
}
404414

415+
416+
public void saveOperatingTimeInterval(long time) {
417+
logger.debug("NON_EXISTENT_ACCOUNT_TRANSFER_MIN:" + time);
418+
this.put(OPERATING_TIME_INTERVAL,
419+
new BytesCapsule(ByteArray.fromLong(time)));
420+
}
421+
422+
public long getOperatingTimeInterval() {
423+
return Optional.ofNullable(this.dbSource.getData(OPERATING_TIME_INTERVAL))
424+
.map(ByteArray::toLong)
425+
.orElseThrow(
426+
() -> new IllegalArgumentException("not found OPERATING_TIME_INTERVAL"));
427+
}
428+
429+
430+
405431
public void saveBlockFilledSlots(int[] blockFilledSlots) {
406432
logger.debug("blockFilledSlots:" + intArrayToString(blockFilledSlots));
407433
this.put(BLOCK_FILLED_SLOTS,

src/main/java/org/tron/core/db/Manager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private void consumeBandwidth(TransactionCapsule trx) throws ValidateBandwidthEx
467467
long now = getHeadBlockTimeStamp();
468468
long latestOperationTime = accountCapsule.getLatestOperationTime();
469469
//10 * 1000
470-
if (now - latestOperationTime >= 10_000L) {
470+
if (now - latestOperationTime >= dynamicPropertiesStore.getOperatingTimeInterval()) {
471471
accountCapsule.setLatestOperationTime(now);
472472
this.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule);
473473
return;

0 commit comments

Comments
 (0)