11/*
22 This file is part of cpp-ethereum.
3+
34 cpp-ethereum is free software: you can redistribute it and/or modify
45 it under the terms of the GNU General Public License as published by
56 the Free Software Foundation, either version 3 of the License, or
67 (at your option) any later version.
8+
79 cpp-ethereum is distributed in the hope that it will be useful,
810 but WITHOUT ANY WARRANTY; without even the implied warranty of
911 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1012 GNU General Public License for more details.
13+
1114 You should have received a copy of the GNU General Public License
1215 along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
1316*/
@@ -74,7 +77,8 @@ string ethCredits(bool _interactive = false)
7477{
7578 std::ostringstream cout;
7679 if (_interactive)
77- cout << " Type 'exit' to quit\n\n " ;
80+ cout
81+ << " Type 'exit' to quit\n\n " ;
7882 return credits () + cout.str ();
7983}
8084
@@ -303,6 +307,7 @@ int main(int argc, char** argv)
303307 bool chainConfigIsSet = false ;
304308 string configJSON;
305309 string genesisJSON;
310+
306311 po::options_description clientDefaultMode (" Client mode (default)" );
307312 clientDefaultMode.add_options ()
308313 (" format" , po::value<string>(), " <binary/hex/human> Set format." )
@@ -332,18 +337,21 @@ int main(int argc, char** argv)
332337 (" genesis" , po::value<string>(), " Set genesisJSON" )
333338 (" genesis-json" , po::value<string>(), " Set genesisJSON" )
334339 (" json-admin" , po::value<string>(), " Set jsonAdmin" );
340+
335341 po::options_description clientTransacting (" Client transactions" );
336342 clientTransacting.add_options ()
337343 (" ask" , po::value<string>(), " See description under." )
338344 (" bid" , po::value<string>(), " See description under." )
339345 (" unsafe-transactions" , " Allow all transactions to proceed without verification. EXTREMELY UNSAFE." );
346+
340347 po::options_description clientMining (" Client mining" );
341348 clientMining.add_options ()
342349 (" address,a" , po::value<string>(), " <addr> Set the author (mining payout) address to given address (default: auto)." )
343350 (" author" , po::value<string>(), " <addr> Set the author (mining payout) address to given address (default: auto)." )
344351 (" mining,m" , po::value<string>(), " <on/off/number> Enable mining, optionally for a specified number of blocks (default: off)." )
345352 (" cpu,C" , " When mining, use the CPU." )
346353 (" mining-threads,t" , " <n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform)." );
354+
347355 po::options_description clientNetworking (" Client networking" );
348356 clientNetworking.add_options ()
349357 (" client-name" , po::value<string>(), " <name> Add a name to your client's version string (default: blank)." )
@@ -367,13 +375,15 @@ int main(int argc, char** argv)
367375 (" pin" , " Only accept or connect to trusted peers." )
368376 (" hermit" , " Equivalent to --no-discovery --pin." )
369377 (" sociable" , " Force discovery and no pinning.\n " );
378+
370379 po::options_description importExportMode (" Import/export mode" );
371380 importExportMode.add_options ()
372381 (" from" , po::value<string>(), " <n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." )
373382 (" to" , po::value<string>(), " <n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." )
374383 (" only" , po::value<string>(), " <n> Equivalent to --export-from n --export-to n." )
375384 (" dont-check" , " Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid.\n " )
376385 (" import-snapshot" , po::value<string>(), " <path> Import blockchain and state data from the Parity Warp Sync snapshot." );
386+
377387 po::options_description generalOptions (" General Options" );
378388 generalOptions.add_options ()
379389 (" db-path,d" , po::value<string>(), " See description under." )
@@ -385,11 +395,14 @@ int main(int argc, char** argv)
385395 (" verbosity,v" , po::value<int >(), " <0 - 9> Set the log verbosity from 0 to 9 (default: 8)." )
386396 (" version,V" , " Show the version and exit." )
387397 (" help,h" , " Show this help message and exit.\n " );
398+
388399 po::options_description experimentalProofOfConcept (" Experimental / Proof of Concept" );
389400 experimentalProofOfConcept.add_options ()
390401 (" shh" , " Enable Whisper.\n " );
402+
391403 po::options_description allowedOptions (" Allowed options" );
392404 allowedOptions.add (clientDefaultMode).add (clientTransacting).add (clientMining).add (clientNetworking).add (importExportMode).add (generalOptions);
405+
393406 po::variables_map vm;
394407 vector<string> unrecognisedOptions;
395408 try
@@ -877,7 +890,7 @@ int main(int argc, char** argv)
877890 {
878891 cerr << " provided genesis block description is not well formatted\n " ;
879892 string genesisSample =
880- R"E(
893+ R"E(
881894 {
882895 "nonce": "0x0000000000000042",
883896 "difficulty": "0x400000000",
@@ -1014,10 +1027,10 @@ int main(int argc, char** argv)
10141027 bytes block = web3.ethereum ()->blockChain ().block (web3.ethereum ()->blockChain ().numberHash (i));
10151028 switch (exportFormat)
10161029 {
1017- case Format::Binary: out.write ((char const *)block.data (), block.size ()); break ;
1018- case Format::Hex: out << toHex (block) << " \n " ; break ;
1019- case Format::Human: out << RLP (block) << " \n " ; break ;
1020- default :;
1030+ case Format::Binary: out.write ((char const *)block.data (), block.size ()); break ;
1031+ case Format::Hex: out << toHex (block) << " \n " ; break ;
1032+ case Format::Human: out << RLP (block) << " \n " ; break ;
1033+ default :;
10211034 }
10221035 }
10231036 return 0 ;
@@ -1045,12 +1058,12 @@ int main(int argc, char** argv)
10451058
10461059 switch (web3.ethereum ()->queueBlock (block, safeImport))
10471060 {
1048- case ImportResult::Success: good++; break ;
1049- case ImportResult::AlreadyKnown: alreadyHave++; break ;
1050- case ImportResult::UnknownParent: unknownParent++; break ;
1051- case ImportResult::FutureTimeUnknown: unknownParent++; futureTime++; break ;
1052- case ImportResult::FutureTimeKnown: futureTime++; break ;
1053- default : bad++; break ;
1061+ case ImportResult::Success: good++; break ;
1062+ case ImportResult::AlreadyKnown: alreadyHave++; break ;
1063+ case ImportResult::UnknownParent: unknownParent++; break ;
1064+ case ImportResult::FutureTimeUnknown: unknownParent++; futureTime++; break ;
1065+ case ImportResult::FutureTimeKnown: futureTime++; break ;
1066+ default : bad++; break ;
10541067 }
10551068
10561069 // sync chain with queue
@@ -1185,14 +1198,14 @@ int main(int argc, char** argv)
11851198 return true ;
11861199
11871200 string r = getResponse (_t.userReadable (isProxy,
1188- [&](TransactionSkeleton const & _t) -> pair<bool , string>
1189- {
1190- h256 contractCodeHash = web3.ethereum ()->postState ().codeHash (_t.to );
1191- if (contractCodeHash == EmptySHA3)
1192- return std::make_pair (false , std::string ());
1193- // TODO: actually figure out the natspec. we'll need the natspec database here though.
1194- return std::make_pair (true , std::string ());
1195- }, [&](Address const & _a) { return _a.hex (); }
1201+ [&](TransactionSkeleton const & _t) -> pair<bool , string>
1202+ {
1203+ h256 contractCodeHash = web3.ethereum ()->postState ().codeHash (_t.to );
1204+ if (contractCodeHash == EmptySHA3)
1205+ return std::make_pair (false , std::string ());
1206+ // TODO: actually figure out the natspec. we'll need the natspec database here though.
1207+ return std::make_pair (true , std::string ());
1208+ }, [&](Address const & _a) { return _a.hex (); }
11961209 ) + " \n Enter yes/no/always (always to this address): " , {" yes" , " n" , " N" , " no" , " NO" , " always" });
11971210 if (r == " always" )
11981211 allowedDestinations.insert (_t.to );
@@ -1217,21 +1230,17 @@ int main(int argc, char** argv)
12171230 if (testingMode)
12181231 testEth = new rpc::Test (*web3.ethereum ());
12191232
1220- if (ipc)
1221- {
1222- jsonrpcIpcServer.reset (new FullServer (
1223- ethFace, new rpc::Whisper (web3, {}), new rpc::Net (web3),
1224- new rpc::Web3 (web3.clientVersion ()), new rpc::Personal (keyManager, *accountHolder, *web3.ethereum ()),
1225- new rpc::AdminEth (*web3.ethereum (), *gasPricer.get (), keyManager, *sessionManager.get ()),
1226- new rpc::AdminNet (web3, *sessionManager.get ()),
1227- new rpc::AdminUtils (*sessionManager.get ()),
1228- new rpc::Debug (*web3.ethereum ()),
1229- testEth
1230- ));
1231- auto ipcConnector = new IpcServer (" geth" );
1232- jsonrpcIpcServer->addConnector (ipcConnector);
1233- ipcConnector->StartListening ();
1234- }
1233+ jsonrpcIpcServer.reset (new FullServer (
1234+ ethFace, new rpc::Net (web3),
1235+ new rpc::Web3 (web3.clientVersion ()), new rpc::Personal (keyManager, *accountHolder, *web3.ethereum ()),
1236+ new rpc::AdminEth (*web3.ethereum (), *gasPricer.get (), keyManager, *sessionManager.get ()),
1237+ new rpc::AdminNet (web3, *sessionManager.get ()),
1238+ new rpc::Debug (*web3.ethereum ()),
1239+ testEth
1240+ ));
1241+ auto ipcConnector = new IpcServer (" geth" );
1242+ jsonrpcIpcServer->addConnector (ipcConnector);
1243+ ipcConnector->StartListening ();
12351244
12361245 if (jsonAdmin.empty ())
12371246 jsonAdmin = sessionManager->newSession (rpc::SessionPermissions{{rpc::Privilege::Admin}});
0 commit comments