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

remove redundant comments

This commit is contained in:
trinitil 2025-01-28 19:19:32 +04:00
parent 383a0c574a
commit 4f9359457f
2 changed files with 2 additions and 30 deletions

View file

@ -4,15 +4,11 @@
#include "td/actor/actor.h"
#include "td/utils/logging.h"
// TON / CellDb includes (проверьте свои пути)
#include "validator/db/celldb.hpp"
// ====================== GLOBAL STORAGE FOR ACTORS =====================
// Чтобы актор LoadCellActor не уничтожился, когда локальная переменная исчезнет.
static td::actor::ActorOwn<ton::validator::CellDb> g_cell_db_actor;
static td::actor::ActorOwn<td::actor::Actor> g_loader_actor; // LoadCellActor хранить здесь
// ============ 1) Актор, печатающий все ключи (если нужно) ============
class PrintHashesActor : public td::actor::Actor {
public:
explicit PrintHashesActor(td::actor::ActorId<ton::validator::CellDb> cell_db)
@ -21,14 +17,13 @@ class PrintHashesActor : public td::actor::Actor {
void start_up() override {
LOG(INFO) << "PrintHashesActor: calling CellDb::print_all_hashes()";
td::actor::send_closure(cell_db_, &ton::validator::CellDb::print_all_hashes);
stop(); // завершить работу
stop();
}
private:
td::actor::ActorId<ton::validator::CellDb> cell_db_;
};
// ============ Helper: Парсим 64-hex-символов в ton::RootHash ============
ton::RootHash parse_hex_hash(const std::string &hex_str) {
if (hex_str.size() != 64) {
throw std::runtime_error("Root hash must be 64 hex chars");
@ -46,18 +41,12 @@ ton::RootHash parse_hex_hash(const std::string &hex_str) {
return root;
}
// ============ MAIN ============
int main(int argc, char* argv[]) {
// Аргументы: path/to/celldb [64-hex-hash]
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " /path/to/celldb [64-hex-hash]\n";
return 1;
}
// Если нужно, включите логи
// td::Logger::instance().set_verbosity_level(3);
std::string celldb_path = argv[1];
bool load_hash = (argc > 2);
ton::RootHash cell_hash;
@ -66,19 +55,14 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "We will load hash = " << cell_hash.to_hex();
}
// Создаём Scheduler
td::actor::Scheduler scheduler({1}); // 1-thread
// Запускаем инициализацию в run_in_context, чтобы всё делалось внутри Actor среды
scheduler.run_in_context([&] {
// 1) Строим opts (ValidatorManagerOptions)
auto opts = ton::validator::ValidatorManagerOptions::create(
// 2 аргумента, если у вас 2-param create
ton::BlockIdExt{ton::masterchainId, ton::shardIdAll, 0, ton::RootHash::zero(), ton::FileHash::zero()},
ton::BlockIdExt{ton::masterchainId, ton::shardIdAll, 0, ton::RootHash::zero(), ton::FileHash::zero()}
);
// 2) Создаём CellDb
g_cell_db_actor = td::actor::create_actor<ton::validator::CellDb>(
"celldb_actor",
td::actor::ActorId<ton::validator::RootDb>(), // пустой
@ -86,16 +70,12 @@ int main(int argc, char* argv[]) {
opts
);
// Если захотите печатать все ключи:
auto printer_actor = td::actor::create_actor<PrintHashesActor>("printer", g_cell_db_actor.get());
});
// Главный цикл
while (scheduler.run(0.1)) {
// do nothing
while (scheduler.run(1)) {
}
// Останавливаем планировщик
scheduler.stop();
LOG(INFO) << "Done. Exiting.";

View file

@ -265,31 +265,24 @@ void CellDbIn::get_cell_db_reader(td::Promise<std::shared_ptr<vm::CellDbReader>>
promise.set_result(boc_->get_cell_db_reader());
}
// In celldb.cpp (somewhere after CellDbIn is declared and defined)
void CellDbIn::print_all_hashes() {
LOG(INFO) << "Enumerating keys in CellDb...";
// Create a snapshot of RocksDB so we can iterate it
auto snapshot = cell_db_->snapshot();
// snapshot->for_each(...) calls our lambda for each (key, value) pair in the DB
auto status = snapshot->for_each([&](td::Slice raw_key, td::Slice raw_value) -> td::Status {
// Special check: in official CellDb code, the "empty" key is "desczero"
if (raw_key == "desczero") {
LOG(INFO) << "Found empty key: desczero";
return td::Status::OK();
}
// Check if the key starts with "desc"
if (raw_key.size() >= 4 && std::memcmp(raw_key.data(), "desc", 4) == 0) {
if (raw_key.size() == 4 + 44) {
// Slice out the 32-byte hash
KeyHash khash;
LOG(INFO) << "raw_key: " << raw_key.substr(4, 44);
auto hash_part = td::base64_decode(raw_key.substr(4, 44)).move_as_ok();
std::memcpy(khash.as_slice().begin(), hash_part.data(), 32);
auto block = get_block(khash).move_as_ok();
// LOG(INFO) << raw_key.str();
LOG(INFO) << "Found key: hash=" << block.root_hash << " d: " << block.root_hash.to_hex();
LOG(INFO) << "Block_id = " << block.block_id.to_str();
@ -705,7 +698,6 @@ void CellDb::get_block_id(CellDbIn::KeyHash key_hash, td::Promise<BlockIdExt> pr
}
void CellDb::print_all_hashes() {
// The underlying RocksDB tasks happen in the CellDbIn actor, so we forward:
td::actor::send_closure(cell_db_, &CellDbIn::print_all_hashes);
}