Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Move bootnodes list from Host to Common
Browse files Browse the repository at this point in the history
Also define a new error code enum and return enum values for error conditions in all tooling main functions instead of -1.
  • Loading branch information
halfalicious committed Feb 13, 2019
1 parent 9b433b3 commit 08da798
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 162 deletions.
12 changes: 7 additions & 5 deletions aleth-bootnode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <libdevcore/FileSystem.h>
#include <libdevcore/LoggingProgramOptions.h>
#include <libethcore/Common.h>
#include <libp2p/Host.h>
#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>
Expand All @@ -16,6 +17,7 @@ namespace bi = boost::asio::ip;

using namespace dev;
using namespace dev::p2p;
using namespace dev::eth;
using namespace std;

namespace
Expand Down Expand Up @@ -68,7 +70,7 @@ int main(int argc, char** argv)
catch (po::error const& e)
{
cout << e.what() << "\n";
return -1;
return EthErrors::ArgumentProcessingFailure;
}

if (vm.count("help"))
Expand All @@ -78,7 +80,7 @@ int main(int argc, char** argv)
<< "USAGE:\n"
<< " " << c_programName << " [options]\n\n";
cout << generalOptions << clientNetworking << loggingProgramOptions;
return 0;
return EthErrors::Success;
}

/// Networking params.
Expand Down Expand Up @@ -125,13 +127,13 @@ int main(int argc, char** argv)
Host h(c_programName, netPrefs, &netData);
h.start();
if (!h.haveNetwork())
return -1;
return EthErrors::NetworkStartFailure;

cout << "Node ID: " << h.enode() << endl;

if (!noBootstrap)
{
for (auto const& bn : Host::pocHosts())
for (auto const& bn : defaultBootNodes())
{
bi::tcp::endpoint ep = Network::resolveHost(bn.second);
h.addNode(
Expand All @@ -153,5 +155,5 @@ int main(int argc, char** argv)
if (!netData.empty())
writeFile(getDataDir() / fs::path(c_networkConfigFileName), &netData);

return 0;
return EthErrors::Success;
}
29 changes: 9 additions & 20 deletions aleth-key/main.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.

#include "KeyAux.h"

#include <libdevcore/FileSystem.h>
#include <libdevcore/LoggingProgramOptions.h>
#include <libethcore/Common.h>
#include <libethcore/KeyManager.h>

#include <aleth/buildinfo.h>
Expand All @@ -40,7 +29,7 @@ void version()
const auto* buildinfo = aleth_get_buildinfo();
cout << "aleth-key " << buildinfo->project_version << "\nBuild: " << buildinfo->system_name << "/"
<< buildinfo->build_type << endl;
exit(0);
exit(EthErrors::Success);
}

int main(int argc, char** argv)
Expand Down Expand Up @@ -73,14 +62,14 @@ int main(int argc, char** argv)
catch (po::error const& e)
{
cerr << e.what();
return -1;
return EthErrors::ArgumentProcessingFailure;
}

for (size_t i = 0; i < unrecognisedOptions.size(); ++i)
if (!m.interpretOption(i, unrecognisedOptions))
{
cerr << "Invalid argument: " << unrecognisedOptions[i] << endl;
return -1;
return EthErrors::ArgumentProcessingFailure;
}

if (vm.count("help"))
Expand All @@ -90,7 +79,7 @@ int main(int argc, char** argv)
<< "Options:" << endl << endl;
KeyCLI::streamHelp(cout);
cout << allowedOptions;
return 0;
return EthErrors::Success;
}
if (vm.count("version"))
version();
Expand All @@ -99,5 +88,5 @@ int main(int argc, char** argv)

m.execute();

return 0;
return EthErrors::Success;
}
33 changes: 9 additions & 24 deletions aleth-vm/main.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/

/// @file
/// EVM Execution tool.
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.

#include <libdevcore/CommonIO.h>
#include <libdevcore/LoggingProgramOptions.h>
#include <libdevcore/SHA3.h>
#include <libethashseal/Ethash.h>
#include <libethashseal/GenesisInfo.h>
#include <libethcore/Common.h>
#include <libethcore/SealEngine.h>
#include <libethereum/Block.h>
#include <libethereum/ChainParams.h>
Expand Down Expand Up @@ -58,7 +43,7 @@ void version()
const auto* buildinfo = aleth_get_buildinfo();
cout << "aleth-vm " << buildinfo->project_version << "\n";
cout << "Build: " << buildinfo->system_name << "/" << buildinfo->build_type << "\n";
exit(0);
exit(EthErrors::Success);
}

enum class Mode
Expand Down Expand Up @@ -191,13 +176,13 @@ int main(int argc, char** argv)
else
{
cerr << "Unknown argument: " << arg << '\n';
return -1;
return EthErrors::UnknownArgument;
}
}
if (vm.count("help"))
{
cout << allowedOptions;
return 0;
return EthErrors::Success;
}
if (vm.count("version"))
{
Expand Down Expand Up @@ -243,7 +228,7 @@ int main(int argc, char** argv)
else
{
cerr << "Unknown network type: " << network << "\n";
return -1;
return EthErrors::UnknownNetworkType;
}
}
if (vm.count("input"))
Expand Down Expand Up @@ -377,5 +362,5 @@ int main(int argc, char** argv)
<< '\n';
cout << "exec time: " << fixed << setprecision(6) << execTime << '\n';
}
return 0;
return EthErrors::Success;
}
Loading

0 comments on commit 08da798

Please sign in to comment.