mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-13 11:42:18 +00:00
Improve queue cleanup (after merge)
This commit is contained in:
parent
28699654fb
commit
0fb781b4c3
1 changed files with 29 additions and 4 deletions
|
@ -2323,8 +2323,22 @@ bool Collator::out_msg_queue_cleanup() {
|
|||
<< nb.blk_.to_str());
|
||||
}
|
||||
}
|
||||
auto queue_root = out_msg_queue_->get_root_cell();
|
||||
if (queue_root.is_null()) {
|
||||
LOG(DEBUG) << "out_msg_queue is empty";
|
||||
return true;
|
||||
}
|
||||
// Unwrap UsageCell: don't build proof for visiting output queue (unless something is deleted)
|
||||
auto r_cell = queue_root->load_cell();
|
||||
if (r_cell.is_error()) {
|
||||
return fatal_error(r_cell.move_as_error());
|
||||
}
|
||||
auto pure_out_msg_queue =
|
||||
std::make_unique<vm::AugmentedDictionary>(r_cell.move_as_ok().data_cell, 352, block::tlb::aug_OutMsgQueue);
|
||||
td::uint32 deleted = 0;
|
||||
auto res = out_msg_queue_->filter([&](vm::CellSlice& cs, td::ConstBitPtr key, int n) -> int {
|
||||
bool fail = false;
|
||||
pure_out_msg_queue->check_for_each([&](Ref<vm::CellSlice> value, td::ConstBitPtr key, int n) -> bool {
|
||||
vm::CellSlice& cs = value.write();
|
||||
assert(n == 352);
|
||||
block::EnqueuedMsgDescr enq_msg_descr;
|
||||
unsigned long long created_lt;
|
||||
|
@ -2333,7 +2347,8 @@ bool Collator::out_msg_queue_cleanup() {
|
|||
&& enq_msg_descr.check_key(key) // check key
|
||||
&& enq_msg_descr.lt_ == created_lt)) {
|
||||
LOG(ERROR) << "cannot unpack EnqueuedMsg with key " << key.to_hex(n);
|
||||
return -1;
|
||||
fail = true;
|
||||
return false;
|
||||
}
|
||||
LOG(DEBUG) << "scanning outbound message with (lt,hash)=(" << enq_msg_descr.lt_ << ","
|
||||
<< enq_msg_descr.hash_.to_hex() << ") enqueued_lt=" << enq_msg_descr.enqueued_lt_;
|
||||
|
@ -2354,10 +2369,20 @@ bool Collator::out_msg_queue_cleanup() {
|
|||
--out_msg_queue_size_;
|
||||
LOG(DEBUG) << "outbound message with (lt,hash)=(" << enq_msg_descr.lt_ << "," << enq_msg_descr.hash_.to_hex()
|
||||
<< ") enqueued_lt=" << enq_msg_descr.enqueued_lt_ << " has been already delivered, dequeueing";
|
||||
// Get value from out_msg_queue_ instead of pure_out_msg_queue (for proof)
|
||||
auto value2 = out_msg_queue_->lookup_delete_with_extra(key, n);
|
||||
CHECK(value2.not_null());
|
||||
vm::CellSlice& cs2 = value2.write();
|
||||
CHECK(cs2.fetch_ulong_bool(64, created_lt) // augmentation
|
||||
&& enq_msg_descr.unpack(cs2) // unpack EnqueuedMsg
|
||||
&& enq_msg_descr.check_key(key) // check key
|
||||
&& enq_msg_descr.lt_ == created_lt);
|
||||
|
||||
if (!dequeue_message(std::move(enq_msg_descr.msg_env_), deliver_lt)) {
|
||||
fatal_error(PSTRING() << "cannot dequeue outbound message with (lt,hash)=(" << enq_msg_descr.lt_ << ","
|
||||
<< enq_msg_descr.hash_.to_hex() << ") by inserting a msg_export_deq record");
|
||||
return -1;
|
||||
fail = true;
|
||||
return false;
|
||||
}
|
||||
register_out_msg_queue_op();
|
||||
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
||||
|
@ -2368,7 +2393,7 @@ bool Collator::out_msg_queue_cleanup() {
|
|||
});
|
||||
LOG(WARNING) << "deleted " << deleted << " messages from out_msg_queue after merge, remaining queue size is "
|
||||
<< out_msg_queue_size_;
|
||||
if (res < 0) {
|
||||
if (fail) {
|
||||
return fatal_error("error scanning/updating OutMsgQueue");
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue