Skip to content

Commit

Permalink
pow-testgiver support
Browse files Browse the repository at this point in the history
  • Loading branch information
ton committed Jul 6, 2020
1 parent dbde9c1 commit f064b10
Show file tree
Hide file tree
Showing 257 changed files with 6,581 additions and 2,524 deletions.
42 changes: 20 additions & 22 deletions adnl/adnl-pong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "td/utils/port/IPAddress.h"
#include "td/net/UdpServer.h"
#include "td/utils/port/signals.h"
#include "td/utils/OptionsParser.h"
#include "td/utils/OptionParser.h"
#include "td/utils/FileLog.h"
#include "td/utils/port/path.h"
#include "td/utils/port/user.h"
Expand Down Expand Up @@ -91,56 +91,54 @@ int main(int argc, char *argv[]) {

std::string config = "/var/ton-work/etc/adnl-proxy.conf.json";

td::OptionsParser p;
td::OptionParser p;
p.set_description("adnl pinger");
p.add_option('v', "verbosity", "set verbosity level", [&](td::Slice arg) {
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
SET_VERBOSITY_LEVEL(v);
return td::Status::OK();
});
p.add_option('h', "help", "prints_help", [&]() {
char b[10240];
td::StringBuilder sb(td::MutableSlice{b, 10000});
sb << p;
std::cout << sb.as_cslice().c_str();
std::exit(2);
return td::Status::OK();
});
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
#if TD_DARWIN || TD_LINUX
close(0);
setsid();
#endif
td::set_signal_handler(td::SignalType::HangUp, force_rotate_logs).ensure();
return td::Status::OK();
});
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
p.add_checked_option('l', "logname", "log to file", [&](td::Slice fname) {
auto F = std::make_unique<td::FileLog>();
TRY_STATUS(F->init(fname.str(), std::numeric_limits<td::uint64>::max(), true));
logger_ = std::move(F);
td::log_interface = logger_.get();
return td::Status::OK();
});
td::uint32 threads = 7;
p.add_option('t', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
td::int32 v;
try {
v = std::stoi(fname.str());
} catch (...) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
}
if (v < 1 || v > 256) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
}
threads = v;
return td::Status::OK();
});
p.add_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user); });
p.add_option('k', "key", "private key", [&](td::Slice key) {
p.add_checked_option(
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
td::int32 v;
try {
v = std::stoi(fname.str());
} catch (...) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
}
if (v < 1 || v > 256) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
}
threads = v;
return td::Status::OK();
});
p.add_checked_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user.str()); });
p.add_checked_option('k', "key", "private key", [&](td::Slice key) {
TRY_RESULT_ASSIGN(pk, ton::PrivateKey::import(key));
return td::Status::OK();
});
p.add_option('a', "addr", "ip:port of instance", [&](td::Slice key) {
p.add_checked_option('a', "addr", "ip:port of instance", [&](td::Slice key) {
TRY_STATUS(addr.init_host_port(key.str()));
return td::Status::OK();
});
Expand Down
1 change: 1 addition & 0 deletions adnl/adnl-proxy-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include "td/utils/buffer.h"
#include "td/utils/Status.h"
#include "auto/tl/ton_api.h"

namespace ton {
Expand Down
43 changes: 19 additions & 24 deletions adnl/adnl-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "td/utils/port/IPAddress.h"
#include "td/net/UdpServer.h"
#include "td/utils/port/signals.h"
#include "td/utils/OptionsParser.h"
#include "td/utils/OptionParser.h"
#include "td/utils/FileLog.h"
#include "td/utils/port/path.h"
#include "td/utils/port/user.h"
Expand Down Expand Up @@ -297,55 +297,50 @@ int main(int argc, char *argv[]) {

std::string config = "/var/ton-work/etc/adnl-proxy.conf.json";

td::OptionsParser p;
td::OptionParser p;
p.set_description("validator or full node for TON network");
p.add_option('v', "verbosity", "set verbosity level", [&](td::Slice arg) {
int v = VERBOSITY_NAME(FATAL) + (td::to_integer<int>(arg));
SET_VERBOSITY_LEVEL(v);
return td::Status::OK();
});
p.add_option('h', "help", "prints_help", [&]() {
char b[10240];
td::StringBuilder sb(td::MutableSlice{b, 10000});
sb << p;
std::cout << sb.as_cslice().c_str();
std::exit(2);
return td::Status::OK();
});
p.add_option('c', "config", "config file", [&](td::Slice arg) {
config = arg.str();
return td::Status::OK();
});
p.add_option('c', "config", "config file", [&](td::Slice arg) { config = arg.str(); });
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
#if TD_DARWIN || TD_LINUX
close(0);
setsid();
#endif
td::set_signal_handler(td::SignalType::HangUp, force_rotate_logs).ensure();
return td::Status::OK();
});
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
p.add_checked_option('l', "logname", "log to file", [&](td::Slice fname) {
auto F = std::make_unique<td::FileLog>();
TRY_STATUS(F->init(fname.str(), std::numeric_limits<td::int64>::max(), true));
logger_ = std::move(F);
td::log_interface = logger_.get();
return td::Status::OK();
});
td::uint32 threads = 7;
p.add_option('t', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
td::int32 v;
try {
v = std::stoi(fname.str());
} catch (...) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
}
if (v < 1 || v > 256) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
}
threads = v;
return td::Status::OK();
});
p.add_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user); });
p.add_checked_option(
't', "threads", PSTRING() << "number of threads (default=" << threads << ")", [&](td::Slice fname) {
td::int32 v;
try {
v = std::stoi(fname.str());
} catch (...) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: not a number");
}
if (v < 1 || v > 256) {
return td::Status::Error(ton::ErrorCode::error, "bad value for --threads: should be in range [1..256]");
}
threads = v;
return td::Status::OK();
});
p.add_checked_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user.str()); });

p.run(argc, argv).ensure();

Expand Down
27 changes: 27 additions & 0 deletions adnl/adnl-tunnel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
/*
This file is part of TON Blockchain source code.
TON Blockchain 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 2
of the License, or (at your option) any later version.
TON Blockchain 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 TON Blockchain. If not, see <http://www.gnu.org/licenses/>.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the file(s),
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version. If you delete this exception statement
from all source files in the program, then also delete it here.
Copyright 2017-2020 Telegram Systems LLP
*/
#pragma once

#include "adnl.h"
Expand Down
4 changes: 2 additions & 2 deletions adnl/test/adnl-test-ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "keys/encryptor.h"
#include "td/utils/Time.h"
#include "td/utils/format.h"
#include "td/utils/OptionsParser.h"
#include "td/utils/OptionParser.h"

#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -168,7 +168,7 @@ td::Result<td::UInt256> get_uint256(std::string str) {
int main(int argc, char *argv[]) {
td::actor::ActorOwn<AdnlNode> x;

td::OptionsParser p;
td::OptionParser p;
p.set_description("test basic adnl functionality");
p.add_option('h', "help", "prints_help", [&]() {
char b[10240];
Expand Down
26 changes: 13 additions & 13 deletions blockchain-explorer/blockchain-explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "adnl/adnl-ext-client.h"
#include "adnl/utils.hpp"
#include "auto/tl/ton_api_json.h"
#include "td/utils/OptionsParser.h"
#include "td/utils/OptionParser.h"
#include "td/utils/Time.h"
#include "td/utils/filesystem.h"
#include "td/utils/format.h"
Expand Down Expand Up @@ -591,41 +591,41 @@ int main(int argc, char* argv[]) {

td::actor::ActorOwn<CoreActor> x;

td::OptionsParser p;
td::OptionParser p;
p.set_description("TON Blockchain explorer");
p.add_option('h', "help", "prints_help", [&]() {
p.add_checked_option('h', "help", "prints_help", [&]() {
char b[10240];
td::StringBuilder sb(td::MutableSlice{b, 10000});
sb << p;
std::cout << sb.as_cslice().c_str();
std::exit(2);
return td::Status::OK();
});
p.add_option('I', "hide-ips", "hides ips from status", [&]() {
p.add_checked_option('I', "hide-ips", "hides ips from status", [&]() {
td::actor::send_closure(x, &CoreActor::set_hide_ips, true);
return td::Status::OK();
});
p.add_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user); });
p.add_option('C', "global-config", "file to read global config", [&](td::Slice fname) {
p.add_checked_option('u', "user", "change user", [&](td::Slice user) { return td::change_user(user.str()); });
p.add_checked_option('C', "global-config", "file to read global config", [&](td::Slice fname) {
td::actor::send_closure(x, &CoreActor::set_global_config, fname.str());
return td::Status::OK();
});
p.add_option('a', "addr", "connect to ip:port", [&](td::Slice arg) {
p.add_checked_option('a', "addr", "connect to ip:port", [&](td::Slice arg) {
td::IPAddress addr;
TRY_STATUS(addr.init_host_port(arg.str()));
td::actor::send_closure(x, &CoreActor::set_remote_addr, addr);
return td::Status::OK();
});
p.add_option('p', "pub", "remote public key", [&](td::Slice arg) {
p.add_checked_option('p', "pub", "remote public key", [&](td::Slice arg) {
td::actor::send_closure(x, &CoreActor::set_remote_public_key, td::BufferSlice{arg});
return td::Status::OK();
});
p.add_option('v', "verbosity", "set verbosity level", [&](td::Slice arg) {
p.add_checked_option('v', "verbosity", "set verbosity level", [&](td::Slice arg) {
verbosity = td::to_integer<int>(arg);
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
return (verbosity >= 0 && verbosity <= 9) ? td::Status::OK() : td::Status::Error("verbosity must be 0..9");
});
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
p.add_checked_option('d', "daemonize", "set SIGHUP", [&]() {
td::set_signal_handler(td::SignalType::HangUp, [](int sig) {
#if TD_DARWIN || TD_LINUX
close(0);
Expand All @@ -634,16 +634,16 @@ int main(int argc, char* argv[]) {
}).ensure();
return td::Status::OK();
});
p.add_option('H', "http-port", "listen on http port", [&](td::Slice arg) {
p.add_checked_option('H', "http-port", "listen on http port", [&](td::Slice arg) {
td::actor::send_closure(x, &CoreActor::set_http_port, td::to_integer<td::uint32>(arg));
return td::Status::OK();
});
p.add_option('L', "local-scripts", "use local copy of ajax/bootstrap/... JS", [&]() {
p.add_checked_option('L', "local-scripts", "use local copy of ajax/bootstrap/... JS", [&]() {
local_scripts = true;
return td::Status::OK();
});
#if TD_DARWIN || TD_LINUX
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
p.add_checked_option('l', "logname", "log to file", [&](td::Slice fname) {
auto FileLog = td::FileFd::open(td::CSlice(fname.str().c_str()),
td::FileFd::Flags::Create | td::FileFd::Flags::Append | td::FileFd::Flags::Write)
.move_as_ok();
Expand Down
2 changes: 1 addition & 1 deletion catchain/catchain-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct CatChainNode {
};

struct CatChainOptions {
td::Clocks::Duration idle_timeout = 16.0;
double idle_timeout = 16.0;
td::uint32 max_deps = 4;

bool debug_disable_db = false;
Expand Down
Loading

0 comments on commit f064b10

Please sign in to comment.