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

Limit collated data size in collator

This commit is contained in:
SpyCheese 2023-07-12 13:29:59 +03:00
parent d5a56b7c2b
commit 21ce145af2
9 changed files with 116 additions and 17 deletions

View file

@ -1214,4 +1214,35 @@ bool VmStorageStat::add_storage(const CellSlice& cs) {
return true;
}
static td::uint64 estimate_prunned_size() {
return 41;
}
static td::uint64 estimate_serialized_size(const Ref<DataCell>& cell) {
return cell->get_serialized_size() + cell->size_refs() * 3 + 3;
}
void ProofStorageStat::add_cell(const Ref<DataCell>& cell) {
auto& status = cells_[cell->get_hash()];
if (status == c_loaded) {
return;
}
if (status == c_prunned) {
proof_size_ -= estimate_prunned_size();
}
status = c_loaded;
proof_size_ += estimate_serialized_size(cell);
for (unsigned i = 0; i < cell->size_refs(); ++i) {
auto& child_status = cells_[cell->get_ref(i)->get_hash()];
if (child_status == c_none) {
child_status = c_prunned;
proof_size_ += estimate_prunned_size();
}
}
}
td::uint64 ProofStorageStat::estimate_proof_size() const {
return proof_size_;
}
} // namespace vm