Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version information for psinode and psitest #475

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/psibase/common/include/psibase/version.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#define PSIBASE_VERSION_MAJOR 0
#define PSIBASE_VERSION_MINOR 1
#define PSIBASE_VERSION_PATCH 6
16 changes: 14 additions & 2 deletions programs/psinode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <psibase/node.hpp>
#include <psibase/peer_manager.hpp>
#include <psibase/serviceEntry.hpp>
#include <psibase/version.hpp>
#include <psibase/websocket.hpp>
#include <psio/finally.hpp>
#include <psio/to_json.hpp>
Expand Down Expand Up @@ -445,7 +446,9 @@ struct transaction_queue
}

#define CATCH_IGNORE \
catch (...) {}
catch (...) \
{ \
}

bool push_boot(BlockContext& bc, transaction_queue::entry& entry)
{
Expand Down Expand Up @@ -2070,6 +2073,7 @@ int main(int argc, char* argv[])
std::string tls_key;
byte_size db_cache_size;
byte_size db_size;
bool version;

namespace po = boost::program_options;

Expand Down Expand Up @@ -2109,6 +2113,7 @@ int main(int argc, char* argv[])
#endif
opt("leeway", po::value<uint32_t>(&leeway_us)->default_value(200000),
"Transaction leeway, in µs.");
opt("version,V", po::bool_switch(&version), "Print version information");
desc.add(common_opts);
opt = desc.add_options();
// Options that can only be specified on the command line
Expand Down Expand Up @@ -2160,7 +2165,7 @@ int main(int argc, char* argv[])
}
catch (std::exception& e)
{
if (!vm.count("help"))
if (!vm.count("help") && !vm.count("version"))
{
std::cerr << e.what() << "\n";
return 1;
Expand All @@ -2174,6 +2179,13 @@ int main(int argc, char* argv[])
return 1;
}

if (version)
{
std::cerr << "psinode " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "."
<< PSIBASE_VERSION_PATCH << "\n";
return 1;
}

try
{
psibase::loggers::set_path(db_path);
Expand Down
24 changes: 19 additions & 5 deletions programs/psitest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <psibase/Prover.hpp>
#include <psibase/Watchdog.hpp>
#include <psibase/log.hpp>
#include <psibase/version.hpp>
#include <psio/to_bin.hpp>
#include <psio/to_json.hpp>

Expand Down Expand Up @@ -1001,6 +1002,10 @@ const char help[] = R"(

Show this message

-V, --version

Print version information

-v, --verbose

Show detailed logging
Expand All @@ -1018,16 +1023,17 @@ const char help[] = R"(
other constraints on debug.wasm. psibase still enforces
constraints on service.wasm. (repeatable)

--timing
--timing

Show how long transactions take in us.
Show how long transactions take in µs.
)";

int main(int argc, char* argv[])
{
bool show_usage = false;
bool error = false;
int verbose = 0;
bool show_usage = false;
bool error = false;
bool show_version = false;
int verbose = 0;
Loggers logConfig;
std::map<std::string, std::string> substitutions;
cl_flags_t additional_args;
Expand All @@ -1037,6 +1043,8 @@ int main(int argc, char* argv[])
{
if (!strcmp(argv[next_arg], "-h") || !strcmp(argv[next_arg], "--help"))
show_usage = true;
else if (!strcmp(argv[next_arg], "-V") || !strcmp(argv[next_arg], "--version"))
show_version = true;
else if (!strcmp(argv[next_arg], "-v") || !strcmp(argv[next_arg], "--verbose"))
{
++verbose;
Expand Down Expand Up @@ -1082,6 +1090,12 @@ int main(int argc, char* argv[])
}
if (next_arg >= argc)
error = true;
if (show_version)
{
std::cerr << "psitest " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "."
<< PSIBASE_VERSION_PATCH << "\n";
return 0;
}
if (show_usage || error)
{
std::cerr << usage;
Expand Down
Loading