3232import org .tron .common .utils .DbOptionalsUtils ;
3333import org .tron .common .utils .FileUtil ;
3434import org .tron .common .utils .Property ;
35- import org .tron .core .Constant ;
3635
3736/**
3837 * Custom storage configurations
@@ -55,10 +54,6 @@ public class Storage {
5554 private static final String ESTIMATED_TRANSACTIONS_CONFIG_KEY =
5655 "storage.txCache.estimatedTransactions" ;
5756 private static final String SNAPSHOT_MAX_FLUSH_COUNT_CONFIG_KEY = "storage.snapshot.maxFlushCount" ;
58- private static final String DB_AUTO_PRUNE_SWITCH_CONFIG_KEY = "storage.prune.enable" ;
59- private static final String DB_AUTO_PRUNE_RETAIN_CONFIG_KEY = "storage.prune.retain" ;
60- private static final String DB_AUTO_PRUNE_FREQUENCY_CONFIG_KEY = "storage.prune.frequency" ;
61- private static final String DB_AUTO_PRUNE_BATCH_CONFIG_KEY = "storage.prune.batch" ;
6257 private static final String PROPERTIES_CONFIG_KEY = "storage.properties" ;
6358 private static final String PROPERTIES_CONFIG_DB_KEY = "storage" ;
6459 private static final String PROPERTIES_CONFIG_DEFAULT_KEY = "default" ;
@@ -96,11 +91,6 @@ public class Storage {
9691 private static final boolean DEFAULT_CHECKPOINT_SYNC = true ;
9792 private static final int DEFAULT_ESTIMATED_TRANSACTIONS = 1000 ;
9893 private static final int DEFAULT_SNAPSHOT_MAX_FLUSH_COUNT = 1 ;
99- private static final boolean DEFAULT_DB_AUTO_PRUNE_SWITCH = false ;
100- private static final int DEFAULT_DB_AUTO_PRUNE_RETAIN = 864000 ;
101- private static final int DEFAULT_DB_AUTO_PRUNE_FREQUENCY = 3 ;
102- private static final int DEFAULT_DB_AUTO_PRUNE_BATCH = 50 ;
103-
10494 private Config storage ;
10595
10696 /**
@@ -122,22 +112,6 @@ public class Storage {
122112 @ Setter
123113 private int maxFlushCount ;
124114
125- @ Getter
126- @ Setter
127- private boolean dbAutoPrune ;
128-
129- @ Getter
130- @ Setter
131- private int dbAutoPruneRetain ;
132-
133- @ Getter
134- @ Setter
135- private int dbAutoPruneFrequency ;
136-
137- @ Getter
138- @ Setter
139- private int dbAutoPruneBatch ;
140-
141115 /**
142116 * Index storage directory: /path/to/{indexDirectory}
143117 */
@@ -208,57 +182,6 @@ public static int getSnapshotMaxFlushCountFromConfig(final Config config) {
208182 return maxFlushCountConfig ;
209183 }
210184
211- public void setDbAutoPruneInfo (final Config config ) {
212- setDbAutoPrune (Storage .getDbAutoPruneSwitchFromConfig (config ));
213- setDbAutoPruneRetain (Storage .getDbAutoPruneRetainFromConfig (config ));
214- setDbAutoPruneFrequency (
215- Storage .getDbAutoPruneFrequencyFromConfig (config ));
216- setDbAutoPruneBatch (Storage .getDbAutoPruneBatchFromConfig (config ));
217- }
218-
219- public static boolean getDbAutoPruneSwitchFromConfig (final Config config ) {
220- return config .hasPath (DB_AUTO_PRUNE_SWITCH_CONFIG_KEY )
221- ? config .getBoolean (DB_AUTO_PRUNE_SWITCH_CONFIG_KEY ) : DEFAULT_DB_AUTO_PRUNE_SWITCH ;
222- }
223-
224- public static int getDbAutoPruneRetainFromConfig (final Config config ) {
225- if (!config .hasPath (DB_AUTO_PRUNE_RETAIN_CONFIG_KEY )) {
226- return DEFAULT_DB_AUTO_PRUNE_RETAIN ;
227- }
228- int dbAutoPruneRetain = config .getInt (DB_AUTO_PRUNE_RETAIN_CONFIG_KEY );
229- if (dbAutoPruneRetain < 30 * Constant .ONE_DAY_BLOCKS_PREDICT ) {
230- throw new IllegalArgumentException (
231- "[storage.prune.retain] value must not be less than 864000!" );
232- }
233- return dbAutoPruneRetain ;
234- }
235-
236- public static int getDbAutoPruneFrequencyFromConfig (final Config config ) {
237- if (!config .hasPath (DB_AUTO_PRUNE_FREQUENCY_CONFIG_KEY )) {
238- return DEFAULT_DB_AUTO_PRUNE_FREQUENCY ;
239- }
240- int dbAutoPruneFrequency = config .getInt (DB_AUTO_PRUNE_FREQUENCY_CONFIG_KEY );
241- if (dbAutoPruneFrequency < 1 ) {
242- throw new IllegalArgumentException ("[storage.prune.frequency] value must not be less than " +
243- "1!" );
244- }
245- return dbAutoPruneFrequency ;
246- }
247-
248- public static int getDbAutoPruneBatchFromConfig (final Config config ) {
249- if (!config .hasPath (DB_AUTO_PRUNE_BATCH_CONFIG_KEY )) {
250- return DEFAULT_DB_AUTO_PRUNE_BATCH ;
251- }
252- int dbAutoPruneBatch = config .getInt (DB_AUTO_PRUNE_BATCH_CONFIG_KEY );
253- if (dbAutoPruneBatch < 1 ) {
254- throw new IllegalArgumentException ("[storage.prune.batch] value must not be less than 1!" );
255- }
256- if (dbAutoPruneBatch > 50 ) {
257- throw new IllegalArgumentException ("[storage.prune.batch] value must not be more than 50!" );
258- }
259- return dbAutoPruneBatch ;
260- }
261-
262185 public static Boolean getContractParseSwitchFromConfig (final Config config ) {
263186 return config .hasPath (EVENT_SUBSCRIBE_CONTRACT_PARSE )
264187 ? config .getBoolean (EVENT_SUBSCRIBE_CONTRACT_PARSE )
0 commit comments