mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve large OutMsgQueue clearance (#822)
* Improve Collator::opt_msg_queue_cleanup, increase collator timeout * Disable importing ext msgs if queue is too big * Extend timeout in collator if previous block is too old --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
51baec48a0
commit
7fcf267717
6 changed files with 105 additions and 25 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "vm/cellslice.h"
|
||||
#include "vm/stack.hpp"
|
||||
#include "common/bitstring.h"
|
||||
#include "td/utils/Random.h"
|
||||
|
||||
#include "td/utils/bits.h"
|
||||
|
||||
|
@ -2007,7 +2008,7 @@ bool DictionaryFixed::combine_with(DictionaryFixed& dict2) {
|
|||
|
||||
bool DictionaryFixed::dict_check_for_each(Ref<Cell> dict, td::BitPtr key_buffer, int n, int total_key_len,
|
||||
const DictionaryFixed::foreach_func_t& foreach_func,
|
||||
bool invert_first) const {
|
||||
bool invert_first, bool shuffle) const {
|
||||
if (dict.is_null()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2026,26 +2027,29 @@ bool DictionaryFixed::dict_check_for_each(Ref<Cell> dict, td::BitPtr key_buffer,
|
|||
key_buffer += l + 1;
|
||||
if (l) {
|
||||
invert_first = false;
|
||||
} else if (invert_first) {
|
||||
}
|
||||
bool invert = shuffle ? td::Random::fast(0, 1) == 1: invert_first;
|
||||
if (invert) {
|
||||
std::swap(c1, c2);
|
||||
}
|
||||
key_buffer[-1] = invert_first;
|
||||
key_buffer[-1] = invert;
|
||||
// recursive check_foreach applied to both children
|
||||
if (!dict_check_for_each(std::move(c1), key_buffer, n - l - 1, total_key_len, foreach_func)) {
|
||||
if (!dict_check_for_each(std::move(c1), key_buffer, n - l - 1, total_key_len, foreach_func, false, shuffle)) {
|
||||
return false;
|
||||
}
|
||||
key_buffer[-1] = !invert_first;
|
||||
return dict_check_for_each(std::move(c2), key_buffer, n - l - 1, total_key_len, foreach_func);
|
||||
key_buffer[-1] = !invert;
|
||||
return dict_check_for_each(std::move(c2), key_buffer, n - l - 1, total_key_len, foreach_func, false, shuffle);
|
||||
}
|
||||
|
||||
bool DictionaryFixed::check_for_each(const foreach_func_t& foreach_func, bool invert_first) {
|
||||
bool DictionaryFixed::check_for_each(const foreach_func_t& foreach_func, bool invert_first, bool shuffle) {
|
||||
force_validate();
|
||||
if (is_empty()) {
|
||||
return true;
|
||||
}
|
||||
int key_len = get_key_bits();
|
||||
unsigned char key_buffer[max_key_bytes];
|
||||
return dict_check_for_each(get_root_cell(), td::BitPtr{key_buffer}, key_len, key_len, foreach_func, invert_first);
|
||||
return dict_check_for_each(get_root_cell(), td::BitPtr{key_buffer}, key_len, key_len, foreach_func, invert_first,
|
||||
shuffle);
|
||||
}
|
||||
|
||||
static inline bool set_bit(td::BitPtr ptr, bool value = true) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue