Skip to content

Commit d43927e

Browse files
committed
fix following comment
1 parent f554d2e commit d43927e

File tree

10 files changed

+13
-83
lines changed

10 files changed

+13
-83
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.tron.core.exception.ContractExeException;
1818
import org.tron.core.exception.ContractValidateException;
1919
import org.tron.core.utils.ProposalUtil;
20-
import org.tron.core.vm.config.VMConfig;
2120
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
2221
import org.tron.protos.Protocol.Transaction.Result.code;
2322
import org.tron.protos.contract.ProposalContract.ProposalCreateContract;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import org.tron.core.store.DynamicPropertiesStore;
3636
import org.tron.core.store.NullifierStore;
3737
import org.tron.core.store.ZKProofStore;
38-
import org.tron.core.utils.TransactionUtil;
39-
import org.tron.core.vm.config.VMConfig;
4038
import org.tron.protos.Protocol.AccountType;
4139
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
4240
import org.tron.protos.Protocol.Transaction.Result.code;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.tron.common.runtime.InternalTransaction.TrxType;
2424
import org.tron.common.runtime.ProgramResult;
2525
import org.tron.common.utils.DBConfig;
26+
import org.tron.common.utils.StorageUtils;
2627
import org.tron.common.utils.WalletUtil;
2728
import org.tron.core.capsule.AccountCapsule;
2829
import org.tron.core.capsule.BlockCapsule;
@@ -339,7 +340,7 @@ private void create()
339340
long energyLimit;
340341
// according to version
341342

342-
if (VMConfig.getEnergyLimitHardFork()) {
343+
if (StorageUtils.getEnergyLimitHardFork()) {
343344
if (callValue < 0) {
344345
throw new ContractValidateException("callValue must be >= 0");
345346
}
@@ -441,7 +442,7 @@ private void call()
441442
tokenId = contract.getTokenId();
442443
}
443444

444-
if (VMConfig.getEnergyLimitHardFork()) {
445+
if (StorageUtils.getEnergyLimitHardFork()) {
445446
if (callValue < 0) {
446447
throw new ContractValidateException("callValue must be >= 0");
447448
}
@@ -576,7 +577,7 @@ public long getTotalEnergyLimit(AccountCapsule creator, AccountCapsule caller,
576577
return getAccountEnergyLimitWithFixRatio(caller, feeLimit, callValue);
577578
}
578579
// according to version
579-
if (VMConfig.getEnergyLimitHardFork()) {
580+
if (StorageUtils.getEnergyLimitHardFork()) {
580581
return getTotalEnergyLimitWithFixRatio(creator, caller, contract, feeLimit, callValue);
581582
} else {
582583
return getTotalEnergyLimitWithFloatRatio(creator, caller, contract, feeLimit, callValue);

actuator/src/main/java/org/tron/core/vm/config/VMConfig.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public static void initAllowTvmSolidity059(long allow) {
9494
ALLOW_TVM_SOLIDITY_059 = allow == 1;
9595
}
9696

97-
public static boolean getEnergyLimitHardFork() {
98-
return ENERGY_LIMIT_HARD_FORK;
99-
}
100-
10197
public static boolean allowTvmTransferTrc10() {
10298
return ALLOW_TVM_TRANSFER_TRC10;
10399
}

actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.tron.common.utils.DBConfig;
1515
import org.tron.common.utils.Hash;
1616
import org.tron.common.utils.Sha256Hash;
17+
import org.tron.common.utils.StorageUtils;
1718
import org.tron.common.utils.StringUtil;
1819
import org.tron.core.ChainBaseManager;
1920
import org.tron.core.capsule.AccountCapsule;
@@ -344,7 +345,7 @@ public Storage getStorage(byte[] address) {
344345
Storage storage;
345346
if (this.parent != null) {
346347
Storage parentStorage = parent.getStorage(address);
347-
if (VMConfig.getEnergyLimitHardFork()) {
348+
if (StorageUtils.getEnergyLimitHardFork()) {
348349
// deep copy
349350
storage = new Storage(parentStorage);
350351
} else {

chainbase/src/main/java/org/tron/common/utils/StorageUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static Options getOptionsByDbName(String dbName) {
5959
return createDefaultDbOptions();
6060
}
6161

62-
private static Options createDefaultDbOptions() {
62+
protected static Options createDefaultDbOptions() {
6363
Options dbOptions = new Options();
6464

6565
dbOptions.createIfMissing(true);

framework/src/main/java/org/tron/common/storage/DepositImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.tron.common.utils.ByteUtil;
1414
import org.tron.common.utils.Commons;
1515
import org.tron.common.utils.Hash;
16+
import org.tron.common.utils.StorageUtils;
1617
import org.tron.common.utils.StringUtil;
1718
import org.tron.core.capsule.AccountCapsule;
1819
import org.tron.core.capsule.AssetIssueCapsule;
@@ -338,7 +339,7 @@ public synchronized Storage getStorage(byte[] address) {
338339
Storage storage;
339340
if (this.parent != null) {
340341
Storage parentStorage = parent.getStorage(address);
341-
if (VMConfig.getEnergyLimitHardFork()) {
342+
if (StorageUtils.getEnergyLimitHardFork()) {
342343
// deep copy
343344
storage = new Storage(parentStorage);
344345
} else {

framework/src/main/java/org/tron/core/config/DefaultConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.springframework.context.annotation.Conditional;
99
import org.springframework.context.annotation.Configuration;
1010
import org.springframework.context.annotation.Import;
11+
import org.tron.common.utils.StorageUtils;
1112
import org.tron.core.config.args.Args;
1213
import org.tron.core.db.RevokingDatabase;
1314
import org.tron.core.db.RevokingStore;
@@ -46,7 +47,7 @@ public RevokingDatabase revokingDatabase() {
4647
revokingDatabase = RevokingStore.getInstance();
4748
} else if (dbVersion == 2) {
4849
revokingDatabase = new SnapshotManager(
49-
Args.getInstance().getOutputDirectoryByDbName("block"));
50+
StorageUtils.getOutputDirectoryByDbName("block"));
5051
} else {
5152
throw new RuntimeException("db version is error.");
5253
}

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,20 +1092,6 @@ public void setFullNodeAllowShieldedTransaction(boolean fullNodeAllowShieldedTra
10921092
DBConfig.setFullNodeAllowShieldedTransaction(fullNodeAllowShieldedTransaction);
10931093
}
10941094

1095-
/**
1096-
* Get storage path by name of database
1097-
*
1098-
* @param dbName name of database
1099-
* @return path of that database
1100-
*/
1101-
public String getOutputDirectoryByDbName(String dbName) {
1102-
String path = storage.getPathByDbName(dbName);
1103-
if (!StringUtils.isBlank(path)) {
1104-
return path;
1105-
}
1106-
return getOutputDirectory();
1107-
}
1108-
11091095
/**
11101096
* get output directory.
11111097
*/

framework/src/main/java/org/tron/core/config/args/Storage.java

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.iq80.leveldb.Options;
2828
import org.tron.common.utils.FileUtil;
2929
import org.tron.common.utils.Property;
30+
import org.tron.common.utils.StorageUtils;
3031

3132
/**
3233
* Custom storage configurations
@@ -36,7 +37,7 @@
3637
* @since 2018/5/25
3738
*/
3839

39-
public class Storage {
40+
public class Storage extends StorageUtils {
4041

4142
/**
4243
* Keys (names) of database config
@@ -74,18 +75,6 @@ public class Storage {
7475
private static final String DEFAULT_INDEX_DIRECTORY = "index";
7576
private static final String DEFAULT_INDEX_SWTICH = "on";
7677

77-
/**
78-
* Default values of db options: <p> DEFAULT_COMPRESSION_TYPE: compressed with snappy
79-
* DEFAULT_BLOCK_SIZE: 4 KB = 4 * 1024 B DEFAULT_WRITE_BUFFER_SIZE: 10 MB = 10 *
80-
* 1024 * 1024 B DEFAULT_CACHE_SIZE: 10 MB = 10 * 1024 * 1024 B DEFAULT_MAX_OPEN_FILES:
81-
* 100
82-
*/
83-
private static final CompressionType DEFAULT_COMPRESSION_TYPE = CompressionType.SNAPPY;
84-
private static final int DEFAULT_BLOCK_SIZE = 4 * 1024;
85-
private static final int DEFAULT_WRITE_BUFFER_SIZE = 10 * 1024 * 1024;
86-
private static final long DEFAULT_CACHE_SIZE = 10 * 1024 * 1024L;
87-
private static final int DEFAULT_MAX_OPEN_FILES = 100;
88-
8978
/**
9079
* Database storage directory: /path/to/{dbDirectory}
9180
*/
@@ -296,22 +285,6 @@ private static Property createProperty(final ConfigObject conf) {
296285
return property;
297286
}
298287

299-
private static Options createDefaultDbOptions() {
300-
Options dbOptions = new Options();
301-
302-
dbOptions.createIfMissing(true);
303-
dbOptions.paranoidChecks(true);
304-
dbOptions.verifyChecksums(true);
305-
306-
dbOptions.compressionType(DEFAULT_COMPRESSION_TYPE);
307-
dbOptions.blockSize(DEFAULT_BLOCK_SIZE);
308-
dbOptions.writeBufferSize(DEFAULT_WRITE_BUFFER_SIZE);
309-
dbOptions.cacheSize(DEFAULT_CACHE_SIZE);
310-
dbOptions.maxOpenFiles(DEFAULT_MAX_OPEN_FILES);
311-
312-
return dbOptions;
313-
}
314-
315288
/**
316289
* Set propertyMap of Storage object from Config
317290
*
@@ -325,32 +298,6 @@ public void setPropertyMapFromConfig(final Config config) {
325298
}
326299
}
327300

328-
/**
329-
* Get storage path by name of database
330-
*
331-
* @param dbName name of database
332-
* @return path of that database
333-
*/
334-
public String getPathByDbName(String dbName) {
335-
if (hasProperty(dbName)) {
336-
return getProperty(dbName).getPath();
337-
}
338-
return null;
339-
}
340-
341-
/**
342-
* Get database options by name of database
343-
*
344-
* @param dbName name of database
345-
* @return options of that database
346-
*/
347-
public Options getOptionsByDbName(String dbName) {
348-
if (hasProperty(dbName)) {
349-
return getProperty(dbName).getDbOptions();
350-
}
351-
return createDefaultDbOptions();
352-
}
353-
354301
/**
355302
* Only for unit test on db
356303
*/

0 commit comments

Comments
 (0)