mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
pow-testgiver support
This commit is contained in:
parent
dbde9c1c40
commit
f064b1047a
257 changed files with 6665 additions and 2608 deletions
|
@ -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"
|
||||
|
@ -91,12 +91,11 @@ 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];
|
||||
|
@ -104,7 +103,6 @@ int main(int argc, char *argv[]) {
|
|||
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
|
||||
|
@ -112,9 +110,8 @@ int main(int argc, char *argv[]) {
|
|||
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);
|
||||
|
@ -122,25 +119,26 @@ int main(int argc, char *argv[]) {
|
|||
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();
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "auto/tl/ton_api.h"
|
||||
|
||||
namespace ton {
|
||||
|
|
|
@ -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"
|
||||
|
@ -297,12 +297,11 @@ 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];
|
||||
|
@ -310,21 +309,16 @@ int main(int argc, char *argv[]) {
|
|||
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);
|
||||
|
@ -332,20 +326,21 @@ int main(int argc, char *argv[]) {
|
|||
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();
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
@ -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];
|
||||
|
|
|
@ -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"
|
||||
|
@ -591,9 +591,9 @@ 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;
|
||||
|
@ -601,31 +601,31 @@ int main(int argc, char* argv[]) {
|
|||
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);
|
||||
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "auto/tl/ton_api_json.h"
|
||||
#include "dht/dht.h"
|
||||
#include "overlay/overlays.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"
|
||||
|
@ -254,7 +254,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
td::actor::ActorOwn<HardforkCreator> x;
|
||||
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description("test collate block");
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
char b[10240];
|
||||
|
@ -262,27 +262,19 @@ int main(int argc, char *argv[]) {
|
|||
sb << p;
|
||||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) {
|
||||
td::actor::send_closure(x, &HardforkCreator::set_db_root, fname.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('m', "ext-message", "binary file with serialized inbound external message", [&](td::Slice fname) {
|
||||
td::actor::send_closure(x, &HardforkCreator::load_ext_message, fname.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('M', "top-shard-message", "binary file with serialized shard top block description",
|
||||
[&](td::Slice fname) {
|
||||
td::actor::send_closure(x, &HardforkCreator::load_shard_block_message, fname.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "root for dbs",
|
||||
[&](td::Slice fname) { td::actor::send_closure(x, &HardforkCreator::set_db_root, fname.str()); });
|
||||
p.add_option('m', "ext-message", "binary file with serialized inbound external message",
|
||||
[&](td::Slice fname) { td::actor::send_closure(x, &HardforkCreator::load_ext_message, fname.str()); });
|
||||
p.add_option(
|
||||
'M', "top-shard-message", "binary file with serialized shard top block description",
|
||||
[&](td::Slice fname) { td::actor::send_closure(x, &HardforkCreator::load_shard_block_message, fname.str()); });
|
||||
p.add_option('v', "verbosity", "set verbosity level", [&](td::Slice arg) {
|
||||
int v = VERBOSITY_NAME(FATAL) + (verbosity = td::to_integer<int>(arg));
|
||||
SET_VERBOSITY_LEVEL(v);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('w', "workchain", "<workchain>[:<shard>]\tcollate block in this workchain", [&](td::Slice arg) {
|
||||
p.add_checked_option('w', "workchain", "<workchain>[:<shard>]\tcollate block in this workchain", [&](td::Slice arg) {
|
||||
ton::ShardId shard = 0;
|
||||
auto pos = std::min(arg.find(':'), arg.size());
|
||||
TRY_RESULT(workchain, td::to_integer_safe<int>(arg.substr(0, pos)));
|
||||
|
@ -299,18 +291,18 @@ int main(int argc, char *argv[]) {
|
|||
ton::ShardIdFull{workchain, shard ? shard : ton::shardIdAll});
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('T', "top-block", "BlockIdExt of top block (new block will be generated atop of it)",
|
||||
[&](td::Slice arg) {
|
||||
ton::BlockIdExt block_id;
|
||||
if (block::parse_block_id_ext(arg, block_id)) {
|
||||
LOG(INFO) << "setting previous block to " << block_id.to_str();
|
||||
td::actor::send_closure(x, &HardforkCreator::set_shard_top_block, block_id);
|
||||
p.add_checked_option('T', "top-block", "BlockIdExt of top block (new block will be generated atop of it)",
|
||||
[&](td::Slice arg) {
|
||||
ton::BlockIdExt block_id;
|
||||
if (block::parse_block_id_ext(arg, block_id)) {
|
||||
LOG(INFO) << "setting previous block to " << block_id.to_str();
|
||||
td::actor::send_closure(x, &HardforkCreator::set_shard_top_block, block_id);
|
||||
|
||||
return td::Status::OK();
|
||||
} else {
|
||||
return td::Status::Error("cannot parse BlockIdExt");
|
||||
}
|
||||
});
|
||||
return td::Status::OK();
|
||||
} else {
|
||||
return td::Status::Error("cannot parse BlockIdExt");
|
||||
}
|
||||
});
|
||||
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
|
||||
td::set_signal_handler(td::SignalType::HangUp, [](int sig) {
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
|
@ -318,7 +310,6 @@ int main(int argc, char *argv[]) {
|
|||
setsid();
|
||||
#endif
|
||||
}).ensure();
|
||||
return td::Status::OK();
|
||||
});
|
||||
|
||||
td::actor::Scheduler scheduler({7});
|
||||
|
|
|
@ -259,6 +259,7 @@ set(FIFT_TEST_SOURCE
|
|||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
add_library(ton_crypto STATIC ${TON_CRYPTO_SOURCE})
|
||||
target_include_directories(ton_crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
|
@ -306,6 +307,12 @@ if (WINGETOPT_FOUND)
|
|||
target_link_libraries_system(tlbc wingetopt)
|
||||
endif()
|
||||
|
||||
add_executable(pow-miner util/pow-miner.cpp util/Miner.cpp util/Miner.h)
|
||||
target_link_libraries(pow-miner PUBLIC ton_crypto ton_block)
|
||||
if (WINGETOPT_FOUND)
|
||||
target_link_libraries_system(fift wingetopt)
|
||||
endif()
|
||||
|
||||
add_library(ton_block ${BLOCK_SOURCE})
|
||||
target_include_directories(ton_block PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/block> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
|
@ -371,6 +378,7 @@ if (NOT CMAKE_CROSSCOMPILING)
|
|||
GenFif(DEST smartcont/auto/restricted-wallet-code SOURCE smartcont/restricted-wallet-code.fc NAME restricted-wallet)
|
||||
GenFif(DEST smartcont/auto/restricted-wallet2-code SOURCE smartcont/restricted-wallet2-code.fc NAME restricted-wallet2)
|
||||
GenFif(DEST smartcont/auto/restricted-wallet3-code SOURCE smartcont/restricted-wallet3-code.fc NAME restricted-wallet3)
|
||||
GenFif(DEST smartcont/auto/pow-testgiver-code SOURCE smartcont/pow-testgiver-code.fc NAME pow-testgiver)
|
||||
|
||||
GenFif(DEST smartcont/auto/dns-manual-code SOURCE smartcont/dns-manual-code.fc NAME dns-manual)
|
||||
GenFif(DEST smartcont/auto/dns-auto-code SOURCE smartcont/dns-auto-code.fc NAME dns-auto)
|
||||
|
|
|
@ -267,6 +267,9 @@ class AnyIntView {
|
|||
return size() > 1 ? (double)digits[size() - 1] + (double)digits[size() - 2] * (1.0 / Tr::Base)
|
||||
: (double)digits[size() - 1];
|
||||
}
|
||||
bool is_odd_any() const {
|
||||
return size() > 0 && (digits[0] & 1);
|
||||
}
|
||||
word_t to_long_any() const;
|
||||
int parse_hex_any(const char* str, int str_len, int* frac = nullptr);
|
||||
int parse_binary_any(const char* str, int str_len, int* frac = nullptr);
|
||||
|
@ -658,6 +661,15 @@ class BigIntG {
|
|||
word_t to_long() const {
|
||||
return as_any_int().to_long_any();
|
||||
}
|
||||
bool is_odd() const {
|
||||
return n > 0 && (digits[0] & 1);
|
||||
}
|
||||
bool is_even() const {
|
||||
return n > 0 && !(digits[0] & 1);
|
||||
}
|
||||
word_t mod_pow2_short(int pow) const {
|
||||
return n > 0 ? digits[0] & ((1 << pow) - 1) : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
word_t top_word() const {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/buffer.h"
|
||||
|
||||
#include "bitstring.h"
|
||||
|
|
|
@ -399,6 +399,18 @@ x{B7B5} @Defop(8u+1) QUFITS
|
|||
x{B7B600} @Defop QFITSX
|
||||
x{B7B601} @Defop QUFITSX
|
||||
|
||||
// advanced integer constants
|
||||
{ 0 { over 1 and 0= } { 1+ swap 2/ swap } while } : pow2decomp
|
||||
{ dup 8 fits { PUSHINT } {
|
||||
dup pow2decomp over 1 = { nip nip PUSHPOW2 } {
|
||||
over -1 = { nip nip PUSHNEGPOW2 } {
|
||||
dup 20 >= { rot drop -rot PUSHINT swap LSHIFT# } {
|
||||
{ drop PUSHINT } {
|
||||
not pow2decomp swap -1 = { nip PUSHPOW2DEC } {
|
||||
drop PUSHINT
|
||||
} cond } cond } cond } cond } cond } cond
|
||||
} dup : PUSHINTX : INTX
|
||||
|
||||
// integer comparison
|
||||
x{B8} @Defop SGN
|
||||
x{B9} @Defop LESS
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "words.h"
|
||||
#include "td/utils/PathView.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/port/path.h"
|
||||
|
||||
namespace fift {
|
||||
|
|
|
@ -183,6 +183,9 @@ AsmOp AsmOp::IntConst(td::RefInt256 x) {
|
|||
if (k >= 0) {
|
||||
return AsmOp::Const(k, "PUSHNEGPOW2");
|
||||
}
|
||||
if (!x->mod_pow2_short(23)) {
|
||||
return AsmOp::Const(dec_string(std::move(x)) + " PUSHINTX");
|
||||
}
|
||||
return AsmOp::Const(dec_string(std::move(x)) + " PUSHINT");
|
||||
}
|
||||
|
||||
|
|
59
crypto/smartcont/new-pow-testgiver.fif
Normal file
59
crypto/smartcont/new-pow-testgiver.fif
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/fift -s
|
||||
"TonUtil.fif" include
|
||||
"Asm.fif" include
|
||||
|
||||
{ ."usage: " $0 type ." <workchain-id> <giver-id> <amount> <interval> <min-complexity> <init-complexity> <max-complexity> [<filename-base>]" cr
|
||||
."Creates a new proof-of-work testgiver with unique 32-bit identifier <giver-id> designed to deliver <amount> every <interval> seconds, with SHA256 hash complexity between 2**<min-complexity> and 2**<max-complexity>, with private key saved to or loaded from <filename-base>.pk" cr
|
||||
."('pow-giver.pk' by default)" cr 1 halt
|
||||
} : usage
|
||||
$# 7 - -2 and ' usage if
|
||||
|
||||
8 :$1..n
|
||||
$1 parse-workchain-id =: wc // set workchain id from command line argument
|
||||
$2 parse-int dup =: subwallet-id
|
||||
0= abort"giver-id must be non-zero"
|
||||
$3 $>GR =: amount
|
||||
$4 parse-int dup =: interval
|
||||
dup 24 ufits and 0= abort"invalid interval"
|
||||
$5 parse-int dup =: min-cpl
|
||||
1- 8 ufits not abort"invalid minimal log-complexity (must be 1..256)"
|
||||
$6 parse-int dup =: init-cpl
|
||||
1- 8 ufits not abort"invalid initial log-complexity (must be 1..256)"
|
||||
$7 parse-int dup =: max-cpl
|
||||
1- 8 ufits not abort"invalid maximal log-complexity (must be 1..256)"
|
||||
$8 "pow-giver" replace-if-null =: file-base
|
||||
|
||||
min-cpl init-cpl > abort"initial complexity cannot be below minimal complexity"
|
||||
max-cpl init-cpl < abort"initial complexity cannot exceed maximal complexity"
|
||||
subwallet-id (.) 1 ' $+ does : +subwallet
|
||||
|
||||
."Creating new proof-of-work testgiver in workchain " wc .
|
||||
."with unique giver id " subwallet-id . cr
|
||||
."Designed to give " amount .GR ."approximately every " interval . ."seconds" cr
|
||||
."Complexity (in SHA256 hashes): min=" min-cpl 1<< . ."init=" init-cpl 1<< . ."max=" max-cpl 1<< . cr
|
||||
|
||||
"auto/pow-testgiver-code.fif" include // code
|
||||
{ 256 swap - 8 u, } : cpl,
|
||||
<b 0 32 u, subwallet-id 32 u, // seqno wallet-id
|
||||
file-base +".pk" load-generate-keypair constant wallet_pk B, // pubkey
|
||||
newkeypair nip 16 B| drop B, // seed
|
||||
256 init-cpl - 1<< 256 u, // pow_complexity
|
||||
-1 32 i, // last_success
|
||||
<b amount Gram, interval 32 u, max-cpl cpl, min-cpl cpl, b> ref,
|
||||
b> // data
|
||||
null // no libraries
|
||||
<b b{0011} s, 3 roll ref, rot ref, swap dict, b> // create StateInit
|
||||
dup ."StateInit: " <s csr. cr
|
||||
dup hashu wc swap 2dup 2constant wallet_addr
|
||||
."new PoW testgiver address = " 2dup .addr cr
|
||||
2dup file-base +subwallet +".addr" save-address-verbose
|
||||
."Non-bounceable address (for init): " 2dup 7 .Addr cr
|
||||
."Bounceable address (for later access): " 6 .Addr cr
|
||||
<b subwallet-id 32 u, -1 32 i, 0 32 u, b>
|
||||
dup ."signing message: " <s csr. cr
|
||||
dup hashu wallet_pk ed25519_sign_uint rot
|
||||
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
|
||||
dup ."External message for initialization is " <s csr. cr
|
||||
2 boc+>B dup Bx. cr
|
||||
file-base +subwallet +"-query.boc" tuck B>file
|
||||
."(Saved proof-of-work testgiver creating query to file " type .")" cr
|
158
crypto/smartcont/pow-testgiver-code.fc
Normal file
158
crypto/smartcont/pow-testgiver-code.fc
Normal file
|
@ -0,0 +1,158 @@
|
|||
;; Advanced TestGiver smart contract with Proof-of-Work verification
|
||||
|
||||
int ufits(int x, int bits) impure asm "UFITSX";
|
||||
|
||||
() recv_internal(slice in_msg) impure {
|
||||
;; do nothing for internal messages
|
||||
}
|
||||
|
||||
() check_proof_of_work(slice cs) impure inline_ref {
|
||||
var hash = slice_hash(cs);
|
||||
var ds = get_data().begin_parse();
|
||||
var (stored_seqno_sw, public_key, seed, pow_complexity) = (ds~load_uint(64), ds~load_uint(256), ds~load_uint(128), ds~load_uint(256));
|
||||
throw_unless(24, hash < pow_complexity); ;; hash problem NOT solved
|
||||
var (op, flags, expire, whom, rdata1, rseed, rdata2) = (cs~load_uint(32), cs~load_int(8), cs~load_uint(32), cs~load_uint(256), cs~load_uint(256), cs~load_uint(128), cs~load_uint(256));
|
||||
cs.end_parse();
|
||||
ufits(expire - now(), 10);
|
||||
throw_unless(25, (rseed == seed) & (rdata1 == rdata2));
|
||||
;; Proof of Work correct
|
||||
accept_message();
|
||||
randomize_lt();
|
||||
randomize(rdata1);
|
||||
var (last_success, xdata) = (ds~load_uint(32), ds~load_ref());
|
||||
ds.end_parse();
|
||||
ds = xdata.begin_parse();
|
||||
var (amount, target_delta, min_cpl, max_cpl) = (ds~load_grams(), ds~load_uint(32), ds~load_uint(8), ds~load_uint(8));
|
||||
ds.end_parse();
|
||||
;; recompute complexity
|
||||
int delta = now() - last_success;
|
||||
if (delta > 0) {
|
||||
int factor = muldivr(delta, 1 << 128, target_delta);
|
||||
factor = min(max(factor, 7 << 125), 9 << 125); ;; factor must be in range 7/8 .. 9/8
|
||||
pow_complexity = muldivr(pow_complexity, factor, 1 << 128); ;; rescale complexity
|
||||
pow_complexity = min(max(pow_complexity, 1 << min_cpl), 1 << max_cpl);
|
||||
}
|
||||
;; update data
|
||||
set_data(begin_cell()
|
||||
.store_uint(stored_seqno_sw, 64)
|
||||
.store_uint(public_key, 256)
|
||||
.store_uint(random() >> 128, 128) ;; new seed
|
||||
.store_uint(pow_complexity, 256)
|
||||
.store_uint(now(), 32) ;; new last_success
|
||||
.store_ref(xdata)
|
||||
.end_cell());
|
||||
commit();
|
||||
;; create outbound message
|
||||
send_raw_message(begin_cell()
|
||||
.store_uint(((flags & 1) << 6) | 0x84, 9)
|
||||
.store_int(flags >> 2, 8)
|
||||
.store_uint(whom, 256)
|
||||
.store_grams(amount)
|
||||
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
|
||||
.end_cell(), 3);
|
||||
}
|
||||
|
||||
() rescale_complexity(slice cs) impure inline_ref {
|
||||
var (op, expire) = (cs~load_uint(32), cs~load_uint(32));
|
||||
cs.end_parse();
|
||||
int time = now();
|
||||
throw_unless(28, time > expire);
|
||||
var ds = get_data().begin_parse();
|
||||
var (skipped_data, pow_complexity, last_success, xdata) = (ds~load_bits(64 + 256 + 128), ds~load_uint(256), ds~load_uint(32), ds~load_ref());
|
||||
ds.end_parse();
|
||||
throw_unless(29, expire > last_success);
|
||||
ds = xdata.begin_parse();
|
||||
var (amount, target_delta) = (ds~load_grams(), ds~load_uint(32));
|
||||
int delta = time - last_success;
|
||||
throw_unless(30, delta >= target_delta * 16);
|
||||
accept_message();
|
||||
var (min_cpl, max_cpl) = (ds~load_uint(8), ds~load_uint(8));
|
||||
ds.end_parse();
|
||||
int factor = muldivr(delta, 1 << 128, target_delta);
|
||||
int max_complexity = (1 << max_cpl);
|
||||
int max_factor = muldiv(max_complexity, 1 << 128, pow_complexity);
|
||||
pow_complexity = (max_factor < factor ? max_complexity : muldivr(pow_complexity, factor, 1 << 128));
|
||||
last_success = time - target_delta;
|
||||
set_data(begin_cell()
|
||||
.store_slice(skipped_data)
|
||||
.store_uint(pow_complexity, 256)
|
||||
.store_uint(last_success, 32) ;; new last_success
|
||||
.store_ref(xdata)
|
||||
.end_cell());
|
||||
}
|
||||
|
||||
(slice, ()) ~update_params(slice ds, cell pref) inline_ref {
|
||||
var cs = pref.begin_parse();
|
||||
var reset_cpl = cs~load_uint(8);
|
||||
var (seed, pow_complexity, last_success) = (ds~load_uint(128), ds~load_uint(256), ds~load_uint(32));
|
||||
if (reset_cpl) {
|
||||
randomize(seed);
|
||||
pow_complexity = (1 << reset_cpl);
|
||||
seed = (random() >> 128);
|
||||
}
|
||||
var c = begin_cell()
|
||||
.store_uint(seed, 128)
|
||||
.store_uint(pow_complexity, 256)
|
||||
.store_uint(now(), 32)
|
||||
.store_ref(begin_cell().store_slice(cs).end_cell())
|
||||
.end_cell();
|
||||
return (begin_parse(c), ());
|
||||
}
|
||||
|
||||
() recv_external(slice in_msg) impure {
|
||||
var op = in_msg.preload_uint(32);
|
||||
if (op == 0x4d696e65) {
|
||||
;; Mine = Obtain test grams by presenting valid proof of work
|
||||
return check_proof_of_work(in_msg);
|
||||
}
|
||||
if (op == 0x5253636c) {
|
||||
;; RScl = Rescale complexity if no success for long time
|
||||
return rescale_complexity(in_msg);
|
||||
}
|
||||
var signature = in_msg~load_bits(512);
|
||||
var cs = in_msg;
|
||||
var (subwallet_id, valid_until, msg_seqno) = (cs~load_uint(32), cs~load_uint(32), cs~load_uint(32));
|
||||
throw_if(35, valid_until <= now());
|
||||
var ds = get_data().begin_parse();
|
||||
var (stored_seqno, stored_subwallet, public_key) = (ds~load_uint(32), ds~load_uint(32), ds~load_uint(256));
|
||||
throw_unless(33, msg_seqno == stored_seqno);
|
||||
throw_unless(34, (subwallet_id == stored_subwallet) | (subwallet_id == 0));
|
||||
throw_unless(35, check_signature(slice_hash(in_msg), signature, public_key));
|
||||
accept_message();
|
||||
cs~touch();
|
||||
while (cs.slice_refs()) {
|
||||
var ref = cs~load_ref();
|
||||
var mode = cs~load_uint(8);
|
||||
if (mode < 0xff) {
|
||||
send_raw_message(ref, mode);
|
||||
} else {
|
||||
ds~update_params(ref);
|
||||
}
|
||||
}
|
||||
set_data(begin_cell()
|
||||
.store_uint(stored_seqno + 1, 32)
|
||||
.store_uint(stored_subwallet, 32)
|
||||
.store_uint(public_key, 256)
|
||||
.store_slice(ds)
|
||||
.end_cell());
|
||||
}
|
||||
|
||||
;; Get methods
|
||||
|
||||
int seqno() method_id {
|
||||
return get_data().begin_parse().preload_uint(32);
|
||||
}
|
||||
|
||||
;; gets (seed, pow_complexity, amount, interval)
|
||||
(int, int, int, int) get_pow_params() method_id {
|
||||
var ds = get_data().begin_parse().skip_bits(32 + 32 + 256);
|
||||
var (seed, pow_complexity, xdata) = (ds~load_uint(128), ds~load_uint(256), ds.preload_ref());
|
||||
ds = xdata.begin_parse();
|
||||
return (seed, pow_complexity, ds~load_grams(), ds.preload_uint(32));
|
||||
}
|
||||
|
||||
int get_public_key() method_id {
|
||||
var ds = get_data().begin_parse();
|
||||
ds~load_uint(32 + 32);
|
||||
return ds.preload_uint(256);
|
||||
}
|
|
@ -46,8 +46,10 @@ $3 parse-int =: subwallet_id
|
|||
$4 parse-int =: seqno
|
||||
$5 $>cc extra-cc+! extra-currencies @ 2=: amount
|
||||
$6 "wallet-query" replace-if-null =: savefile
|
||||
subwallet_id (.) 1 ' $+ does : +subwallet
|
||||
|
||||
file-base +".addr" load-address
|
||||
file-base +subwallet +".addr" dup file-exists? { drop file-base +".addr" } ifnot
|
||||
load-address
|
||||
2dup 2constant wallet_addr
|
||||
."Source wallet address = " 2dup .addr cr 6 .Addr cr
|
||||
file-base +".pk" load-keypair nip constant wallet_pk
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "PaymentChannel.h"
|
||||
#include "GenericAccount.h"
|
||||
#include "vm/cells.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "vm/cells.h"
|
||||
#include "vm/cellslice.h"
|
||||
|
|
|
@ -288,7 +288,8 @@ std::string wycheproof_ed25519() {
|
|||
"sig" : "7c38e026f29e14aabd059a0f2db8b0cd783040609a8be684db12f82a27774ab07a9155711ecfaf7f99f277bad0c6ae7e39d4eef676573336a5c51eb6f946b30d2020",
|
||||
"result" : "invalid",
|
||||
"flags" : []
|
||||
},)abcd" R"abcd(
|
||||
},)abcd"
|
||||
R"abcd(
|
||||
{
|
||||
"tcId" : 34,
|
||||
"comment" : "include pk in signature",
|
||||
|
@ -570,7 +571,8 @@ std::string wycheproof_ed25519() {
|
|||
"flags" : [
|
||||
"SignatureMalleability"
|
||||
]
|
||||
},)abcd" R"abcd(
|
||||
},)abcd"
|
||||
R"abcd(
|
||||
{
|
||||
"tcId" : 68,
|
||||
"comment" : "checking malleability ",
|
||||
|
@ -858,7 +860,8 @@ std::string wycheproof_ed25519() {
|
|||
"flags" : []
|
||||
}
|
||||
]
|
||||
},)abcd" R"abcd(
|
||||
},)abcd"
|
||||
R"abcd(
|
||||
{
|
||||
"key" : {
|
||||
"curve" : "edwards25519",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include "vm/cellslice.h"
|
||||
#include <functional>
|
||||
|
||||
namespace tlb {
|
||||
|
||||
|
|
108
crypto/util/Miner.cpp
Normal file
108
crypto/util/Miner.cpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
#include "Miner.h"
|
||||
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include "td/utils/port/Clocks.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
namespace ton {
|
||||
#pragma pack(push, 1)
|
||||
struct HData {
|
||||
unsigned char op[4];
|
||||
signed char flags = -4;
|
||||
unsigned char expire[4] = {}, myaddr[32] = {}, rdata1[32] = {}, pseed[16] = {}, rdata2[32] = {};
|
||||
void inc() {
|
||||
for (long i = 31; !(rdata1[i] = ++(rdata2[i])); --i) {
|
||||
}
|
||||
}
|
||||
void set_expire(unsigned x) {
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
expire[i] = (x & 0xff);
|
||||
x >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
td::Slice as_slice() const {
|
||||
return td::Slice(reinterpret_cast<const td::uint8*>(this), sizeof(*this));
|
||||
}
|
||||
};
|
||||
|
||||
struct HDataEnv {
|
||||
unsigned char d1 = 0, d2 = sizeof(HData) * 2;
|
||||
HData body;
|
||||
|
||||
td::Slice as_slice() const {
|
||||
return td::Slice(reinterpret_cast<const td::uint8*>(this), sizeof(*this));
|
||||
}
|
||||
|
||||
void init(const block::StdAddress& my_address, td::Slice seed) {
|
||||
std::memcpy(body.myaddr, my_address.addr.data(), sizeof(body.myaddr));
|
||||
body.flags = static_cast<td::int8>(my_address.workchain * 4 + my_address.bounceable);
|
||||
CHECK(seed.size() == 16);
|
||||
std::memcpy(body.pseed, seed.data(), 16);
|
||||
std::memcpy(body.op, "Mine", 4);
|
||||
|
||||
td::Random::secure_bytes(body.rdata1, 32);
|
||||
std::memcpy(body.rdata2, body.rdata1, 32);
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_copyable<HDataEnv>::value, "HDataEnv must be a trivial type");
|
||||
#pragma pack(pop)
|
||||
|
||||
td::optional<std::string> Miner::run(const Options& options) {
|
||||
HDataEnv H;
|
||||
H.init(options.my_address, td::Slice(options.seed.data(), options.seed.size()));
|
||||
|
||||
td::Slice data = H.as_slice();
|
||||
CHECK(data.size() == 123);
|
||||
|
||||
constexpr size_t prefix_size = 72;
|
||||
constexpr size_t guard_pos = prefix_size - (72 - 28);
|
||||
CHECK(0 <= guard_pos && guard_pos < 32);
|
||||
size_t got_prefix_size = (const unsigned char*)H.body.rdata1 + guard_pos + 1 - (const unsigned char*)&H;
|
||||
CHECK(prefix_size == got_prefix_size);
|
||||
|
||||
auto head = data.substr(0, prefix_size);
|
||||
auto tail = data.substr(prefix_size);
|
||||
|
||||
SHA256_CTX shactx1, shactx2;
|
||||
std::array<td::uint8, 32> hash;
|
||||
SHA256_Init(&shactx1);
|
||||
auto guard = head.back();
|
||||
|
||||
td::int64 i = 0, i0 = 0;
|
||||
for (; i < options.max_iterations; i++) {
|
||||
if (!(i & 0xfffff) || head.back() != guard) {
|
||||
if (options.hashes_computed) {
|
||||
*options.hashes_computed += i - i0;
|
||||
}
|
||||
i0 = i;
|
||||
if (options.expire_at && options.expire_at.value().is_in_past(td::Timestamp::now())) {
|
||||
break;
|
||||
}
|
||||
H.body.set_expire((unsigned)td::Clocks::system() + 900);
|
||||
guard = head.back();
|
||||
SHA256_Init(&shactx1);
|
||||
SHA256_Update(&shactx1, head.ubegin(), head.size());
|
||||
}
|
||||
shactx2 = shactx1;
|
||||
SHA256_Update(&shactx2, tail.ubegin(), tail.size());
|
||||
SHA256_Final(hash.data(), &shactx2);
|
||||
|
||||
if (memcmp(hash.data(), options.complexity.data(), 32) < 0) {
|
||||
// FOUND
|
||||
if (options.hashes_computed) {
|
||||
*options.hashes_computed += i - i0;
|
||||
}
|
||||
return H.body.as_slice().str();
|
||||
}
|
||||
H.body.inc();
|
||||
}
|
||||
if (options.hashes_computed) {
|
||||
*options.hashes_computed += i - i0;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
} // namespace ton
|
23
crypto/util/Miner.h
Normal file
23
crypto/util/Miner.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "block/block.h"
|
||||
#include "td/utils/optional.h"
|
||||
#include "td/utils/Time.h"
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
|
||||
namespace ton {
|
||||
class Miner {
|
||||
public:
|
||||
struct Options {
|
||||
block::StdAddress my_address;
|
||||
std::array<td::uint8, 16> seed;
|
||||
std::array<td::uint8, 32> complexity;
|
||||
td::optional<td::Timestamp> expire_at;
|
||||
td::int64 max_iterations = std::numeric_limits<td::int64>::max();
|
||||
std::atomic<td::uint64>* hashes_computed{nullptr};
|
||||
};
|
||||
|
||||
static td::optional<std::string> run(const Options& options);
|
||||
};
|
||||
} // namespace ton
|
214
crypto/util/pow-miner.cpp
Normal file
214
crypto/util/pow-miner.cpp
Normal file
|
@ -0,0 +1,214 @@
|
|||
#include "common/bigint.hpp"
|
||||
#include "common/refint.h"
|
||||
#include "block/block.h"
|
||||
#include "td/utils/benchmark.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "vm/boc.h"
|
||||
#include "openssl/digest.hpp"
|
||||
#include <openssl/sha.h>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <cstdlib>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "Miner.h"
|
||||
|
||||
const char* progname;
|
||||
|
||||
int usage() {
|
||||
std::cerr
|
||||
<< "usage: " << progname
|
||||
<< " [-v][-B][-w<threads>] [-t<timeout>] <my-address> <pow-seed> <pow-complexity> <iterations> [<miner-addr> "
|
||||
"<output-ext-msg-boc>]\n"
|
||||
"Outputs a valid <rdata> value for proof-of-work testgiver after computing at most <iterations> hashes "
|
||||
"or terminates with non-zero exit code\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
||||
td::RefInt256 parse_bigint(std::string str, int bits) {
|
||||
int len = (int)str.size();
|
||||
auto num = td::make_refint();
|
||||
auto& x = num.write();
|
||||
if (len >= 3 && str[0] == '0' && str[1] == 'x') {
|
||||
if (x.parse_hex(str.data() + 2, len - 2) != len - 2) {
|
||||
return {};
|
||||
}
|
||||
} else if (!len || x.parse_dec(str.data(), len) != len) {
|
||||
return {};
|
||||
}
|
||||
return x.unsigned_fits_bits(bits) ? std::move(num) : td::RefInt256{};
|
||||
}
|
||||
|
||||
td::RefInt256 parse_bigint_chk(std::string str, int bits) {
|
||||
auto x = parse_bigint(std::move(str), bits);
|
||||
if (x.is_null()) {
|
||||
std::cerr << "fatal: `" << str << "` is not an integer" << std::endl;
|
||||
usage();
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
void parse_addr(std::string str, block::StdAddress& addr) {
|
||||
if (!addr.parse_addr(str) || (addr.workchain != -1 && addr.workchain != 0)) {
|
||||
std::cerr << "fatal: `" << str.c_str() << "` is not a valid blockchain address" << std::endl;
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
bool make_boc = false;
|
||||
std::string boc_filename;
|
||||
block::StdAddress miner_address;
|
||||
|
||||
int verbosity = 0;
|
||||
std::atomic<td::uint64> hashes_computed{0};
|
||||
td::Timestamp start_at;
|
||||
|
||||
void print_stats() {
|
||||
auto passed = td::Timestamp::now().at() - start_at.at();
|
||||
if (passed < 1e-9) {
|
||||
passed = 1;
|
||||
}
|
||||
std::cerr << "[ hashes computed: " << hashes_computed << " ]" << std::endl;
|
||||
std::cerr << "[ speed: " << static_cast<double>(hashes_computed) / passed << " hps ]" << std::endl;
|
||||
}
|
||||
|
||||
int found(td::Slice data) {
|
||||
for (unsigned i = 0; i < data.size(); i++) {
|
||||
printf("%02X", data.ubegin()[i]);
|
||||
}
|
||||
printf("\n");
|
||||
if (make_boc) {
|
||||
vm::CellBuilder cb;
|
||||
td::Ref<vm::Cell> ext_msg, body;
|
||||
CHECK(cb.store_bytes_bool(data) // body
|
||||
&& cb.finalize_to(body) // -> body
|
||||
&& cb.store_long_bool(0x44, 7) // ext_message_in$10 ...
|
||||
&& cb.store_long_bool(miner_address.workchain, 8) // workchain
|
||||
&& cb.store_bytes_bool(miner_address.addr.as_slice()) // miner addr
|
||||
&& cb.store_long_bool(1, 6) // amount:Grams ...
|
||||
&& cb.store_ref_bool(std::move(body)) // body:^Cell
|
||||
&& cb.finalize_to(ext_msg));
|
||||
auto boc = vm::std_boc_serialize(std::move(ext_msg), 2).move_as_ok();
|
||||
std::cerr << "Saving " << boc.size() << " bytes of serialized external message into file `" << boc_filename << "`"
|
||||
<< std::endl;
|
||||
td::write_file(boc_filename, boc).ensure();
|
||||
}
|
||||
if (verbosity > 0) {
|
||||
print_stats();
|
||||
}
|
||||
std::exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void miner(const ton::Miner::Options& options) {
|
||||
auto res = ton::Miner::run(options);
|
||||
if (res) {
|
||||
found(res.value());
|
||||
}
|
||||
}
|
||||
|
||||
class MinerBench : public td::Benchmark {
|
||||
public:
|
||||
std::string get_description() const override {
|
||||
return "Miner";
|
||||
}
|
||||
|
||||
void run(int n) override {
|
||||
ton::Miner::Options options;
|
||||
options.my_address.parse_addr("EQDU86V5wyPrLd4nQ0RHPcCLPZq_y1O5wFWyTsMw63vjXTOv");
|
||||
std::fill(options.seed.begin(), options.seed.end(), 0xa7);
|
||||
std::fill(options.complexity.begin(), options.complexity.end(), 0);
|
||||
options.max_iterations = n;
|
||||
CHECK(!ton::Miner::run(options));
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char* const argv[]) {
|
||||
ton::Miner::Options options;
|
||||
|
||||
progname = argv[0];
|
||||
int i, threads = 0;
|
||||
bool bounce = false, benchmark = false;
|
||||
while ((i = getopt(argc, argv, "bnvw:t:Bh")) != -1) {
|
||||
switch (i) {
|
||||
case 'v':
|
||||
++verbosity;
|
||||
break;
|
||||
case 'w':
|
||||
threads = atoi(optarg);
|
||||
CHECK(threads > 0 && threads <= 128);
|
||||
break;
|
||||
case 't': {
|
||||
int timeout = atoi(optarg);
|
||||
CHECK(timeout > 0);
|
||||
options.expire_at = td::Timestamp::in(timeout);
|
||||
break;
|
||||
}
|
||||
case 'B':
|
||||
benchmark = true;
|
||||
break;
|
||||
case 'b':
|
||||
bounce = true;
|
||||
break;
|
||||
case 'n':
|
||||
bounce = false;
|
||||
break;
|
||||
case 'h':
|
||||
return usage();
|
||||
default:
|
||||
std::cerr << "unknown option" << std::endl;
|
||||
return usage();
|
||||
}
|
||||
}
|
||||
if (benchmark && argc == optind) {
|
||||
td::bench(MinerBench());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc != optind + 4 && argc != optind + 6) {
|
||||
return usage();
|
||||
}
|
||||
|
||||
parse_addr(argv[optind], options.my_address);
|
||||
options.my_address.bounceable = bounce;
|
||||
CHECK(parse_bigint_chk(argv[optind + 1], 128)->export_bytes(options.seed.data(), 16, false));
|
||||
|
||||
auto cmplx = parse_bigint_chk(argv[optind + 2], 256);
|
||||
CHECK(cmplx->export_bytes(options.complexity.data(), 32, false));
|
||||
CHECK(!cmplx->unsigned_fits_bits(256 - 62));
|
||||
td::BigInt256 bigpower, hrate;
|
||||
bigpower.set_pow2(256).mod_div(*cmplx, hrate);
|
||||
long long hash_rate = hrate.to_long();
|
||||
options.max_iterations = parse_bigint_chk(argv[optind + 3], 50)->to_long();
|
||||
if (argc == optind + 6) {
|
||||
make_boc = true;
|
||||
parse_addr(argv[optind + 4], miner_address);
|
||||
boc_filename = argv[optind + 5];
|
||||
}
|
||||
|
||||
if (verbosity >= 2) {
|
||||
std::cerr << "[ expected required hashes for success: " << hash_rate << " ]" << std::endl;
|
||||
}
|
||||
if (benchmark) {
|
||||
td::bench(MinerBench());
|
||||
}
|
||||
|
||||
start_at = td::Timestamp::now();
|
||||
|
||||
options.hashes_computed = &hashes_computed;
|
||||
// may invoke several miner threads
|
||||
if (threads <= 0) {
|
||||
miner(options);
|
||||
} else {
|
||||
std::vector<std::thread> T;
|
||||
for (int i = 0; i < threads; i++) {
|
||||
T.emplace_back(miner, options);
|
||||
}
|
||||
for (auto& thr : T) {
|
||||
thr.join();
|
||||
}
|
||||
}
|
||||
if (verbosity > 0) {
|
||||
print_stats();
|
||||
}
|
||||
}
|
|
@ -23,9 +23,10 @@
|
|||
#include "vm/cells.h"
|
||||
#include "vm/cellslice.h"
|
||||
#include "td/utils/bits.h"
|
||||
#include "td/utils/Slice-decl.h"
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Slice-decl.h"
|
||||
|
||||
namespace vm {
|
||||
using td::Ref;
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "td/utils/Span.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace td {
|
||||
extern template class td::Cnt<std::string>;
|
||||
extern template class td::Ref<td::Cnt<std::string>>;
|
||||
|
@ -186,7 +188,7 @@ class StackEntry {
|
|||
private:
|
||||
static bool is_list(const StackEntry* se);
|
||||
template <typename T, Type tag>
|
||||
Ref<T> dynamic_as() const & {
|
||||
Ref<T> dynamic_as() const& {
|
||||
return tp == tag ? static_cast<Ref<T>>(ref) : td::Ref<T>{};
|
||||
}
|
||||
template <typename T, Type tag>
|
||||
|
@ -198,7 +200,7 @@ class StackEntry {
|
|||
return tp == tag ? static_cast<Ref<T>>(std::move(ref)) : td::Ref<T>{};
|
||||
}
|
||||
template <typename T, Type tag>
|
||||
Ref<T> as() const & {
|
||||
Ref<T> as() const& {
|
||||
return tp == tag ? Ref<T>{td::static_cast_ref(), ref} : td::Ref<T>{};
|
||||
}
|
||||
template <typename T, Type tag>
|
||||
|
@ -230,31 +232,31 @@ class StackEntry {
|
|||
return ref;
|
||||
}
|
||||
}
|
||||
td::RefInt256 as_int() const & {
|
||||
td::RefInt256 as_int() const& {
|
||||
return as<td::CntInt256, t_int>();
|
||||
}
|
||||
td::RefInt256 as_int() && {
|
||||
return move_as<td::CntInt256, t_int>();
|
||||
}
|
||||
Ref<Cell> as_cell() const & {
|
||||
Ref<Cell> as_cell() const& {
|
||||
return as<Cell, t_cell>();
|
||||
}
|
||||
Ref<Cell> as_cell() && {
|
||||
return move_as<Cell, t_cell>();
|
||||
}
|
||||
Ref<CellBuilder> as_builder() const & {
|
||||
Ref<CellBuilder> as_builder() const& {
|
||||
return as<CellBuilder, t_builder>();
|
||||
}
|
||||
Ref<CellBuilder> as_builder() && {
|
||||
return move_as<CellBuilder, t_builder>();
|
||||
}
|
||||
Ref<CellSlice> as_slice() const & {
|
||||
Ref<CellSlice> as_slice() const& {
|
||||
return as<CellSlice, t_slice>();
|
||||
}
|
||||
Ref<CellSlice> as_slice() && {
|
||||
return move_as<CellSlice, t_slice>();
|
||||
}
|
||||
Ref<Continuation> as_cont() const &;
|
||||
Ref<Continuation> as_cont() const&;
|
||||
Ref<Continuation> as_cont() &&;
|
||||
Ref<Cnt<std::string>> as_string_ref() const {
|
||||
return as<Cnt<std::string>, t_string>();
|
||||
|
@ -269,16 +271,16 @@ class StackEntry {
|
|||
std::string as_bytes() const {
|
||||
return tp == t_bytes ? *as_bytes_ref() : "";
|
||||
}
|
||||
Ref<Box> as_box() const &;
|
||||
Ref<Box> as_box() const&;
|
||||
Ref<Box> as_box() &&;
|
||||
Ref<Tuple> as_tuple() const &;
|
||||
Ref<Tuple> as_tuple() const&;
|
||||
Ref<Tuple> as_tuple() &&;
|
||||
Ref<Tuple> as_tuple_range(unsigned max_len = 255, unsigned min_len = 0) const &;
|
||||
Ref<Tuple> as_tuple_range(unsigned max_len = 255, unsigned min_len = 0) const&;
|
||||
Ref<Tuple> as_tuple_range(unsigned max_len = 255, unsigned min_len = 0) &&;
|
||||
Ref<Atom> as_atom() const &;
|
||||
Ref<Atom> as_atom() const&;
|
||||
Ref<Atom> as_atom() &&;
|
||||
template <class T>
|
||||
Ref<T> as_object() const & {
|
||||
Ref<T> as_object() const& {
|
||||
return dynamic_as<T, t_object>();
|
||||
}
|
||||
template <class T>
|
||||
|
@ -444,7 +446,7 @@ class Stack : public td::CntObject {
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
std::vector<StackEntry> extract_contents() const & {
|
||||
std::vector<StackEntry> extract_contents() const& {
|
||||
return stack;
|
||||
}
|
||||
std::vector<StackEntry> extract_contents() && {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "td/utils/filesystem.h"
|
||||
#include "td/actor/MultiPromise.h"
|
||||
#include "td/utils/overloaded.h"
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/port/path.h"
|
||||
#include "td/utils/port/user.h"
|
||||
#include "td/utils/port/signals.h"
|
||||
|
@ -1176,12 +1176,11 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
std::vector<std::function<void()>> acts;
|
||||
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description("dht server for TON DHT 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];
|
||||
|
@ -1189,17 +1188,14 @@ int main(int argc, char *argv[]) {
|
|||
sb << p;
|
||||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('C', "global-config", "file to read global config", [&](td::Slice fname) {
|
||||
acts.push_back([&x, fname = fname.str()]() { td::actor::send_closure(x, &DhtServer::set_global_config, fname); });
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('c', "local-config", "file to read local config", [&](td::Slice fname) {
|
||||
acts.push_back([&x, fname = fname.str()]() { td::actor::send_closure(x, &DhtServer::set_local_config, fname); });
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('I', "ip", "ip:port of instance", [&](td::Slice arg) {
|
||||
p.add_checked_option('I', "ip", "ip:port of instance", [&](td::Slice arg) {
|
||||
td::IPAddress addr;
|
||||
TRY_STATUS(addr.init_host_port(arg.str()));
|
||||
acts.push_back([&x, addr]() { td::actor::send_closure(x, &DhtServer::add_ip, addr); });
|
||||
|
@ -1207,7 +1203,6 @@ int main(int argc, char *argv[]) {
|
|||
});
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) {
|
||||
acts.push_back([&x, fname = fname.str()]() { td::actor::send_closure(x, &DhtServer::set_db_root, fname); });
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
|
@ -1215,28 +1210,27 @@ int main(int argc, char *argv[]) {
|
|||
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) {
|
||||
logger_ = td::TsFileLog::create(fname.str()).move_as_ok();
|
||||
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();
|
||||
|
||||
td::set_runtime_signal_handler(1, need_stats).ensure();
|
||||
|
|
|
@ -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 "td/utils/filesystem.h"
|
||||
#include "dht/dht.h"
|
||||
#include "auto/tl/ton_api_json.h"
|
||||
|
@ -265,7 +265,7 @@ td::Result<td::UInt256> get_uint256(std::string str) {
|
|||
int main(int argc, char *argv[]) {
|
||||
td::actor::ActorOwn<adnl::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];
|
||||
|
|
163
doc/TestGrams-HOWTO
Normal file
163
doc/TestGrams-HOWTO
Normal file
|
@ -0,0 +1,163 @@
|
|||
The aim of this text is to describe how to quickly obtain a small amount of test Grams for test purposes, or a larger amount of test Grams for running a validator in the test network. We assume familiarity with the TON Blockchain LiteClient as explained in the LiteClient-HOWTO, and with the procedure required to compile the LiteClient and other software. For obtaining larger amount of test Grams required for running a validator, we also assume acquaintance with the FullNode-HOWTO and Validator-HOWTO. You will also need a dedicated server powerful enough for running a Full Node in order to obtain the larger amount of test Grams. Obtaining small amounts of test Grams does not require a dedicated server and may be done in several minutes on a home computer.
|
||||
|
||||
1. Proof-of-Work TestGiver smart contracts
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In order to prevent a small number of malicious parties to collect all test Grams reserved for test purposes, a special kind of "Proof-of-Work TestGiver" smart contracts have been deployed in the masterchain of the test network. The addresses of these smart contacts are:
|
||||
|
||||
Small testgivers (deliver from 10 to 100 test Grams every several minutes):
|
||||
|
||||
kf-kkdY_B7p-77TLn2hUhM6QidWrrsl8FYWCIvBMpZKprBtN
|
||||
kf8SYc83pm5JkGt0p3TQRkuiM58O9Cr3waUtR9OoFq716lN-
|
||||
kf-FV4QTxLl-7Ct3E6MqOtMt-RGXMxi27g4I645lw6MTWraV
|
||||
kf_NSzfDJI1A3rOM0GQm7xsoUXHTgmdhN5-OrGD8uwL2JMvQ
|
||||
kf8gf1PQy4u2kURl-Gz4LbS29eaN4sVdrVQkPO-JL80VhOe6
|
||||
kf8kO6K6Qh6YM4ddjRYYlvVAK7IgyW8Zet-4ZvNrVsmQ4EOF
|
||||
kf-P_TOdwcCh0AXHhBpICDMxStxHenWdLCDLNH5QcNpwMHJ8
|
||||
kf91o4NNTryJ-Cw3sDGt9OTiafmETdVFUMvylQdFPoOxIsLm
|
||||
kf9iWhwk9GwAXjtwKG-vN7rmXT3hLIT23RBY6KhVaynRrIK7
|
||||
kf8JfFUEJhhpRW80_jqD7zzQteH6EBHOzxiOhygRhBdt4z2N
|
||||
|
||||
Large testgivers (deliver 10000 test Grams at least once a day):
|
||||
|
||||
kf8guqdIbY6kpMykR8WFeVGbZcP2iuBagXfnQuq0rGrxgE04
|
||||
kf9CxReRyaGj0vpSH0gRZkOAitm_yDHvgiMGtmvG-ZTirrMC
|
||||
kf-WXA4CX4lqyVlN4qItlQSWPFIy00NvO2BAydgC4CTeIUme
|
||||
kf8yF4oXfIj7BZgkqXM6VsmDEgCqWVSKECO1pC0LXWl399Vx
|
||||
kf9nNY69S3_heBBSUtpHRhIzjjqY0ChugeqbWcQGtGj-gQxO
|
||||
kf_wUXx-l1Ehw0kfQRgFtWKO07B6WhSqcUQZNyh4Jmj8R4zL
|
||||
kf_6keW5RniwNQYeq3DNWGcohKOwI85p-V2MsPk4v23tyO3I
|
||||
kf_NSPpF4ZQ7mrPylwk-8XQQ1qFD5evLnx5_oZVNywzOjSfh
|
||||
kf-uNWj4JmTJefr7IfjBSYQhFbd3JqtQ6cxuNIsJqDQ8SiEA
|
||||
kf8mO4l6ZB_eaMn1OqjLRrrkiBcSt7kYTvJC_dzJLdpEDKxn
|
||||
|
||||
The first ten smart contracts enable a tester willing to obtain a small amount of test Grams to obtain some without spending too much computing power (typically, several minutes of work of a home computer should suffice). The remaining smart contracts are for obtaining larger amounts of test Grams required for running a validator in the test network; typically, a day of work of a dedicated server powerful enough to run a validator should suffice to obtain the necessary amount.
|
||||
|
||||
You should randomly choose one of these "proof-of-work testgiver" smart contracts (from one of these two lists depending on your purpose) and obtain test Grams from this smart contract by a procedure similar to "mining". Essentially, you have to present an external message containing the proof of work and the address of your wallet to the chosen "proof-of-work testgiver" smart contract, and then the necessary amount will be sent to you.
|
||||
|
||||
2. The "mining" process
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In order to create an external message containing the "proof of work", you should run a special "mining" utility, compiled from the TON sources located in the GitHub repository. The utility is located in file './crypto/pow-miner' with respect to the build directory, and can be compiled by typing 'make pow-miner' in the build directory.
|
||||
|
||||
However, before running "pow-miner", you need to know the actual values of "seed" and "complexity" parameters of the chosen "proof-of-work testgiver" smart contract. This can be done by invoking get-method "get_pow_params" of this smart contract. For instance, if you use testgiver smart contract kf-kkdY_B7p-77TLn2hUhM6QidWrrsl8FYWCIvBMpZKprBtN, you can simply type
|
||||
|
||||
> runmethod kf-kkdY_B7p-77TLn2hUhM6QidWrrsl8FYWCIvBMpZKprBtN get_pow_params
|
||||
|
||||
in the LiteClient console and obtain output like
|
||||
|
||||
...
|
||||
arguments: [ 101616 ]
|
||||
result: [ 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498432 100000000000 256 ]
|
||||
remote result (not to be trusted): [ 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498432 100000000000 256 ]
|
||||
|
||||
The two first large numbers in the "result:" line are the "seed" and the "complexity" of this smart contract. In this example, the seed is 229760179690128740373110445116482216837 and the complexity is 53919893334301279589334030174039261347274288845081144962207220498432.
|
||||
|
||||
Next, you invoke the pow-miner utility as follows:
|
||||
|
||||
$ crypto/pow-miner -vv -w<num-threads> -t<timeout-in-sec> <your-wallet-address> <seed> <complexity> <iterations> <pow-testgiver-address> <boc-filename>
|
||||
|
||||
Here <num-threads> is the number of CPU cores that you want to use for mining, <timeout-in-sec> is the maximal amount of seconds that the miner would run before admitting failure, <your-wallet-address> is the address of your wallet (possibly not initialized yet), either in the masterchain or in the workchain (note that you need a masterchain wallet to control a validator), <seed> and <complexity> are the most recent values obtained by running get-method 'get-pow-params', <pow-testgiver-address> is the address of the chosen proof-of-work testgiver smartcontract, and <boc-filename> is the filename of the output file where the external message with the proof of work will be saved in the case of success.
|
||||
|
||||
For example, if your wallet address is kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7, you might run
|
||||
|
||||
$ crypto/pow-miner -vv -w7 -t100 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498432 100000000000 kf-kkdY_B7p-77TLn2hUhM6QidWrrsl8FYWCIvBMpZKprBtN mined.boc
|
||||
|
||||
The program will run for some time (at most 100 seconds in this case) and either terminate successfully (with zero exit code) and save the required proof of work into file "mined.boc", or terminate with a non-zero exit code if no proof of work was found.
|
||||
|
||||
In the case of failure, you will see something like
|
||||
|
||||
[ expected required hashes for success: 2147483648 ]
|
||||
[ hashes computed: 1192230912 ]
|
||||
|
||||
and the program will terminate with a non-zero exit code. Then you have to obtain the "seed" and "complexity" again (because they may have changed in the meantime as a result of processing requests from more successful miners) and re-run the "pow-miner" with the new parameters, repeating the process again and again until success.
|
||||
|
||||
In the case of success, you will see something like
|
||||
|
||||
[ expected required hashes for success: 2147483648 ]
|
||||
4D696E65005EFE49705690D2AACC203003DBE333046683B698EF945FF250723C0F73297A2A1A41E2F1A1F533B3BC4F5664D6C743C1C5C74BB3342F3A7314364B3D0DA698E6C80C1EA4ACDA33755876665780BAE9BE8A4D6385A1F533B3BC4F5664D6C743C1C5C74BB3342F3A7314364B3D0DA698E6C80C1EA4
|
||||
Saving 176 bytes of serialized external message into file `mined.boc`
|
||||
[ hashes computed: 1122036095 ]
|
||||
|
||||
Then you can use the LiteClient to send external message from file "mined.boc" to the proof-of-work testgiver smart contract (and you must do this as soon as possible):
|
||||
|
||||
> sendfile mined.boc
|
||||
... external message status is 1
|
||||
|
||||
You can wait for several seconds and check the state of your wallet:
|
||||
|
||||
> last
|
||||
> getaccount kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7
|
||||
...
|
||||
account state is (account
|
||||
addr:(addr_std
|
||||
anycast:nothing workchain_id:0 address:x5690D2AACC203003DBE333046683B698EF945FF250723C0F73297A2A1A41E2F1)
|
||||
storage_stat:(storage_info
|
||||
used:(storage_used
|
||||
cells:(var_uint len:1 value:1)
|
||||
bits:(var_uint len:1 value:111)
|
||||
public_cells:(var_uint len:0 value:0)) last_paid:1593722498
|
||||
due_payment:nothing)
|
||||
storage:(account_storage last_trans_lt:7720869000002
|
||||
balance:(currencies
|
||||
grams:(nanograms
|
||||
amount:(var_uint len:5 value:100000000000))
|
||||
other:(extra_currencies
|
||||
dict:hme_empty))
|
||||
state:account_uninit))
|
||||
x{C005690D2AACC203003DBE333046683B698EF945FF250723C0F73297A2A1A41E2F12025BC2F7F2341000001C169E9DCD0945D21DBA0004_}
|
||||
last transaction lt = 7720869000001 hash = 83C15CDED025970FEF7521206E82D2396B462AADB962C7E1F4283D88A0FAB7D4
|
||||
account balance is 100000000000ng
|
||||
|
||||
If nobody has sent a valid proof of work with this *seed* and *complexity* before you, the proof-of-work testgiver will accept your proof of work and this will be reflected in the balance of your wallet (10 or 20 seconds may elapse after sending the external message before this happens; be sure to make several attempts and type "last" each time before checking the balance of your wallet to refresh the LiteClient state). In the case of success, you will see that the balance has been increased (and even that your wallet has been created in uninitialized state if it did not exist before). In the case of failure, you will have to obtain the new "seed" and "complexity" and repeat the mining process from the very beginning.
|
||||
|
||||
If you have been lucky and the balance of your wallet has been increased, you may want to initialize the wallet if it wasn't initialized before (more information on wallet creation can be found in LiteClient-HOWTO):
|
||||
|
||||
> sendfile new-wallet-query.boc
|
||||
... external message status is 1
|
||||
> last
|
||||
> getaccount kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7
|
||||
...
|
||||
account state is (account
|
||||
addr:(addr_std
|
||||
anycast:nothing workchain_id:0 address:x5690D2AACC203003DBE333046683B698EF945FF250723C0F73297A2A1A41E2F1)
|
||||
storage_stat:(storage_info
|
||||
used:(storage_used
|
||||
cells:(var_uint len:1 value:3)
|
||||
bits:(var_uint len:2 value:1147)
|
||||
public_cells:(var_uint len:0 value:0)) last_paid:1593722691
|
||||
due_payment:nothing)
|
||||
storage:(account_storage last_trans_lt:7720945000002
|
||||
balance:(currencies
|
||||
grams:(nanograms
|
||||
amount:(var_uint len:5 value:99995640998))
|
||||
other:(extra_currencies
|
||||
dict:hme_empty))
|
||||
state:(account_active
|
||||
(
|
||||
split_depth:nothing
|
||||
special:nothing
|
||||
code:(just
|
||||
value:(raw@^Cell
|
||||
x{}
|
||||
x{FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54}
|
||||
))
|
||||
data:(just
|
||||
value:(raw@^Cell
|
||||
x{}
|
||||
x{00000001CE6A50A6E9467C32671667F8C00C5086FC8D62E5645652BED7A80DF634487715}
|
||||
))
|
||||
library:hme_empty))))
|
||||
x{C005690D2AACC203003DBE333046683B698EF945FF250723C0F73297A2A1A41E2F1206811EC2F7F23A1800001C16B0BC790945D20D1929934_}
|
||||
x{FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54}
|
||||
x{00000001CE6A50A6E9467C32671667F8C00C5086FC8D62E5645652BED7A80DF634487715}
|
||||
last transaction lt = 7720945000001 hash = 73353151859661AB0202EA5D92FF409747F201D10F1E52BD0CBB93E1201676BF
|
||||
account balance is 99995640998ng
|
||||
|
||||
Now you are a happy owner of 100 test Grams that can be used for whatever testing purposes you had in mind. Congratulations!
|
||||
|
||||
3. Automating the mining process in the case of failure
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you fail to obtain your test Grams for a long time, this may happen because too many other testers are simultaneously "mining" from the same proof-of-work testgiver smart contract. Maybe you should choose another proof-of-work testgiver smart contract from one of the lists given above. Alternatively, you can write a simple script to automatically run `pow-miner` with the correct parameters again and again until success (detected by checking the exit code of `pow-miner`) and invoke the lite-client with parameter -c 'sendfile mined.boc' to send the external message immediately after it is found.
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
#include "http/http-client.h"
|
||||
|
||||
#include "td/utils/port/signals.h"
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/FileLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -258,12 +258,11 @@ int main(int argc, char *argv[]) {
|
|||
td::log_interface = td::default_log_interface;
|
||||
};
|
||||
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description("simple http proxy");
|
||||
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];
|
||||
|
@ -271,9 +270,8 @@ int main(int argc, char *argv[]) {
|
|||
sb << p;
|
||||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('p', "port", "sets listening port", [&](td::Slice arg) -> td::Status {
|
||||
p.add_checked_option('p', "port", "sets listening port", [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(port, td::to_integer_safe<td::uint16>(arg));
|
||||
td::actor::send_closure(x, &HttpProxy::set_port, port);
|
||||
return td::Status::OK();
|
||||
|
@ -285,13 +283,11 @@ int main(int argc, char *argv[]) {
|
|||
setsid();
|
||||
#endif
|
||||
}).ensure();
|
||||
return td::Status::OK();
|
||||
});
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
|
||||
logger_ = td::FileLog::create(fname.str()).move_as_ok();
|
||||
td::log_interface = logger_.get();
|
||||
return td::Status::OK();
|
||||
});
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
#include "http.h"
|
||||
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ton {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "tl-utils/lite-utils.hpp"
|
||||
#include "auto/tl/ton_api_json.h"
|
||||
#include "auto/tl/lite_api.hpp"
|
||||
#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"
|
||||
|
@ -4167,7 +4167,7 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
td::actor::ActorOwn<TestNode> x;
|
||||
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description("Test Lite Client for TON Blockchain");
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
char b[10240];
|
||||
|
@ -4175,30 +4175,21 @@ int main(int argc, char* argv[]) {
|
|||
sb << p;
|
||||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('C', "global-config", "file to read global config", [&](td::Slice fname) {
|
||||
td::actor::send_closure(x, &TestNode::set_global_config, fname.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('r', "disable-readline", "", [&]() {
|
||||
td::actor::send_closure(x, &TestNode::set_readline_enabled, false);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('R', "enable-readline", "", [&]() {
|
||||
td::actor::send_closure(x, &TestNode::set_readline_enabled, true);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) {
|
||||
td::actor::send_closure(x, &TestNode::set_db_root, fname.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('L', "print-limit", "sets maximum count of recursively printed objects", [&](td::Slice arg) {
|
||||
p.add_option('C', "global-config", "file to read global config",
|
||||
[&](td::Slice fname) { td::actor::send_closure(x, &TestNode::set_global_config, fname.str()); });
|
||||
p.add_option('r', "disable-readline", "",
|
||||
[&]() { td::actor::send_closure(x, &TestNode::set_readline_enabled, false); });
|
||||
p.add_option('R', "enable-readline", "",
|
||||
[&]() { td::actor::send_closure(x, &TestNode::set_readline_enabled, true); });
|
||||
p.add_option('D', "db", "root for dbs",
|
||||
[&](td::Slice fname) { td::actor::send_closure(x, &TestNode::set_db_root, fname.str()); });
|
||||
p.add_checked_option('L', "print-limit", "sets maximum count of recursively printed objects", [&](td::Slice arg) {
|
||||
auto plimit = td::to_integer<int>(arg);
|
||||
td::actor::send_closure(x, &TestNode::set_print_limit, plimit);
|
||||
return plimit >= 0 ? td::Status::OK() : td::Status::Error("printing limit must be non-negative");
|
||||
});
|
||||
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");
|
||||
|
@ -4206,27 +4197,21 @@ int main(int argc, char* argv[]) {
|
|||
p.add_option('i', "idx", "set liteserver idx", [&](td::Slice arg) {
|
||||
auto idx = td::to_integer<int>(arg);
|
||||
td::actor::send_closure(x, &TestNode::set_liteserver_idx, idx);
|
||||
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, &TestNode::set_remote_addr, addr);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('c', "cmd", "schedule command", [&](td::Slice arg) {
|
||||
td::actor::send_closure(x, &TestNode::add_cmd, td::BufferSlice{arg});
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('c', "cmd", "schedule command",
|
||||
[&](td::Slice arg) { td::actor::send_closure(x, &TestNode::add_cmd, td::BufferSlice{arg}); });
|
||||
p.add_option('t', "timeout", "timeout in batch mode", [&](td::Slice arg) {
|
||||
auto d = td::to_double(arg);
|
||||
td::actor::send_closure(x, &TestNode::set_fail_timeout, td::Timestamp::in(d));
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('p', "pub", "remote public key", [&](td::Slice arg) {
|
||||
td::actor::send_closure(x, &TestNode::set_public_key, td::BufferSlice{arg});
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('p', "pub", "remote public key",
|
||||
[&](td::Slice arg) { td::actor::send_closure(x, &TestNode::set_public_key, td::BufferSlice{arg}); });
|
||||
p.add_option('d', "daemonize", "set SIGHUP", [&]() {
|
||||
td::set_signal_handler(td::SignalType::HangUp, [](int sig) {
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
|
@ -4234,7 +4219,6 @@ int main(int argc, char* argv[]) {
|
|||
setsid();
|
||||
#endif
|
||||
}).ensure();
|
||||
return td::Status::OK();
|
||||
});
|
||||
#if TD_DARWIN || TD_LINUX
|
||||
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
|
||||
|
@ -4244,7 +4228,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
dup2(FileLog.get_native_fd().fd(), 1);
|
||||
dup2(FileLog.get_native_fd().fd(), 2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "http/http-client.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/Random.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
|
@ -1121,7 +1121,7 @@ int main(int argc, char *argv[]) {
|
|||
td::log_interface = td::default_log_interface;
|
||||
};
|
||||
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description(
|
||||
"A simple rldp-to-http and http-to-rldp proxy for running and accessing ton sites\n"
|
||||
"Example:\n\trldp-http-proxy -p 8080 -c 3333 -C ton-global.config.json\tRuns a local HTTP->RLDP proxy that "
|
||||
|
@ -1132,7 +1132,6 @@ int main(int argc, char *argv[]) {
|
|||
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 a help message", [&]() {
|
||||
char b[10240];
|
||||
|
@ -1140,45 +1139,41 @@ int main(int argc, char *argv[]) {
|
|||
sb << p;
|
||||
std::cout << sb.as_cslice().c_str();
|
||||
std::exit(2);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('p', "port", "sets http listening port", [&](td::Slice arg) -> td::Status {
|
||||
p.add_checked_option('p', "port", "sets http listening port", [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(port, td::to_integer_safe<td::uint16>(arg));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_port, port);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('a', "address", "local <ip>:<port> to use for adnl queries", [&](td::Slice arg) -> td::Status {
|
||||
p.add_checked_option('a', "address", "local <ip>:<port> to use for adnl queries", [&](td::Slice arg) -> td::Status {
|
||||
td::IPAddress addr;
|
||||
TRY_STATUS(addr.init_host_port(arg.str()));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_addr, addr);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('A', "adnl", "server ADNL addr", [&](td::Slice arg) -> td::Status {
|
||||
p.add_checked_option('A', "adnl", "server ADNL addr", [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(adnl, ton::adnl::AdnlNodeIdShort::parse(arg));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::add_adnl_addr, adnl);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('c', "client-port", "local <port> to use for client adnl queries", [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(port, td::to_integer_safe<td::uint16>(arg));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_client_port, port);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('C', "global-config", "global TON configuration file", [&](td::Slice arg) -> td::Status {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_global_config, arg.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('L', "local", "http hostname that will be proxied to http server at localhost:80",
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
td::IPAddress addr;
|
||||
TRY_STATUS(addr.init_ipv4_port("127.0.0.1", 80));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_local_host, arg.str(), addr);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "db root", [&](td::Slice arg) -> td::Status {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_db_root, arg.str());
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option(
|
||||
p.add_checked_option('c', "client-port", "local <port> to use for client adnl queries",
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(port, td::to_integer_safe<td::uint16>(arg));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_client_port, port);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('C', "global-config", "global TON configuration file",
|
||||
[&](td::Slice arg) { td::actor::send_closure(x, &RldpHttpProxy::set_global_config, arg.str()); });
|
||||
p.add_checked_option('L', "local", "http hostname that will be proxied to http server at localhost:80",
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
td::IPAddress addr;
|
||||
TRY_STATUS(addr.init_ipv4_port("127.0.0.1", 80));
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_local_host, arg.str(), addr);
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "db root",
|
||||
[&](td::Slice arg) { td::actor::send_closure(x, &RldpHttpProxy::set_db_root, arg.str()); });
|
||||
p.add_checked_option(
|
||||
'R', "remote",
|
||||
"<hostname>@<ip>:<port>, indicates a http hostname that will be proxied to remote http server at <ip>:<port>",
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
|
@ -1198,25 +1193,23 @@ int main(int argc, char *argv[]) {
|
|||
setsid();
|
||||
#endif
|
||||
}).ensure();
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('l', "logname", "log to file", [&](td::Slice fname) {
|
||||
logger_ = td::FileLog::create(fname.str()).move_as_ok();
|
||||
td::log_interface = logger_.get();
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('P', "proxy-all", "value=[YES|NO]. proxy all HTTP requests (default only *.ton and *.adnl)",
|
||||
[&](td::Slice value) {
|
||||
if (value == "YES" || value == "yes") {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_proxy_all, true);
|
||||
} else if (value == "NO" || value == "no") {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_proxy_all, false);
|
||||
} else {
|
||||
return td::Status::Error("--proxy-all expected YES or NO");
|
||||
}
|
||||
p.add_checked_option('P', "proxy-all", "value=[YES|NO]. proxy all HTTP requests (default only *.ton and *.adnl)",
|
||||
[&](td::Slice value) {
|
||||
if (value == "YES" || value == "yes") {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_proxy_all, true);
|
||||
} else if (value == "NO" || value == "no") {
|
||||
td::actor::send_closure(x, &RldpHttpProxy::set_proxy_all, false);
|
||||
} else {
|
||||
return td::Status::Error("--proxy-all expected YES or NO");
|
||||
}
|
||||
|
||||
return td::Status::OK();
|
||||
});
|
||||
return td::Status::OK();
|
||||
});
|
||||
|
||||
td::actor::Scheduler scheduler({7});
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "Ack.h"
|
||||
|
||||
namespace ton {
|
||||
|
|
19
rldp2/Ack.h
19
rldp2/Ack.h
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/int_types.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "Bbr.h"
|
||||
|
||||
#include "BdwStats.h"
|
||||
|
|
19
rldp2/Bbr.h
19
rldp2/Bbr.h
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "td/utils/int_types.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "BdwStats.h"
|
||||
|
||||
namespace ton {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Time.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "FecHelper.h"
|
||||
|
||||
#include "td/utils/check.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/int_types.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "InboundTransfer.h"
|
||||
|
||||
#include "common/errorcode.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/optional.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "LossSender.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "LossStats.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LossSender.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "OutboundTransfer.h"
|
||||
|
||||
namespace ton {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RldpSender.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "Pacer.h"
|
||||
namespace ton {
|
||||
namespace rldp2 {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "td/utils/optional.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "RldpConnection.h"
|
||||
|
||||
#include "td/utils/overloaded.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Bbr.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "RldpReceiver.h"
|
||||
|
||||
namespace ton {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Ack.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "RldpSender.h"
|
||||
|
||||
#include "RttStats.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Time.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "RttStats.h"
|
||||
#include <cmath>
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Time.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "SenderPackets.h"
|
||||
|
||||
#include "td/utils/bits.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/VectorQueue.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#include "rldp-in.hpp"
|
||||
#include "auto/tl/ton_api.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Slice.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "LoadSpeed.h"
|
||||
|
||||
#include "td/utils/format.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "MerkleTree.h"
|
||||
|
||||
#include "common/bitstring.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/optional.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "NodeActor.h"
|
||||
|
||||
#include "vm/boc.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LoadSpeed.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "PeerState.h"
|
||||
#include "Bitset.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "PeerActor.h"
|
||||
#include "auto/tl/ton_api.hpp"
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Bitset.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "PeerState.h"
|
||||
namespace ton {
|
||||
void PeerState::notify_node() {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "Torrent.h"
|
||||
|
||||
#include "td/utils/Status.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "MerkleTree.h"
|
||||
#include "TorrentMeta.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "TorrentCreator.h"
|
||||
|
||||
#include "td/db/utils/CyclicBuffer.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Torrent.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "TorrentHeader.hpp"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Slice.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "TorrentInfo.h"
|
||||
|
||||
#include "vm/cells/CellString.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/Slice.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "TorrentMeta.h"
|
||||
|
||||
#include "TorrentHeader.hpp"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "TorrentHeader.h"
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "adnl/adnl.h"
|
||||
#include "common/bigint.hpp"
|
||||
#include "common/bitstring.h"
|
||||
|
@ -11,7 +30,7 @@
|
|||
#include "td/utils/port/signals.h"
|
||||
#include "td/utils/Parser.h"
|
||||
#include "td/utils/overloaded.h"
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/PathView.h"
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
@ -807,37 +826,27 @@ int main(int argc, char *argv[]) {
|
|||
td::set_default_failure_signal_handler();
|
||||
|
||||
StorageCliOptions options;
|
||||
td::OptionsParser p;
|
||||
td::OptionParser p;
|
||||
p.set_description("experimental cli for ton storage");
|
||||
p.add_option('h', "help", "prints_help", [&]() {
|
||||
std::cout << (PSLICE() << p).c_str();
|
||||
std::exit(2);
|
||||
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) {
|
||||
auto verbosity = td::to_integer<int>(arg);
|
||||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(FATAL) + verbosity);
|
||||
return (verbosity >= 0 && verbosity <= 20) ? td::Status::OK() : td::Status::Error("verbosity must be 0..20");
|
||||
});
|
||||
p.add_option('C', "config", "set ton config", [&](td::Slice arg) {
|
||||
options.config = arg.str();
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) {
|
||||
options.db_root = fname.str();
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('I', "ip", "set ip:port", [&](td::Slice arg) {
|
||||
p.add_option('C', "config", "set ton config", [&](td::Slice arg) { options.config = arg.str(); });
|
||||
p.add_option('D', "db", "root for dbs", [&](td::Slice fname) { options.db_root = fname.str(); });
|
||||
p.add_checked_option('I', "ip", "set ip:port", [&](td::Slice arg) {
|
||||
td::IPAddress addr;
|
||||
TRY_STATUS(addr.init_host_port(arg.str()));
|
||||
options.addr = addr;
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('E', "execute", "execute one command", [&](td::Slice arg) {
|
||||
options.cmd = arg.str();
|
||||
return td::Status::OK();
|
||||
});
|
||||
p.add_option('d', "dir", "working directory", [&](td::Slice arg) { return td::chdir(arg.str()); });
|
||||
p.add_option('E', "execute", "execute one command", [&](td::Slice arg) { options.cmd = arg.str(); });
|
||||
p.add_checked_option('d', "dir", "working directory", [&](td::Slice arg) { return td::chdir(arg.str()); });
|
||||
|
||||
auto S = p.run(argc, argv);
|
||||
if (S.is_error()) {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#include "td/utils/benchmark.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include "td/utils/Container.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#include "td/db/utils/BlobView.h"
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2017-2019 Telegram Systems LLP
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
namespace td {
|
||||
class BlobViewImpl;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Span.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/port/IoSlice.h"
|
||||
|
||||
namespace td {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "td/utils/port/FileFd.h"
|
||||
#include "td/utils/Timer.h"
|
||||
|
@ -598,12 +598,13 @@ int main(int argc, char **argv) {
|
|||
Mode mode = Baseline;
|
||||
size_t buffer_size = 1024;
|
||||
|
||||
td::OptionsParser options_parser;
|
||||
options_parser.add_option('f', td::Slice("from"), td::Slice("read from file"), [&](td::Slice arg) -> td::Status {
|
||||
from = arg.str();
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_option('m', td::Slice("mode"), td::Slice("mode"), [&](td::Slice arg) -> td::Status {
|
||||
td::OptionParser options_parser;
|
||||
options_parser.add_checked_option('f', td::Slice("from"), td::Slice("read from file"),
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
from = arg.str();
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_checked_option('m', td::Slice("mode"), td::Slice("mode"), [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(x, td::to_integer_safe<int>(arg));
|
||||
switch (x) {
|
||||
case 0:
|
||||
|
@ -627,11 +628,12 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
return td::Status::Error("unknown mode");
|
||||
});
|
||||
options_parser.add_option('b', td::Slice("buffer"), td::Slice("buffer size"), [&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(x, td::to_integer_safe<size_t>(arg));
|
||||
buffer_size = x;
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_checked_option('b', td::Slice("buffer"), td::Slice("buffer size"),
|
||||
[&](td::Slice arg) -> td::Status {
|
||||
TRY_RESULT(x, td::to_integer_safe<size_t>(arg));
|
||||
buffer_size = x;
|
||||
return td::Status::OK();
|
||||
});
|
||||
|
||||
auto status = options_parser.run(argc, argv);
|
||||
if (status.is_error()) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
namespace td {
|
||||
namespace raptorq {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/utils/BufferedFd.h"
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/port/SocketFd.h"
|
||||
#include "td/utils/port/ServerSocketFd.h"
|
||||
#include "td/utils/Observer.h"
|
||||
|
@ -105,19 +105,14 @@ class PingClient : public td::actor::Actor, td::ObserverBase {
|
|||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
td::OptionsParser options_parser;
|
||||
td::OptionParser options_parser;
|
||||
options_parser.set_description("Tcp ping server/client (based on td::actors2)");
|
||||
|
||||
int port = 8081;
|
||||
bool is_client = false;
|
||||
options_parser.add_option('p', "port", "listen/connect to tcp port (8081 by default)", [&](td::Slice arg) {
|
||||
port = td::to_integer<int>(arg);
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_option('c', "client", "Work as client (server by default)", [&]() {
|
||||
is_client = true;
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_option('p', "port", "listen/connect to tcp port (8081 by default)",
|
||||
[&](td::Slice arg) { port = td::to_integer<int>(arg); });
|
||||
options_parser.add_option('c', "client", "Work as client (server by default)", [&]() { is_client = true; });
|
||||
auto status = options_parser.run(argc, argv);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << status.error();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/utils/OptionsParser.h"
|
||||
#include "td/utils/OptionParser.h"
|
||||
#include "td/utils/Observer.h"
|
||||
#include "td/utils/port/UdpSocketFd.h"
|
||||
|
||||
|
@ -113,21 +113,15 @@ class PingPong : public td::actor::Actor {
|
|||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
td::OptionsParser options_parser;
|
||||
td::OptionParser options_parser;
|
||||
options_parser.set_description("Udp ping server/client (8083 <-> 8084) (based on td::actors2)");
|
||||
|
||||
int from_port = 8083;
|
||||
int to_port = 8084;
|
||||
bool is_client = false;
|
||||
bool use_tcp = false;
|
||||
options_parser.add_option('c', "client", "Work as client (server by default)", [&]() {
|
||||
is_client = true;
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_option('t', "tcp", "Use tcp (udp by default)", [&]() {
|
||||
use_tcp = true;
|
||||
return td::Status::OK();
|
||||
});
|
||||
options_parser.add_option('c', "client", "Work as client (server by default)", [&]() { is_client = true; });
|
||||
options_parser.add_option('t', "tcp", "Use tcp (udp by default)", [&]() { use_tcp = true; });
|
||||
auto status = options_parser.run(argc, argv);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << status.error();
|
||||
|
|
|
@ -28,10 +28,11 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace td {
|
||||
namespace tl {
|
||||
namespace simple {
|
||||
// TL type is
|
||||
|
||||
std::string gen_cpp_name(std::string name) {
|
||||
for (std::size_t i = 0; i < name.size(); i++) {
|
||||
|
@ -92,6 +93,9 @@ struct Constructor {
|
|||
struct CustomType {
|
||||
std::string name;
|
||||
std::vector<const Constructor *> constructors;
|
||||
|
||||
mutable bool is_result_{false};
|
||||
mutable bool is_query_{false};
|
||||
};
|
||||
|
||||
struct Function {
|
||||
|
@ -120,6 +124,23 @@ class Schema {
|
|||
auto *from_function = config.get_function_by_num(function_num);
|
||||
functions.push_back(get_function(from_function));
|
||||
}
|
||||
for (auto &function : functions_) {
|
||||
mark_result(function->type);
|
||||
for (auto &arg : function->args) {
|
||||
mark_query(arg.type);
|
||||
}
|
||||
}
|
||||
|
||||
//for (auto custom_type : custom_types) {
|
||||
//std::cerr << custom_type->name;
|
||||
//if (custom_type->is_result_) {
|
||||
//std::cerr << " result";
|
||||
//}
|
||||
//if (custom_type->is_query_) {
|
||||
//std::cerr << " query";
|
||||
//}
|
||||
//std::cerr << std::endl;
|
||||
//}
|
||||
}
|
||||
|
||||
std::vector<const CustomType *> custom_types;
|
||||
|
@ -136,6 +157,34 @@ class Schema {
|
|||
std::map<std::int32_t, Constructor *> constructor_by_id;
|
||||
std::map<std::int32_t, Function *> function_by_id;
|
||||
|
||||
void mark_result(const Type *type) {
|
||||
do_mark(type, true);
|
||||
}
|
||||
|
||||
void mark_query(const Type *type) {
|
||||
do_mark(type, false);
|
||||
}
|
||||
|
||||
void do_mark(const Type *type, bool is_result) {
|
||||
if (type->type == Type::Vector) {
|
||||
return do_mark(type->vector_value_type, is_result);
|
||||
}
|
||||
if (type->type != Type::Custom) {
|
||||
return;
|
||||
}
|
||||
auto *custom = type->custom;
|
||||
auto &was = is_result ? custom->is_result_ : custom->is_query_;
|
||||
if (was) {
|
||||
return;
|
||||
}
|
||||
was = true;
|
||||
for (auto constructor : custom->constructors) {
|
||||
for (auto &arg : constructor->args) {
|
||||
do_mark(arg.type, is_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Type *get_type(const tl_type *from_type) {
|
||||
auto &type = type_by_id[from_type->id];
|
||||
if (!type) {
|
||||
|
@ -185,6 +234,7 @@ class Schema {
|
|||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
const CustomType *get_custom_type(const tl_type *from_type) {
|
||||
auto *type = get_type(from_type);
|
||||
assert(type->type == Type::Custom);
|
||||
|
@ -208,6 +258,7 @@ class Schema {
|
|||
}
|
||||
return constructor;
|
||||
}
|
||||
|
||||
const Function *get_function(const tl_combinator *from) {
|
||||
auto &function = function_by_id[from->id];
|
||||
if (!function) {
|
||||
|
@ -225,6 +276,7 @@ class Schema {
|
|||
}
|
||||
return function;
|
||||
}
|
||||
|
||||
const Type *get_type(const tl_tree *tree) {
|
||||
assert(tree->get_type() == NODE_TYPE_TYPE);
|
||||
auto *type_tree = static_cast<const tl_tree_type *>(tree);
|
||||
|
|
|
@ -10,6 +10,10 @@ else()
|
|||
set(TD_HAVE_GETOPT 1)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR "lib")
|
||||
endif()
|
||||
|
||||
if (NOT ZLIB_FOUND)
|
||||
find_package(ZLIB)
|
||||
endif()
|
||||
|
@ -67,6 +71,8 @@ set(TDUTILS_SOURCE
|
|||
td/utils/port/thread_local.cpp
|
||||
td/utils/port/user.cpp
|
||||
td/utils/port/UdpSocketFd.cpp
|
||||
td/utils/port/uname.cpp
|
||||
td/utils/port/user.cpp
|
||||
td/utils/port/wstring_convert.cpp
|
||||
|
||||
td/utils/port/detail/Epoll.cpp
|
||||
|
@ -79,6 +85,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/port/detail/Poll.cpp
|
||||
td/utils/port/detail/Select.cpp
|
||||
td/utils/port/detail/ThreadIdGuard.cpp
|
||||
td/utils/port/detail/ThreadPthread.cpp
|
||||
td/utils/port/detail/WineventPoll.cpp
|
||||
|
||||
${TDMIME_AUTO}
|
||||
|
@ -100,10 +107,11 @@ set(TDUTILS_SOURCE
|
|||
td/utils/logging.cpp
|
||||
td/utils/misc.cpp
|
||||
td/utils/MpmcQueue.cpp
|
||||
td/utils/OptionsParser.cpp
|
||||
td/utils/OptionParser.cpp
|
||||
td/utils/PathView.cpp
|
||||
td/utils/Random.cpp
|
||||
td/utils/Slice.cpp
|
||||
td/utils/SharedSlice.cpp
|
||||
td/utils/Slice.cpp
|
||||
td/utils/StackAllocator.cpp
|
||||
td/utils/Status.cpp
|
||||
td/utils/StringBuilder.cpp
|
||||
|
@ -113,6 +121,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/tests.cpp
|
||||
td/utils/tl_parsers.cpp
|
||||
td/utils/translit.cpp
|
||||
td/utils/TsFileLog.cpp
|
||||
td/utils/unicode.cpp
|
||||
td/utils/utf8.cpp
|
||||
|
||||
|
@ -143,6 +152,8 @@ set(TDUTILS_SOURCE
|
|||
td/utils/port/thread_local.h
|
||||
td/utils/port/user.h
|
||||
td/utils/port/UdpSocketFd.h
|
||||
td/utils/port/uname.h
|
||||
td/utils/port/user.h
|
||||
td/utils/port/wstring_convert.h
|
||||
|
||||
td/utils/port/detail/Epoll.h
|
||||
|
@ -155,6 +166,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/port/detail/Poll.h
|
||||
td/utils/port/detail/PollableFd.h
|
||||
td/utils/port/detail/Select.h
|
||||
td/utils/port/detail/skip_eintr.h
|
||||
td/utils/port/detail/ThreadIdGuard.h
|
||||
td/utils/port/detail/ThreadPthread.h
|
||||
td/utils/port/detail/ThreadStl.h
|
||||
|
@ -215,7 +227,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/ObjectPool.h
|
||||
td/utils/Observer.h
|
||||
td/utils/optional.h
|
||||
td/utils/OptionsParser.h
|
||||
td/utils/OptionParser.h
|
||||
td/utils/OrderedEventsProcessor.h
|
||||
td/utils/overloaded.h
|
||||
td/utils/Parser.h
|
||||
|
@ -224,6 +236,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/Random.h
|
||||
td/utils/ScopeGuard.h
|
||||
td/utils/SharedObjectPool.h
|
||||
td/utils/SharedSlice.h
|
||||
td/utils/Slice-decl.h
|
||||
td/utils/Slice.h
|
||||
td/utils/Span.h
|
||||
|
@ -235,6 +248,7 @@ set(TDUTILS_SOURCE
|
|||
td/utils/StorerBase.h
|
||||
td/utils/StringBuilder.h
|
||||
td/utils/tests.h
|
||||
td/utils/ThreadLocalStorage.h
|
||||
td/utils/ThreadSafeCounter.h
|
||||
td/utils/Time.h
|
||||
td/utils/TimedStat.h
|
||||
|
@ -244,6 +258,8 @@ set(TDUTILS_SOURCE
|
|||
td/utils/tl_parsers.h
|
||||
td/utils/tl_storers.h
|
||||
td/utils/translit.h
|
||||
td/utils/TsFileLog.h
|
||||
td/utils/TsList.h
|
||||
td/utils/type_traits.h
|
||||
td/utils/UInt.h
|
||||
td/utils/uint128.h
|
||||
|
@ -272,11 +288,13 @@ set(TDUTILS_TEST_SOURCE
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/test/HazardPointers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/heap.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/json.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/List.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/log.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/misc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcQueue.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcWaiter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/MpscLinkQueue.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/OptionParser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/OrderedEventsProcessor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/port.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/pq.cpp
|
||||
|
@ -294,7 +312,7 @@ if (WIN32)
|
|||
# find_library(WS2_32_LIBRARY ws2_32)
|
||||
# find_library(MSWSOCK_LIBRARY Mswsock)
|
||||
# target_link_libraries(tdutils PRIVATE ${WS2_32_LIBRARY} ${MSWSOCK_LIBRARY})
|
||||
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz)
|
||||
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz psapi)
|
||||
endif()
|
||||
if (NOT CMAKE_CROSSCOMPILING AND TDUTILS_MIME_TYPE)
|
||||
add_dependencies(tdutils tdmime_auto)
|
||||
|
@ -335,8 +353,6 @@ if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD")
|
|||
endif()
|
||||
|
||||
install(TARGETS tdutils EXPORT TdTargets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
|
|
|
@ -565,6 +565,7 @@ application/x-tex-tfm tfm
|
|||
application/x-texinfo texinfo texi
|
||||
application/x-tgif obj
|
||||
application/x-tgsticker tgs
|
||||
application/x-tgwallpattern tgv
|
||||
application/x-ustar ustar
|
||||
application/x-wais-source src
|
||||
application/x-x509-ca-cert der crt
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue