1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

fix some warnings

This commit is contained in:
birydrad 2024-09-13 09:54:57 +02:00
parent 1c66852842
commit 71dbb48594
18 changed files with 151 additions and 122 deletions

View file

@ -333,6 +333,10 @@ add_cxx_compiler_flag("-Wno-sign-conversion")
add_cxx_compiler_flag("-Qunused-arguments")
add_cxx_compiler_flag("-Wno-unused-private-field")
add_cxx_compiler_flag("-Wno-redundant-move")
#add_cxx_compiler_flag("-Wno-unused-function")
#add_cxx_compiler_flag("-Wno-unused-variable")
#add_cxx_compiler_flag("-Wno-shorten-64-to-32")
#add_cxx_compiler_flag("-Werror")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1")

View file

@ -371,7 +371,7 @@ void CatChainReceiverImpl::add_block(td::BufferSlice payload, std::vector<CatCha
int height = prev->height_ + 1;
auto max_block_height = get_max_block_height(opts_, sources_.size());
if (height > max_block_height) {
if (td::narrow_cast<td::uint64>(height) > max_block_height) {
VLOG(CATCHAIN_WARNING) << this << ": cannot create block: max height exceeded (" << max_block_height << ")";
active_send_ = false;
return;

View file

@ -320,7 +320,7 @@ ton::ValidatorSessionConfig Config::get_consensus_config() const {
c.max_block_size = r.max_block_bytes;
c.max_collated_data_size = r.max_collated_bytes;
};
auto set_v2 = [&] (auto& r) {
auto set_v2 = [&](auto& r) {
set_v1(r);
c.new_catchain_ids = r.new_catchain_ids;
};
@ -1940,7 +1940,7 @@ td::Result<SizeLimitsConfig> Config::get_size_limits_config() const {
td::Result<SizeLimitsConfig> Config::do_get_size_limits_config(td::Ref<vm::CellSlice> cs) {
SizeLimitsConfig limits;
if (cs.is_null()) {
return limits; // default values
return limits; // default values
}
auto unpack_v1 = [&](auto& rec) {
limits.max_msg_bits = rec.max_msg_bits;
@ -2299,17 +2299,14 @@ td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
if (shard->sgn() < 0) {
shard &= ((td::make_refint(1) << 64) - 1);
}
return vm::make_tuple_ref(
td::make_refint(block_id.id.workchain),
std::move(shard),
td::make_refint(block_id.id.seqno),
td::bits_to_refint(block_id.root_hash.bits(), 256),
td::bits_to_refint(block_id.file_hash.bits(), 256));
return vm::make_tuple_ref(td::make_refint(block_id.id.workchain), std::move(shard),
td::make_refint(block_id.id.seqno), td::bits_to_refint(block_id.root_hash.bits(), 256),
td::bits_to_refint(block_id.file_hash.bits(), 256));
};
std::vector<vm::StackEntry> last_mc_blocks;
last_mc_blocks.push_back(block_id_to_tuple(block_id));
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16; ) {
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16;) {
--seqno;
ton::BlockIdExt block_id;
if (!get_old_mc_block_id(seqno, block_id)) {
@ -2323,9 +2320,8 @@ td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
if (!get_last_key_block(last_key_block, last_key_block_lt)) {
return td::Status::Error("cannot fetch last key block");
}
return vm::make_tuple_ref(
td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)),
block_id_to_tuple(last_key_block));
return vm::make_tuple_ref(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)),
block_id_to_tuple(last_key_block));
}
td::optional<PrecompiledContractsConfig::Contract> PrecompiledContractsConfig::get_contract(

View file

@ -197,6 +197,7 @@ struct McShardHash : public McShardHashI {
: blk_(blk), start_lt_(start_lt), end_lt_(end_lt) {
}
McShardHash(const McShardHash&) = default;
McShardHash& operator=(const McShardHash&) = default;
bool is_valid() const {
return blk_.is_valid();
}
@ -545,7 +546,10 @@ class Config {
};
public:
enum { needValidatorSet = 16, needSpecialSmc = 32, needWorkchainInfo = 256, needCapabilities = 512 };
static constexpr int needValidatorSet = 16;
static constexpr int needSpecialSmc = 32;
static constexpr int needWorkchainInfo = 256;
static constexpr int needCapabilities = 512;
int mode{0};
ton::BlockIdExt block_id;
@ -682,14 +686,12 @@ class Config {
class ConfigInfo : public Config, public ShardConfig {
public:
enum {
needStateRoot = 1,
needLibraries = 2,
needStateExtraRoot = 4,
needShardHashes = 8,
needAccountsRoot = 64,
needPrevBlocks = 128
};
static constexpr int needStateRoot = 1;
static constexpr int needLibraries = 2;
static constexpr int needStateExtraRoot = 4;
static constexpr int needShardHashes = 8;
static constexpr int needAccountsRoot = 64;
static constexpr int needPrevBlocks = 128;
ton::BlockSeqno vert_seqno{~0U};
int global_id_{0};
ton::UnixTime utime{0};

View file

@ -81,7 +81,7 @@ bool CodeBlob::compute_used_code_vars(std::unique_ptr<Op>& ops_ptr, const VarDes
func_assert(ops_ptr->cl == Op::_Nop);
return ops_ptr->set_var_info(var_info);
}
return compute_used_code_vars(ops_ptr->next, var_info, edit) | ops_ptr->compute_used_vars(*this, edit);
return int(compute_used_code_vars(ops_ptr->next, var_info, edit)) | int(ops_ptr->compute_used_vars(*this, edit));
}
bool operator==(const VarDescrList& x, const VarDescrList& y) {
@ -584,7 +584,7 @@ bool prune_unreachable(std::unique_ptr<Op>& ops) {
ops = std::move(op.block1);
return prune_unreachable(ops);
} else {
reach = prune_unreachable(op.block0) | prune_unreachable(op.block1);
reach = int(prune_unreachable(op.block0)) | int(prune_unreachable(op.block1));
}
break;
}
@ -660,7 +660,7 @@ bool prune_unreachable(std::unique_ptr<Op>& ops) {
break;
}
case Op::_TryCatch: {
reach = prune_unreachable(op.block0) | prune_unreachable(op.block1);
reach = int(prune_unreachable(op.block0)) | int(prune_unreachable(op.block1));
break;
}
default:
@ -892,15 +892,15 @@ bool Op::mark_noreturn() {
return set_noreturn(true);
case _If:
case _TryCatch:
return set_noreturn((block0->mark_noreturn() & (block1 && block1->mark_noreturn())) | next->mark_noreturn());
return set_noreturn((int(block0->mark_noreturn()) & int(block1 && block1->mark_noreturn())) | int(next->mark_noreturn()));
case _Again:
block0->mark_noreturn();
return set_noreturn(true);
case _Until:
return set_noreturn(block0->mark_noreturn() | next->mark_noreturn());
return set_noreturn(int(block0->mark_noreturn()) | int(next->mark_noreturn()));
case _While:
block1->mark_noreturn();
return set_noreturn(block0->mark_noreturn() | next->mark_noreturn());
return set_noreturn(int(block0->mark_noreturn()) | int(next->mark_noreturn()));
case _Repeat:
block0->mark_noreturn();
return set_noreturn(next->mark_noreturn());

View file

@ -87,9 +87,23 @@ int get_random_serialization_mode(T &rnd) {
return modes[rnd.fast(0, (int)modes.size() - 1)];
}
class BenchSha256 : public td::Benchmark {
class BenchSha : public td::Benchmark {
public:
explicit BenchSha(size_t n) : str_(n, 'a') {
}
std::string get_description() const override {
return PSTRING() << get_name() << " length=" << str_.size();
}
virtual std::string get_name() const = 0;
protected:
std::string str_;
};
class BenchSha256 : public BenchSha {
public:
using BenchSha::BenchSha;
std::string get_name() const override {
return "SHA256";
}
@ -97,7 +111,7 @@ class BenchSha256 : public td::Benchmark {
int res = 0;
for (int i = 0; i < n; i++) {
digest::SHA256 hasher;
hasher.feed("abcd", 4);
hasher.feed(str_);
unsigned char buf[32];
hasher.extract(buf);
res += buf[0];
@ -105,10 +119,12 @@ class BenchSha256 : public td::Benchmark {
td::do_not_optimize_away(res);
}
};
class BenchSha256Reuse : public td::Benchmark {
class BenchSha256Reuse : public BenchSha {
public:
std::string get_description() const override {
return "SHA256 reuse";
using BenchSha::BenchSha;
std::string get_name() const override {
return "SHA256 reuse (used in DataCell)";
}
void run(int n) override {
@ -116,7 +132,7 @@ class BenchSha256Reuse : public td::Benchmark {
digest::SHA256 hasher;
for (int i = 0; i < n; i++) {
hasher.reset();
hasher.feed("abcd", 4);
hasher.feed(str_);
unsigned char buf[32];
hasher.extract(buf);
res += buf[0];
@ -124,18 +140,28 @@ class BenchSha256Reuse : public td::Benchmark {
td::do_not_optimize_away(res);
}
};
class BenchSha256Low : public td::Benchmark {
class BenchSha256Low : public BenchSha {
public:
std::string get_description() const override {
using BenchSha::BenchSha;
std::string get_name() const override {
return "SHA256 low level";
}
// Use the old method to check for performance degradation
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996) // Disable deprecated warning for MSVC
#endif
void run(int n) override {
int res = 0;
SHA256_CTX ctx;
for (int i = 0; i < n; i++) {
SHA256_Init(&ctx);
SHA256_Update(&ctx, "abcd", 4);
SHA256_Update(&ctx, str_.data(), str_.size());
unsigned char buf[32];
SHA256_Final(buf, &ctx);
res += buf[0];
@ -143,9 +169,17 @@ class BenchSha256Low : public td::Benchmark {
td::do_not_optimize_away(res);
}
};
class BenchSha256Tdlib : public td::Benchmark {
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif
class BenchSha256Tdlib : public BenchSha {
public:
std::string get_description() const override {
using BenchSha::BenchSha;
std::string get_name() const override {
return "SHA256 TDLib";
}
@ -155,7 +189,7 @@ class BenchSha256Tdlib : public td::Benchmark {
for (int i = 0; i < n; i++) {
td::init_thread_local<td::Sha256State>(ctx);
ctx->init();
ctx->feed("abcd");
ctx->feed(str_);
unsigned char buf[32];
ctx->extract(td::MutableSlice(buf, 32), false);
res += buf[0];
@ -180,7 +214,7 @@ void bench_threaded(F &&f) {
void run(int n) override {
std::atomic<int> task_i{0};
int chunk_size = 1024;
size_t num_threads = 1;
int num_threads = 16;
n *= num_threads;
std::vector<td::thread> threads;
for (int i = 0; i < num_threads; i++) {
@ -204,16 +238,20 @@ void bench_threaded(F &&f) {
bench(Threaded(std::forward<F>(f)));
}
TEST(Cell, sha_benchmark) {
bench(BenchSha256Tdlib());
bench(BenchSha256Low());
bench(BenchSha256Reuse());
bench(BenchSha256());
for (size_t n : {4, 64, 128}) {
bench(BenchSha256Tdlib(n));
bench(BenchSha256Low(n));
bench(BenchSha256Reuse(n));
bench(BenchSha256(n));
}
}
TEST(Cell, sha_benchmark_threaded) {
bench_threaded([] { return BenchSha256Tdlib(); });
bench_threaded([]() { return BenchSha256Low(); });
bench_threaded([]() { return BenchSha256Reuse(); });
bench_threaded([]() { return BenchSha256(); });
for (size_t n : {4, 64, 128}) {
bench_threaded([n] { return BenchSha256Tdlib(n); });
bench_threaded([n]() { return BenchSha256Low(n); });
bench_threaded([n]() { return BenchSha256Reuse(n); });
bench_threaded([n]() { return BenchSha256(n); });
}
}
std::string serialize_boc(Ref<Cell> cell, int mode = 31) {
@ -814,12 +852,11 @@ TEST(TonDb, BocMultipleRoots) {
};
TEST(TonDb, InMemoryDynamicBocSimple) {
auto counter = [] {
return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum();
};
auto counter = [] { return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum(); };
auto before = counter();
SCOPE_EXIT {
LOG_CHECK(before == counter()) << before << " vs " << counter();;
LOG_CHECK(before == counter()) << before << " vs " << counter();
;
};
td::Random::Xorshift128plus rnd{123};
auto kv = std::make_shared<td::MemoryKeyValue>();
@ -854,12 +891,11 @@ TEST(TonDb, InMemoryDynamicBocSimple) {
}
void test_dynamic_boc(std::optional<DynamicBagOfCellsDb::CreateInMemoryOptions> o_in_memory) {
auto counter = [] {
return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum();
};
auto counter = [] { return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum(); };
auto before = counter();
SCOPE_EXIT {
LOG_CHECK((o_in_memory && o_in_memory->use_arena) || before == counter()) << before << " vs " << counter();;
LOG_CHECK((o_in_memory && o_in_memory->use_arena) || before == counter()) << before << " vs " << counter();
;
};
td::Random::Xorshift128plus rnd{123};
std::string old_root_hash;
@ -870,7 +906,7 @@ void test_dynamic_boc(std::optional<DynamicBagOfCellsDb::CreateInMemoryOptions>
auto res = DynamicBagOfCellsDb::create_in_memory(kv.get(), *o_in_memory);
auto roots_n = old_root_hash.empty() ? 0 : 1;
ASSERT_EQ(roots_n, res->get_stats().ok().roots_total_count);
return std::move(res);
return res;
}
return DynamicBagOfCellsDb::create();
};
@ -945,19 +981,17 @@ void test_dynamic_boc2(std::optional<DynamicBagOfCellsDb::CreateInMemoryOptions>
auto stats = res->get_stats().move_as_ok();
ASSERT_EQ(root_n, stats.roots_total_count);
VLOG(boc) << "reset roots_n=" << stats.roots_total_count << " cells_n=" << stats.cells_total_count;
return std::move(res);
return res;
}
return DynamicBagOfCellsDb::create();
};
auto dboc = create_dboc(0);
dboc->set_loader(std::make_unique<CellLoader>(kv));
auto counter = [] {
return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum();
};
auto counter = [] { return td::NamedThreadSafeCounter::get_default().get_counter("DataCell").sum(); };
auto before = counter();
SCOPE_EXIT {
LOG_CHECK((o_in_memory && o_in_memory->use_arena) || before == counter()) << before << " vs " << counter();;
LOG_CHECK((o_in_memory && o_in_memory->use_arena) || before == counter()) << before << " vs " << counter();
};
std::vector<Ref<Cell>> roots(max_roots);
@ -2257,7 +2291,6 @@ TEST(Ref, AtomicRef) {
int threads_n = 10;
std::vector<Node> nodes(threads_n);
std::vector<td::thread> threads(threads_n);
int thread_id = 0;
for (auto &thread : threads) {
thread = td::thread([&] {
for (int i = 0; i < 1000000; i++) {
@ -2272,7 +2305,6 @@ TEST(Ref, AtomicRef) {
}
}
});
thread_id++;
}
for (auto &thread : threads) {
thread.join();

View file

@ -1316,7 +1316,7 @@ void CppTypeCode::clear_context() {
std::string CppTypeCode::new_tmp_var() {
char buffer[16];
while (true) {
sprintf(buffer, "t%d", ++tmp_ints);
snprintf(buffer, sizeof(buffer), "t%d", ++tmp_ints);
if (tmp_cpp_ids.is_good_ident(buffer) && local_cpp_ids.is_good_ident(buffer)) {
break;
}

View file

@ -420,7 +420,7 @@ void AdmissibilityInfo::operator|=(const AdmissibilityInfo& other) {
std::size_t i, j, n = info.size(), n1 = other.info.size();
assert(n1 && !(n1 & (n1 - 1)));
for (i = j = 0; i < n; i++) {
info[i] = info[i] | other.info[j];
info[i] = info[i] || other.info[j];
j = (j + 1) & (n1 - 1);
}
}
@ -2511,7 +2511,7 @@ void define_builtins() {
Bits_type = define_builtin_type("bits", "#", false, 1023, 0, true, 0);
for (int i = 1; i <= 257; i++) {
char buff[8];
sprintf(buff, "uint%d", i);
snprintf(buff, sizeof(buff), "uint%d", i);
define_builtin_type(buff + 1, "", false, i, i, true, -1);
if (i < 257) {
define_builtin_type(buff, "", false, i, i, true, 1);
@ -2519,7 +2519,7 @@ void define_builtins() {
}
for (int i = 1; i <= 1023; i++) {
char buff[12];
sprintf(buff, "bits%d", i);
snprintf(buff, sizeof(buff), "bits%d", i);
define_builtin_type(buff, "", false, i, i, true, 0);
}
Eq_type = define_builtin_type("=", "##", false, 0, 0, true);

View file

@ -8,7 +8,6 @@
#include <typeindex>
#include <typeinfo>
#include <optional>
#include "td/utils/port/platform.h"
#ifdef __has_include
#if __has_include(<cxxabi.h>)

View file

@ -81,7 +81,7 @@ Result<bool> StreamToFileActor::do_loop() {
sync_at_ = {};
}
bool need_update = sync_state_.set_synced_size(synced_size_) | sync_state_.set_flushed_size(flushed_size_);
bool need_update = int(sync_state_.set_synced_size(synced_size_)) | int(sync_state_.set_flushed_size(flushed_size_));
if (need_update && callback_) {
callback_->on_sync_state_changed();
}

View file

@ -28,7 +28,7 @@ namespace tl {
std::string TL_writer::int_to_string(int x) {
char buf[15];
std::sprintf(buf, "%d", x);
std::snprintf(buf, sizeof(buf), "%d", x);
return buf;
}

View file

@ -32,12 +32,7 @@ class HazardPointers {
explicit HazardPointers(size_t threads_n) : threads_(threads_n) {
for (auto &data : threads_) {
for (auto &ptr : data.hazard_) {
// workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64658
#if TD_GCC && GCC_VERSION <= 40902
ptr = nullptr;
#else
std::atomic_init(&ptr, static_cast<T *>(nullptr));
#endif
}
}
}

View file

@ -1768,7 +1768,7 @@ class RunEmulator : public TonlibQueryActor {
void get_block_id(td::Promise<FullBlockId>&& promise) {
auto shard_id = ton::shard_prefix(request_.address.addr, 60);
auto query = ton::lite_api::liteServer_lookupBlock(0b111111010, ton::create_tl_lite_block_id_simple({request_.address.workchain, shard_id, 0}), request_.lt, 0);
client_.send_query(std::move(query), promise.wrap([self = this, shard_id](td::Result<tonlib_api::object_ptr<ton::lite_api::liteServer_blockHeader>> header_r) -> td::Result<FullBlockId> {
client_.send_query(std::move(query), promise.wrap([shard_id](td::Result<tonlib_api::object_ptr<ton::lite_api::liteServer_blockHeader>> header_r) -> td::Result<FullBlockId> {
TRY_RESULT(header, std::move(header_r));
ton::BlockIdExt block_id = ton::create_block_id(header->id_);
@ -1817,7 +1817,7 @@ class RunEmulator : public TonlibQueryActor {
void get_mc_state_root(td::Promise<td::Ref<vm::Cell>>&& promise) {
TRY_RESULT_PROMISE(promise, lite_block, to_lite_api(*to_tonlib_api(block_id_.mc)));
auto block = ton::create_block_id(lite_block);
client_.send_query(ton::lite_api::liteServer_getConfigAll(0b11'11111111, std::move(lite_block)), promise.wrap([self = this, block](auto r_config) -> td::Result<td::Ref<vm::Cell>> {
client_.send_query(ton::lite_api::liteServer_getConfigAll(0b11'11111111, std::move(lite_block)), promise.wrap([block](auto r_config) -> td::Result<td::Ref<vm::Cell>> {
TRY_RESULT(state, block::check_extract_state_proof(block, r_config->state_proof_.as_slice(), r_config->config_proof_.as_slice()));
@ -1842,7 +1842,7 @@ class RunEmulator : public TonlibQueryActor {
constexpr int req_count = 256;
auto query = ton::lite_api::liteServer_listBlockTransactions(std::move(lite_block), mode, req_count, std::move(after), false, true);
client_.send_query(std::move(query), [self = this, mode, lt, root_hash = block_id_.id.root_hash, req_count](lite_api_ptr<ton::lite_api::liteServer_blockTransactions>&& bTxes) {
client_.send_query(std::move(query), [self = this, mode, lt, root_hash = block_id_.id.root_hash](lite_api_ptr<ton::lite_api::liteServer_blockTransactions>&& bTxes) {
if (!bTxes) {
self->check(td::Status::Error("liteServer.blockTransactions is null"));
return;
@ -5867,7 +5867,7 @@ td::Status TonlibClient::do_request(const tonlib_api::blocks_getTransactions& re
std::move(after),
reverse_mode,
check_proof),
promise.wrap([check_proof, reverse_mode, root_hash, req_count = request.count_, start_addr, start_lt, mode = request.mode_]
promise.wrap([root_hash, req_count = request.count_, start_addr, start_lt, mode = request.mode_]
(lite_api_ptr<ton::lite_api::liteServer_blockTransactions>&& bTxes) -> td::Result<object_ptr<tonlib_api::blocks_transactions>> {
TRY_STATUS(check_block_transactions_proof(bTxes, mode, start_lt, start_addr, root_hash, req_count));

View file

@ -42,7 +42,7 @@ void ValidatorSessionImpl::process_blocks(std::vector<catchain::CatChainBlock *>
on_new_round(real_state_->cur_round_seqno());
}
td::uint32 cnt = 0;
[[maybe_unused]] td::uint32 cnt = 0;
auto ts = description().get_ts();
auto att = description().get_attempt_seqno(ts);
std::vector<tl_object_ptr<ton_api::validatorSession_round_Message>> msgs;

View file

@ -32,11 +32,11 @@ std::string PackageId::path() const {
return "/files/packages/";
} else if (key) {
char s[24];
sprintf(s, "key%03d", id / 1000000);
snprintf(s, sizeof(s), "key%03d", id / 1000000);
return PSTRING() << "/archive/packages/" << s << "/";
} else {
char s[20];
sprintf(s, "arch%04d", id / 100000);
snprintf(s, sizeof(s), "arch%04d", id / 100000);
return PSTRING() << "/archive/packages/" << s << "/";
}
}
@ -46,11 +46,11 @@ std::string PackageId::name() const {
return PSTRING() << "temp.archive." << id;
} else if (key) {
char s[20];
sprintf(s, "%06d", id);
snprintf(s, sizeof(s), "%06d", id);
return PSTRING() << "key.archive." << s;
} else {
char s[10];
sprintf(s, "%05d", id);
snprintf(s, sizeof(s), "%05d", id);
return PSTRING() << "archive." << s;
}
}
@ -342,19 +342,19 @@ void ArchiveManager::add_zero_state(BlockIdExt block_id, td::BufferSlice data, t
void ArchiveManager::add_persistent_state(BlockIdExt block_id, BlockIdExt masterchain_block_id, td::BufferSlice data,
td::Promise<td::Unit> promise) {
auto create_writer = [&](std::string path, td::Promise<std::string> P) {
td::actor::create_actor<db::WriteFile>("writefile", db_root_ + "/archive/tmp/",
std::move(path), std::move(data), std::move(P))
td::actor::create_actor<db::WriteFile>("writefile", db_root_ + "/archive/tmp/", std::move(path), std::move(data),
std::move(P))
.release();
};
add_persistent_state_impl(block_id, masterchain_block_id, std::move(promise), std::move(create_writer));
}
void ArchiveManager::add_persistent_state_gen(BlockIdExt block_id, BlockIdExt masterchain_block_id,
std::function<td::Status(td::FileFd&)> write_state,
std::function<td::Status(td::FileFd &)> write_state,
td::Promise<td::Unit> promise) {
auto create_writer = [&](std::string path, td::Promise<std::string> P) {
td::actor::create_actor<db::WriteFile>("writefile", db_root_ + "/archive/tmp/",
std::move(path), std::move(write_state), std::move(P))
td::actor::create_actor<db::WriteFile>("writefile", db_root_ + "/archive/tmp/", std::move(path),
std::move(write_state), std::move(P))
.release();
};
add_persistent_state_impl(block_id, masterchain_block_id, std::move(promise), std::move(create_writer));
@ -624,8 +624,8 @@ void ArchiveManager::load_package(PackageId id) {
}
}
desc.file =
td::actor::create_actor<ArchiveSlice>("slice", id.id, id.key, id.temp, false, db_root_, archive_lru_.get(), statistics_);
desc.file = td::actor::create_actor<ArchiveSlice>("slice", id.id, id.key, id.temp, false, db_root_,
archive_lru_.get(), statistics_);
m.emplace(id, std::move(desc));
update_permanent_slices();
@ -659,8 +659,8 @@ const ArchiveManager::FileDescription *ArchiveManager::add_file_desc(ShardIdFull
FileDescription new_desc{id, false};
td::mkdir(db_root_ + id.path()).ensure();
std::string prefix = PSTRING() << db_root_ << id.path() << id.name();
new_desc.file =
td::actor::create_actor<ArchiveSlice>("slice", id.id, id.key, id.temp, false, db_root_, archive_lru_.get(), statistics_);
new_desc.file = td::actor::create_actor<ArchiveSlice>("slice", id.id, id.key, id.temp, false, db_root_,
archive_lru_.get(), statistics_);
const FileDescription &desc = f.emplace(id, std::move(new_desc));
if (!id.temp) {
update_desc(f, desc, shard, seqno, ts, lt);
@ -940,7 +940,8 @@ void ArchiveManager::start_up() {
void ArchiveManager::alarm() {
alarm_timestamp() = td::Timestamp::in(60.0);
auto stats = statistics_.to_string_and_reset();
auto to_file_r = td::FileFd::open(db_root_ + "/db_stats.txt", td::FileFd::Truncate | td::FileFd::Create | td::FileFd::Write, 0644);
auto to_file_r =
td::FileFd::open(db_root_ + "/db_stats.txt", td::FileFd::Truncate | td::FileFd::Create | td::FileFd::Write, 0644);
if (to_file_r.is_error()) {
LOG(ERROR) << "Failed to open db_stats.txt: " << to_file_r.move_as_error();
return;
@ -1034,7 +1035,7 @@ void ArchiveManager::persistent_state_gc(std::pair<BlockSeqno, FileHash> last) {
}
if (res != 0) {
delay_action([key, SelfId = actor_id(
this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
td::Timestamp::in(1.0));
return;
}
@ -1051,7 +1052,7 @@ void ArchiveManager::persistent_state_gc(std::pair<BlockSeqno, FileHash> last) {
}
if (!allow_delete) {
delay_action([key, SelfId = actor_id(
this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
td::Timestamp::in(1.0));
return;
}
@ -1082,9 +1083,9 @@ void ArchiveManager::got_gc_masterchain_handle(ConstBlockHandle handle, std::pai
td::unlink(db_root_ + "/archive/states/" + F.filename_short()).ignore();
perm_states_.erase(it);
}
delay_action([key, SelfId = actor_id(
this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
td::Timestamp::in(1.0));
delay_action(
[key, SelfId = actor_id(this)]() { td::actor::send_closure(SelfId, &ArchiveManager::persistent_state_gc, key); },
td::Timestamp::in(1.0));
}
PackageId ArchiveManager::get_temp_package_id() const {

View file

@ -79,14 +79,14 @@ std::string Block::filename() const {
std::string Block::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "block_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string BlockShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "block_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_" << hash().to_hex();
}
@ -116,14 +116,14 @@ std::string PersistentState::filename() const {
std::string PersistentState::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "state_" << masterchain_block_id.seqno() << "_" << block_id.id.workchain << "_" << s << "_"
<< hash().to_hex();
}
std::string PersistentStateShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(shard_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(shard_id.shard));
return PSTRING() << "state_" << masterchain_seqno << "_" << shard_id.workchain << "_" << s << "_" << hash().to_hex();
}
@ -137,14 +137,14 @@ std::string Proof::filename() const {
std::string Proof::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "proof_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string ProofShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "proof_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_" << hash().to_hex();
}
@ -158,14 +158,14 @@ std::string ProofLink::filename() const {
std::string ProofLink::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "prooflink_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string ProofLinkShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "prooflink_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_" << hash().to_hex();
}
@ -179,14 +179,14 @@ std::string Signatures::filename() const {
std::string Signatures::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "signatures_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string SignaturesShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "signatures_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_"
<< hash().to_hex();
}
@ -202,14 +202,14 @@ std::string Candidate::filename() const {
std::string Candidate::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "candidate_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string CandidateShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "candidate_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_" << hash().to_hex();
}
@ -223,14 +223,14 @@ std::string CandidateRef::filename() const {
std::string CandidateRef::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "candidateref_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string CandidateRefShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "candidateref_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_"
<< hash().to_hex();
}
@ -245,14 +245,14 @@ std::string BlockInfo::filename() const {
std::string BlockInfo::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.id.shard));
return PSTRING() << "info_" << block_id.id.workchain << "_" << s << "_" << block_id.id.seqno << "_"
<< hash().to_hex();
}
std::string BlockInfoShort::filename_short() const {
char s[33];
sprintf(s, "%llx", static_cast<long long>(block_id.shard));
snprintf(s, sizeof(s), "%llx", static_cast<long long>(block_id.shard));
return PSTRING() << "info_" << block_id.workchain << "_" << s << "_" << block_id.seqno << "_" << hash().to_hex();
}

View file

@ -4775,11 +4775,11 @@ bool Collator::check_block_overload() {
}
char buffer[17];
if (history_weight(overload_history_) >= 0) {
sprintf(buffer, "%016llx", (unsigned long long)overload_history_);
snprintf(buffer, sizeof(buffer), "%016llx", (unsigned long long)overload_history_);
LOG(INFO) << "want_split set because of overload history " << buffer;
want_split_ = true;
} else if (history_weight(underload_history_) >= 0) {
sprintf(buffer, "%016llx", (unsigned long long)underload_history_);
snprintf(buffer, sizeof(buffer), "%016llx", (unsigned long long)underload_history_);
LOG(INFO) << "want_merge set because of underload history " << buffer;
want_merge_ = true;
}

View file

@ -1853,7 +1853,7 @@ void LiteQuery::perform_getConfigParams(BlockIdExt blkid, int mode, std::vector<
request_mc_block_data_state(blkid);
} else {
// get configuration from previous key block
load_prevKeyBlock(blkid, [this, blkid, mode, param_list = std::move(param_list)](
load_prevKeyBlock(blkid, [this, mode, param_list = std::move(param_list)](
td::Result<std::pair<BlockIdExt, Ref<BlockQ>>> res) mutable {
if (res.is_error()) {
this->abort_query(res.move_as_error());
@ -2050,7 +2050,7 @@ void LiteQuery::perform_lookupBlockWithProof(BlockId blkid, BlockIdExt mc_blkid,
ton::AccountIdPrefixFull pfx{blkid.workchain, blkid.shard};
auto P = td::PromiseCreator::lambda(
[Self = actor_id(this), mc_blkid, manager = manager_, mode, pfx](td::Result<ConstBlockHandle> res) {
[Self = actor_id(this), mc_blkid, manager = manager_, pfx](td::Result<ConstBlockHandle> res) {
if (res.is_error()) {
td::actor::send_closure(Self, &LiteQuery::abort_query, res.move_as_error());
return;
@ -2066,7 +2066,7 @@ void LiteQuery::perform_lookupBlockWithProof(BlockId blkid, BlockIdExt mc_blkid,
}
LOG(DEBUG) << "requesting data for block " << handle->id().to_str();
td::actor::send_closure_later(manager, &ValidatorManager::get_block_data_from_db, handle,
[Self, mc_ref_blkid = handle->masterchain_ref_block(), mc_blkid, pfx, mode](td::Result<Ref<BlockData>> res) {
[Self, mc_ref_blkid = handle->masterchain_ref_block(), pfx](td::Result<Ref<BlockData>> res) {
if (res.is_error()) {
td::actor::send_closure(Self, &LiteQuery::abort_query, res.move_as_error());
} else {