mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Limit checked external messages per address (#1005)
* Limit checked external messages per address * Change max_ext_msg_per_addr_time_window; cleanup mempool by timer --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
d80ce8d3eb
commit
ceefac74cf
6 changed files with 92 additions and 23 deletions
|
@ -241,10 +241,20 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
};
|
||||
std::map<int, ExtMessages> ext_msgs_; // priority -> messages
|
||||
std::map<ExtMessage::Hash, std::pair<int, MessageId<ExtMessage>>> ext_messages_hashes_; // hash -> priority
|
||||
td::Timestamp cleanup_mempool_at_;
|
||||
// IHR ?
|
||||
std::map<MessageId<IhrMessage>, std::unique_ptr<MessageExt<IhrMessage>>> ihr_messages_;
|
||||
std::map<IhrMessage::Hash, MessageId<IhrMessage>> ihr_messages_hashes_;
|
||||
|
||||
struct CheckedExtMsgCounter {
|
||||
std::map<std::pair<WorkchainId, StdSmcAddress>, size_t> counter_cur_, counter_prev_;
|
||||
td::Timestamp cleanup_at_ = td::Timestamp::now();
|
||||
|
||||
size_t get_msg_count(WorkchainId wc, StdSmcAddress addr);
|
||||
size_t inc_msg_count(WorkchainId wc, StdSmcAddress addr);
|
||||
void before_query();
|
||||
} checked_ext_msg_counter_;
|
||||
|
||||
private:
|
||||
// VALIDATOR GROUPS
|
||||
ValidatorSessionId get_validator_set_id(ShardIdFull shard, td::Ref<ValidatorSet> val_set, td::Bits256 opts_hash,
|
||||
|
@ -678,6 +688,12 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
size_t max_cached_candidates() const {
|
||||
return 128;
|
||||
}
|
||||
static double max_ext_msg_per_addr_time_window() {
|
||||
return 10.0;
|
||||
}
|
||||
static size_t max_ext_msg_per_addr() {
|
||||
return 3 * 10;
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<BlockSeqno, WaitList<td::actor::Actor, td::Unit>> shard_client_waiters_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue