mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
fix compilation errors of different platforms and move to c++20
This commit is contained in:
parent
0780a6a1b5
commit
1c66852842
10 changed files with 67 additions and 25 deletions
|
|
@ -62,6 +62,7 @@
|
|||
#include "vm/dict.h"
|
||||
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
|
||||
namespace vm {
|
||||
|
||||
|
|
@ -2010,7 +2011,7 @@ TEST(TonDb, CompactArrayOld) {
|
|||
SCOPE_EXIT {
|
||||
ton_db->commit_transaction(std::move(txn));
|
||||
};
|
||||
auto smart = txn->begin_smartcontract("");
|
||||
auto smart = txn->begin_smartcontract();
|
||||
SCOPE_EXIT {
|
||||
txn->commit_smartcontract(std::move(smart));
|
||||
};
|
||||
|
|
@ -2037,7 +2038,7 @@ TEST(TonDb, CompactArrayOld) {
|
|||
SCOPE_EXIT {
|
||||
ton_db->commit_transaction(std::move(txn));
|
||||
};
|
||||
auto smart = txn->begin_smartcontract("");
|
||||
auto smart = txn->begin_smartcontract();
|
||||
//smart->validate_meta();
|
||||
SCOPE_EXIT {
|
||||
txn->commit_smartcontract(std::move(smart));
|
||||
|
|
@ -2058,7 +2059,7 @@ TEST(TonDb, CompactArrayOld) {
|
|||
SCOPE_EXIT {
|
||||
ton_db->abort_transaction(std::move(txn));
|
||||
};
|
||||
auto smart = txn->begin_smartcontract("");
|
||||
auto smart = txn->begin_smartcontract();
|
||||
SCOPE_EXIT {
|
||||
txn->abort_smartcontract(std::move(smart));
|
||||
};
|
||||
|
|
@ -2219,7 +2220,7 @@ TEST(TonDb, CellStat) {
|
|||
ASSERT_EQ(stat.cells, new_stat.get_stat().cells);
|
||||
ASSERT_EQ(stat.bits, new_stat.get_stat().bits);
|
||||
|
||||
CHECK(usage_tree.unique());
|
||||
CHECK(usage_tree.use_count() == 1);
|
||||
usage_tree.reset();
|
||||
td::Ref<vm::Cell> C, BC, C_proof;
|
||||
std::shared_ptr<vm::CellUsageTree> usage_tree_B;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ struct CellHash {
|
|||
|
||||
inline size_t cell_hash_slice_hash(td::Slice hash) {
|
||||
// use offset 8, because in db keys are grouped by first bytes.
|
||||
return td::as<size_t>(hash.ubegin() + 8);
|
||||
return td::as<size_t>(hash.substr(8, 8).ubegin());
|
||||
}
|
||||
namespace std {
|
||||
template <>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#include "td/utils/HashMap.h"
|
||||
#include "td/utils/HashSet.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#if TD_PORT_POSIX
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -98,7 +100,7 @@ class ArenaPrunnedCellCreator : public ExtCellCreator {
|
|||
}
|
||||
#else
|
||||
static std::unique_ptr<char, Deleter> alloc() {
|
||||
auto ptr = reinterpret_cast<char *>(malloc(batch_size)));
|
||||
auto ptr = reinterpret_cast<char *>(malloc(batch_size));
|
||||
CHECK(ptr != nullptr);
|
||||
return std::unique_ptr<char, Deleter>(ptr);
|
||||
}
|
||||
|
|
@ -292,7 +294,7 @@ struct CellInfoHashTableDense {
|
|||
}
|
||||
template <class Iterator>
|
||||
void init_from(Iterator begin, Iterator end) {
|
||||
auto size = std::distance(begin, end);
|
||||
auto size = td::narrow_cast<size_t>(std::distance(begin, end));
|
||||
dense_ht_buckets_ = std::max(size_t(1), size_t(size / 8));
|
||||
|
||||
std::vector<size_t> offsets(dense_ht_buckets_ + 2);
|
||||
|
|
@ -438,16 +440,16 @@ class CellStorage {
|
|||
add_stat("ht.size", size);
|
||||
add_stat("ht.load", double(size) / std::max(1.0, double(capacity)));
|
||||
}
|
||||
CHECK(stats.roots_total_count == local_roots_.size());
|
||||
CHECK(td::narrow_cast<size_t>(stats.roots_total_count) == local_roots_.size());
|
||||
return stats;
|
||||
}
|
||||
void apply_stats_diff(DynamicBagOfCellsDb::Stats diff) {
|
||||
auto unique_access = local_access_.lock();
|
||||
stats_.apply_diff(diff);
|
||||
CHECK(stats_.roots_total_count == local_roots_.size());
|
||||
CHECK(td::narrow_cast<size_t>(stats_.roots_total_count) == local_roots_.size());
|
||||
size_t cells_count{0};
|
||||
for_each_bucket(0, [&](size_t bucket_id, auto &bucket) { cells_count += bucket.infos_.size(); });
|
||||
CHECK(stats_.cells_total_count == cells_count);
|
||||
CHECK(td::narrow_cast<size_t>(stats_.cells_total_count) == cells_count);
|
||||
}
|
||||
|
||||
td::Result<Ref<DataCell>> load_cell(const CellHash &hash) const {
|
||||
|
|
@ -541,8 +543,8 @@ class CellStorage {
|
|||
DefaultPrunnedCellCreator default_pc_creator;
|
||||
|
||||
auto timer = td::Timer();
|
||||
size_t cell_count{0};
|
||||
size_t desc_count{0};
|
||||
td::int64 cell_count{0};
|
||||
td::int64 desc_count{0};
|
||||
if (options.use_less_memory_during_creation) {
|
||||
auto [new_cell_count, new_desc_count] = parallel_scan_cells(
|
||||
default_pc_creator, options.use_arena,
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ class TonDbTransactionImpl;
|
|||
using TonDbTransaction = std::unique_ptr<TonDbTransactionImpl>;
|
||||
class TonDbTransactionImpl {
|
||||
public:
|
||||
SmartContractDb begin_smartcontract(td::Slice hash = {});
|
||||
|
||||
SmartContractDb begin_smartcontract(td::Slice hash = std::string(32, '\0'));
|
||||
|
||||
void commit_smartcontract(SmartContractDb txn);
|
||||
void commit_smartcontract(SmartContractDiff txn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue