Skip to content

Commit 98123b2

Browse files
committed
Bugfix in Transaction::compute_state, optimize AccountStorageStat cleanup
1 parent ad123c4 commit 98123b2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

crypto/block/account-storage-stat.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ AccountStorageStat& AccountStorageStat::operator=(AccountStorageStat&& other) {
5555

5656
td::Result<AccountStorageStat::CellInfo> AccountStorageStat::replace_roots(std::vector<Ref<vm::Cell>> new_roots) {
5757
std::erase_if(new_roots, [](const Ref<vm::Cell>& c) { return c.is_null(); });
58+
if (new_roots.empty()) {
59+
roots_.clear();
60+
total_bits_ = total_cells_ = 0;
61+
dict_ = vm::Dictionary{256};
62+
cache_ = {};
63+
return CellInfo{};
64+
}
65+
5866
auto cmp = [](const Ref<vm::Cell>& c1, const Ref<vm::Cell>& c2) { return c1->get_hash() < c2->get_hash(); };
5967
std::sort(new_roots.begin(), new_roots.end(), cmp);
6068
std::sort(roots_.begin(), roots_.end(), cmp);

crypto/block/transaction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,7 @@ bool Transaction::compute_state(const SerializeConfig& cfg) {
33693369
if (compute_phase) {
33703370
stats.add_hint(compute_phase->vm_loaded_cells);
33713371
}
3372-
auto roots = new_storage->prefetch_all_refs();
3372+
auto roots = new_storage_for_stat->prefetch_all_refs();
33733373
storage_stats_updates.insert(storage_stats_updates.end(), roots.begin(), roots.end());
33743374
{
33753375
StorageStatCalculationContext context{true};

0 commit comments

Comments
 (0)