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

Rework limiting imported msg queues

This commit is contained in:
SpyCheese 2023-07-20 17:48:52 +03:00
parent e6b77ef71d
commit 869c6fe675
9 changed files with 30 additions and 51 deletions

View file

@ -829,7 +829,6 @@ top_block_descr#d5 proof_for:BlockIdExt signatures:(Maybe ^BlockSignatures)
// COLLATED DATA
//
top_block_descr_set#4ac789f3 collection:(HashmapE 96 ^TopBlockDescr) = TopBlockDescrSet;
neighbor_msg_queue_limits#7e549333 neighbors:(HashmapE 96 int32) = NeighborMsgQueueLimits;
//
// VALIDATOR MISBEHAVIOR COMPLAINTS

View file

@ -199,10 +199,6 @@ bool OutputQueueMerger::load() {
unsigned long long lt = heap[0]->lt;
std::size_t orig_size = msg_list.size();
do {
if (src_remaining_msgs_[heap[0]->source] == 0) {
std::pop_heap(heap.begin(), heap.end(), MsgKeyValue::greater);
continue;
}
while (heap[0]->is_fork()) {
auto other = std::make_unique<MsgKeyValue>();
if (!heap[0]->split(*other)) {
@ -218,17 +214,17 @@ bool OutputQueueMerger::load() {
heap.pop_back();
} while (!heap.empty() && heap[0]->lt <= lt);
std::sort(msg_list.begin() + orig_size, msg_list.end(), MsgKeyValue::less);
size_t j = orig_size;
for (size_t i = orig_size; i < msg_list.size(); ++i) {
td::int32 &remaining = src_remaining_msgs_[msg_list[i]->source];
if (remaining != 0) {
if (remaining > 0) {
if (remaining != -1) {
if (remaining == 0) {
limit_exceeded = true;
} else {
--remaining;
}
msg_list[j++] = std::move(msg_list[i]);
}
msg_list[i]->limit_exceeded = limit_exceeded;
}
msg_list.resize(j);
return msg_list.size() > orig_size;
}

View file

@ -32,6 +32,7 @@ struct OutputQueueMerger {
int source;
int key_len{0};
td::BitArray<max_key_len> key;
bool limit_exceeded{false};
MsgKeyValue() = default;
MsgKeyValue(int src, Ref<vm::Cell> node);
MsgKeyValue(td::ConstBitPtr key_pfx, int key_pfx_len, int src, Ref<vm::Cell> node);
@ -82,6 +83,7 @@ struct OutputQueueMerger {
std::vector<td::int32> src_remaining_msgs_;
bool eof;
bool failed;
bool limit_exceeded{false};
void add_root(int src, Ref<vm::Cell> outmsg_root, td::int32 msg_limit);
bool load();
};