@@ -102,12 +102,10 @@ public class Args extends CommonParameter {
102102 /**
103103 * set parameters.
104104 */
105- public static void setParam (final String [] args ,
106- final String confFileName ) {
105+ public static void setParam (final String [] args , final String confFileName ) {
107106 // 1. Parse CLI args into a separate object
108107 CLIParameter cmd = new CLIParameter ();
109- JCommander jc =
110- JCommander .newBuilder ().addObject (cmd ).build ();
108+ JCommander jc = JCommander .newBuilder ().addObject (cmd ).build ();
111109 jc .parse (args );
112110
113111 if (cmd .version ) {
@@ -1014,14 +1012,10 @@ public static void applyConfigParams(
10141012 * Apply CLI parameters that were explicitly passed.
10151013 * Only assigned parameters override Config values.
10161014 */
1017- private static void applyCLIParams (CLIParameter cmd ,
1018- JCommander jc ) {
1019- Map <String , ParameterDescription > assigned =
1020- jc .getParameters ().stream ()
1021- .filter (ParameterDescription ::isAssigned )
1022- .collect (Collectors .toMap (
1023- ParameterDescription ::getLongestName ,
1024- p -> p ));
1015+ private static void applyCLIParams (CLIParameter cmd , JCommander jc ) {
1016+ Map <String , ParameterDescription > assigned = jc .getParameters ().stream ()
1017+ .filter (ParameterDescription ::isAssigned )
1018+ .collect (Collectors .toMap (ParameterDescription ::getLongestName , p -> p ));
10251019
10261020 if (assigned .containsKey ("--output-directory" )) {
10271021 PARAMETER .outputDirectory = cmd .outputDirectory ;
@@ -1032,10 +1026,8 @@ private static void applyCLIParams(CLIParameter cmd,
10321026 if (assigned .containsKey ("--support-constant" )) {
10331027 PARAMETER .supportConstant = cmd .supportConstant ;
10341028 }
1035- if (assigned .containsKey (
1036- "--max-energy-limit-for-constant" )) {
1037- PARAMETER .maxEnergyLimitForConstant =
1038- cmd .maxEnergyLimitForConstant ;
1029+ if (assigned .containsKey ("--max-energy-limit-for-constant" )) {
1030+ PARAMETER .maxEnergyLimitForConstant = cmd .maxEnergyLimitForConstant ;
10391031 }
10401032 if (assigned .containsKey ("--lru-cache-size" )) {
10411033 PARAMETER .lruCacheSize = cmd .lruCacheSize ;
@@ -1052,54 +1044,38 @@ private static void applyCLIParams(CLIParameter cmd,
10521044 if (assigned .containsKey ("--save-internaltx" )) {
10531045 PARAMETER .saveInternalTx = cmd .saveInternalTx ;
10541046 }
1055- if (assigned .containsKey (
1056- "--save-featured-internaltx" )) {
1057- PARAMETER .saveFeaturedInternalTx =
1058- cmd .saveFeaturedInternalTx ;
1047+ if (assigned .containsKey ("--save-featured-internaltx" )) {
1048+ PARAMETER .saveFeaturedInternalTx = cmd .saveFeaturedInternalTx ;
10591049 }
1060- if (assigned .containsKey (
1061- "--save-cancel-all-unfreeze-v2-details" )) {
1062- PARAMETER .saveCancelAllUnfreezeV2Details =
1063- cmd .saveCancelAllUnfreezeV2Details ;
1050+ if (assigned .containsKey ("--save-cancel-all-unfreeze-v2-details" )) {
1051+ PARAMETER .saveCancelAllUnfreezeV2Details = cmd .saveCancelAllUnfreezeV2Details ;
10641052 }
10651053 if (assigned .containsKey ("--long-running-time" )) {
10661054 PARAMETER .longRunningTime = cmd .longRunningTime ;
10671055 }
10681056 if (assigned .containsKey ("--max-connect-number" )) {
1069- PARAMETER .maxHttpConnectNumber =
1070- cmd .maxHttpConnectNumber ;
1057+ PARAMETER .maxHttpConnectNumber = cmd .maxHttpConnectNumber ;
10711058 }
10721059 if (assigned .containsKey ("--storage-db-directory" )) {
1073- PARAMETER .storageDbDirectory =
1074- cmd .storageDbDirectory ;
1060+ PARAMETER .storageDbDirectory = cmd .storageDbDirectory ;
10751061 }
10761062 if (assigned .containsKey ("--storage-db-engine" )) {
10771063 PARAMETER .storageDbEngine = cmd .storageDbEngine ;
10781064 }
1079- if (assigned .containsKey (
1080- "--storage-db-synchronous" )) {
1081- PARAMETER .storageDbSynchronous =
1082- cmd .storageDbSynchronous ;
1065+ if (assigned .containsKey ("--storage-db-synchronous" )) {
1066+ PARAMETER .storageDbSynchronous = cmd .storageDbSynchronous ;
10831067 }
1084- if (assigned .containsKey (
1085- "--contract-parse-enable" )) {
1086- PARAMETER .contractParseEnable =
1087- cmd .contractParseEnable ;
1068+ if (assigned .containsKey ("--contract-parse-enable" )) {
1069+ PARAMETER .contractParseEnable = cmd .contractParseEnable ;
10881070 }
1089- if (assigned .containsKey (
1090- "--storage-index-directory" )) {
1091- PARAMETER .storageIndexDirectory =
1092- cmd .storageIndexDirectory ;
1071+ if (assigned .containsKey ("--storage-index-directory" )) {
1072+ PARAMETER .storageIndexDirectory = cmd .storageIndexDirectory ;
10931073 }
1094- if (assigned .containsKey (
1095- "--storage-index-switch" )) {
1096- PARAMETER .storageIndexSwitch =
1097- cmd .storageIndexSwitch ;
1074+ if (assigned .containsKey ("--storage-index-switch" )) {
1075+ PARAMETER .storageIndexSwitch = cmd .storageIndexSwitch ;
10981076 }
1099- if (assigned .containsKey (
1100- "--storage-transactionHistory-switch" )) {
1101- PARAMETER .storageTransactionHistorySwitch =
1102- cmd .storageTransactionHistorySwitch ;
1077+ if (assigned .containsKey ("--storage-transactionHistory-switch" )) {
1078+ PARAMETER .storageTransactionHistorySwitch = cmd .storageTransactionHistorySwitch ;
11031079 }
11041080 if (assigned .containsKey ("--fast-forward" )) {
11051081 PARAMETER .fastForward = cmd .fastForward ;
@@ -1116,10 +1092,8 @@ private static void applyCLIParams(CLIParameter cmd,
11161092 if (assigned .containsKey ("--solidity-thread" )) {
11171093 PARAMETER .solidityThreads = cmd .solidityThreads ;
11181094 }
1119- if (assigned .containsKey (
1120- "--validate-sign-thread" )) {
1121- PARAMETER .validateSignThreadNum =
1122- cmd .validateSignThreadNum ;
1095+ if (assigned .containsKey ("--validate-sign-thread" )) {
1096+ PARAMETER .validateSignThreadNum = cmd .validateSignThreadNum ;
11231097 }
11241098 if (assigned .containsKey ("--trust-node" )) {
11251099 PARAMETER .trustNodeAddr = cmd .trustNodeAddr ;
@@ -1130,18 +1104,15 @@ private static void applyCLIParams(CLIParameter cmd,
11301104 if (assigned .containsKey ("--p2p-disable" )) {
11311105 PARAMETER .p2pDisable = cmd .p2pDisable ;
11321106 }
1133- if (assigned .containsKey (
1134- "--history-balance-lookup" )) {
1135- PARAMETER .historyBalanceLookup =
1136- cmd .historyBalanceLookup ;
1107+ if (assigned .containsKey ("--history-balance-lookup" )) {
1108+ PARAMETER .historyBalanceLookup = cmd .historyBalanceLookup ;
11371109 }
11381110 if (assigned .containsKey ("--log-config" )) {
11391111 PARAMETER .logbackPath = cmd .logbackPath ;
11401112 }
11411113 }
11421114
1143- private static void initLocalWitnesses (
1144- Config config , CLIParameter cmd ) {
1115+ private static void initLocalWitnesses (Config config , CLIParameter cmd ) {
11451116 // not a witness node, skip
11461117 if (!PARAMETER .isWitness ()) {
11471118 localWitnesses = new LocalWitnesses ();
@@ -1150,48 +1121,35 @@ private static void initLocalWitnesses(
11501121
11511122 // path 1: CLI --private-key
11521123 if (StringUtils .isNotBlank (cmd .privateKey )) {
1153- localWitnesses =
1154- WitnessInitializer .initFromCLIPrivateKey (
1155- cmd .privateKey , cmd .witnessAddress );
1124+ localWitnesses = WitnessInitializer .initFromCLIPrivateKey (
1125+ cmd .privateKey , cmd .witnessAddress );
11561126 return ;
11571127 }
11581128
1159- String witnessAddr = config .hasPath (
1160- ConfigKey .LOCAL_WITNESS_ACCOUNT_ADDRESS )
1161- ? config .getString (
1162- ConfigKey .LOCAL_WITNESS_ACCOUNT_ADDRESS )
1163- : null ;
1129+ String witnessAddr = config .hasPath (ConfigKey .LOCAL_WITNESS_ACCOUNT_ADDRESS )
1130+ ? config .getString (ConfigKey .LOCAL_WITNESS_ACCOUNT_ADDRESS ) : null ;
11641131
11651132 // path 2: config localwitness (private key list)
11661133 if (config .hasPath (ConfigKey .LOCAL_WITNESS )) {
1167- List <String > keys = config .getStringList (
1168- ConfigKey .LOCAL_WITNESS );
1134+ List <String > keys = config .getStringList (ConfigKey .LOCAL_WITNESS );
11691135 if (!keys .isEmpty ()) {
1170- localWitnesses =
1171- WitnessInitializer .initFromCFGPrivateKey (
1172- keys , witnessAddr );
1136+ localWitnesses = WitnessInitializer .initFromCFGPrivateKey (keys , witnessAddr );
11731137 return ;
11741138 }
11751139 }
11761140
11771141 // path 3: config localwitnesskeystore + password
1178- if (config .hasPath (
1179- ConfigKey .LOCAL_WITNESS_KEYSTORE )) {
1180- List <String > keystores = config .getStringList (
1181- ConfigKey .LOCAL_WITNESS_KEYSTORE );
1142+ if (config .hasPath (ConfigKey .LOCAL_WITNESS_KEYSTORE )) {
1143+ List <String > keystores = config .getStringList (ConfigKey .LOCAL_WITNESS_KEYSTORE );
11821144 if (!keystores .isEmpty ()) {
1183- localWitnesses =
1184- WitnessInitializer .initFromKeystore (
1185- keystores , cmd .password ,
1186- witnessAddr );
1145+ localWitnesses = WitnessInitializer .initFromKeystore (
1146+ keystores , cmd .password , witnessAddr );
11871147 return ;
11881148 }
11891149 }
11901150
11911151 // no private key source configured
1192- throw new TronError (
1193- "This is a witness node, "
1194- + "but localWitnesses is null" ,
1152+ throw new TronError ("This is a witness node, but localWitnesses is null" ,
11951153 TronError .ErrCode .WITNESS_INIT );
11961154 }
11971155
0 commit comments