Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/main/java/org/tron/core/db/DynamicPropertiesStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down