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

Commit

Permalink
Merge pull request #5491 from ethereum/return-error-codes
Browse files Browse the repository at this point in the history
Update Aleth tools to return error codes
  • Loading branch information
halfalicious authored Feb 13, 2019
2 parents df1048c + 73fd11d commit 4754e7a
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 137 deletions.
8 changes: 5 additions & 3 deletions aleth-bootnode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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 @@ -28,6 +29,7 @@ namespace fs = boost::filesystem;

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

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

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

/// Networking params.
Expand Down Expand Up @@ -149,5 +151,5 @@ int main(int argc, char** argv)
if (!netData.empty())
writeFile(getDataDir() / fs::path(c_networkConfigFileName), &netData);

return 0;
return AlethErrors::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(AlethErrors::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 AlethErrors::ArgumentProcessingFailure;
}

for (size_t i = 0; i < unrecognisedOptions.size(); ++i)
if (!m.interpretOption(i, unrecognisedOptions))
{
cerr << "Invalid argument: " << unrecognisedOptions[i] << endl;
return -1;
return AlethErrors::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 AlethErrors::Success;
}
if (vm.count("version"))
version();
Expand All @@ -99,5 +88,5 @@ int main(int argc, char** argv)

m.execute();

return 0;
return AlethErrors::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(AlethErrors::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 AlethErrors::UnknownArgument;
}
}
if (vm.count("help"))
{
cout << allowedOptions;
return 0;
return AlethErrors::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 AlethErrors::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 AlethErrors::Success;
}
Loading

0 comments on commit 4754e7a

Please sign in to comment.