1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-12 19:22:37 +00:00

Fix error processing in load_cell (#1467)

This commit is contained in:
SpyCheese 2025-01-15 07:45:04 +00:00 committed by GitHub
parent 62838571eb
commit 2ebc6d6a3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,8 +100,18 @@ class DynamicBagOfCellsDbImpl : public DynamicBagOfCellsDb, private ExtCellCreat
return get_cell_info_lazy(level_mask, hash, depth).cell; return get_cell_info_lazy(level_mask, hash, depth).cell;
} }
td::Result<Ref<DataCell>> load_cell(td::Slice hash) override { td::Result<Ref<DataCell>> load_cell(td::Slice hash) override {
TRY_RESULT(loaded_cell, get_cell_info_force(hash).cell->load_cell()); auto info = hash_table_.get_if_exists(hash);
return std::move(loaded_cell.data_cell); if (info && info->sync_with_db) {
TRY_RESULT(loaded_cell, info->cell->load_cell());
return std::move(loaded_cell.data_cell);
}
TRY_RESULT(res, loader_->load(hash, true, *this));
if (res.status != CellLoader::LoadResult::Ok) {
return td::Status::Error("cell not found");
}
Ref<DataCell> cell = res.cell();
hash_table_.apply(hash, [&](CellInfo &info) { update_cell_info_loaded(info, hash, std::move(res)); });
return cell;
} }
td::Result<Ref<DataCell>> load_root(td::Slice hash) override { td::Result<Ref<DataCell>> load_root(td::Slice hash) override {
return load_cell(hash); return load_cell(hash);
@ -145,9 +155,6 @@ class DynamicBagOfCellsDbImpl : public DynamicBagOfCellsDb, private ExtCellCreat
promise->set_result(std::move(cell)); promise->set_result(std::move(cell));
}); });
} }
CellInfo &get_cell_info_force(td::Slice hash) {
return hash_table_.apply(hash, [&](CellInfo &info) { update_cell_info_force(info, hash); });
}
CellInfo &get_cell_info_lazy(Cell::LevelMask level_mask, td::Slice hash, td::Slice depth) { CellInfo &get_cell_info_lazy(Cell::LevelMask level_mask, td::Slice hash, td::Slice depth) {
return hash_table_.apply(hash.substr(hash.size() - Cell::hash_bytes), return hash_table_.apply(hash.substr(hash.size() - Cell::hash_bytes),
[&](CellInfo &info) { update_cell_info_lazy(info, level_mask, hash, depth); }); [&](CellInfo &info) { update_cell_info_lazy(info, level_mask, hash, depth); });