mirror of
				https://github.com/ton-blockchain/ton
				synced 2025-03-09 15:40:10 +00:00 
			
		
		
		
	Drop duplicate ext msg broadcasts (#894)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
		
							parent
							
								
									79c48ebbba
								
							
						
					
					
						commit
						f344aa46c3
					
				
					 2 changed files with 17 additions and 2 deletions
				
			
		|  | @ -109,6 +109,9 @@ void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broad | |||
|   } | ||||
| 
 | ||||
|   auto q = B.move_as_ok(); | ||||
|   if (!processed_ext_msg_broadcasts_.insert(td::sha256_bits256(q->message_->data_)).second) { | ||||
|     return promise.set_error(td::Status::Error("duplicate external message broadcast")); | ||||
|   } | ||||
|   if (config_.ext_messages_broadcast_disabled_) { | ||||
|     promise.set_error(td::Status::Error("rebroadcasting external messages is disabled")); | ||||
|     promise = [manager = validator_manager_, message = q->message_->data_.clone()](td::Result<td::Unit> R) mutable { | ||||
|  | @ -703,6 +706,9 @@ void FullNodeShardImpl::send_external_message(td::BufferSlice data) { | |||
|                             }); | ||||
|     return; | ||||
|   } | ||||
|   if (!processed_ext_msg_broadcasts_.insert(td::sha256_bits256(data)).second) { | ||||
|     return; | ||||
|   } | ||||
|   auto B = create_serialize_tl_object<ton_api::tonNode_externalMessageBroadcast>( | ||||
|       create_tl_object<ton_api::tonNode_externalMessage>(std::move(data))); | ||||
|   if (B.size() <= overlay::Overlays::max_simple_broadcast_size()) { | ||||
|  | @ -852,10 +858,15 @@ void FullNodeShardImpl::alarm() { | |||
|       update_certificate_at_ = td::Timestamp::never(); | ||||
|     } | ||||
|   } | ||||
|   if (cleanup_processed_ext_msg_at_ && cleanup_processed_ext_msg_at_.is_in_past()) { | ||||
|     processed_ext_msg_broadcasts_.clear(); | ||||
|     cleanup_processed_ext_msg_at_ = td::Timestamp::in(60.0); | ||||
|   } | ||||
|   alarm_timestamp().relax(sync_completed_at_); | ||||
|   alarm_timestamp().relax(update_certificate_at_); | ||||
|   alarm_timestamp().relax(reload_neighbours_at_); | ||||
|   alarm_timestamp().relax(ping_neighbours_at_); | ||||
|   alarm_timestamp().relax(cleanup_processed_ext_msg_at_); | ||||
| } | ||||
| 
 | ||||
| void FullNodeShardImpl::start_up() { | ||||
|  | @ -872,8 +883,8 @@ void FullNodeShardImpl::start_up() { | |||
| 
 | ||||
|     reload_neighbours_at_ = td::Timestamp::now(); | ||||
|     ping_neighbours_at_ = td::Timestamp::now(); | ||||
|     alarm_timestamp().relax(reload_neighbours_at_); | ||||
|     alarm_timestamp().relax(ping_neighbours_at_); | ||||
|     cleanup_processed_ext_msg_at_ = td::Timestamp::now(); | ||||
|     alarm_timestamp().relax(td::Timestamp::now()); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ | |||
| #include "full-node-shard.h" | ||||
| #include "td/actor/PromiseFuture.h" | ||||
| #include "td/utils/port/Poll.h" | ||||
| #include <set> | ||||
| 
 | ||||
| namespace ton { | ||||
| 
 | ||||
|  | @ -250,6 +251,9 @@ class FullNodeShardImpl : public FullNodeShard { | |||
|   adnl::AdnlNodeIdShort last_pinged_neighbour_ = adnl::AdnlNodeIdShort::zero(); | ||||
| 
 | ||||
|   FullNodeConfig config_; | ||||
| 
 | ||||
|   std::set<td::Bits256> processed_ext_msg_broadcasts_; | ||||
|   td::Timestamp cleanup_processed_ext_msg_at_; | ||||
| }; | ||||
| 
 | ||||
| }  // namespace fullnode
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue