mirror of
				https://github.com/ton-blockchain/ton
				synced 2025-03-09 15:40:10 +00:00 
			
		
		
		
	Fix checking ext message broadcasts (#912)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
		
							parent
							
								
									71c650692d
								
							
						
					
					
						commit
						c7302bc4a3
					
				
					 2 changed files with 12 additions and 2 deletions
				
			
		|  | @ -109,7 +109,8 @@ 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) { | ||||
|   auto hash = td::sha256_bits256(q->message_->data_); | ||||
|   if (!processed_ext_msg_broadcasts_.insert(hash).second) { | ||||
|     return promise.set_error(td::Status::Error("duplicate external message broadcast")); | ||||
|   } | ||||
|   if (config_.ext_messages_broadcast_disabled_) { | ||||
|  | @ -120,6 +121,11 @@ void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broad | |||
|       } | ||||
|     }; | ||||
|   } | ||||
|   if (my_ext_msg_broadcasts_.count(hash)) { | ||||
|     // Don't re-check messages that were sent by us
 | ||||
|     promise.set_result(td::Unit()); | ||||
|     return; | ||||
|   } | ||||
|   td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::check_external_message, | ||||
|                           std::move(q->message_->data_), | ||||
|                           promise.wrap([](td::Ref<ExtMessage>) { return td::Unit(); })); | ||||
|  | @ -706,9 +712,11 @@ void FullNodeShardImpl::send_external_message(td::BufferSlice data) { | |||
|                             }); | ||||
|     return; | ||||
|   } | ||||
|   if (!processed_ext_msg_broadcasts_.insert(td::sha256_bits256(data)).second) { | ||||
|   td::Bits256 hash = td::sha256_bits256(data); | ||||
|   if (processed_ext_msg_broadcasts_.count(hash)) { | ||||
|     return; | ||||
|   } | ||||
|   my_ext_msg_broadcasts_.insert(hash); | ||||
|   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()) { | ||||
|  | @ -860,6 +868,7 @@ void FullNodeShardImpl::alarm() { | |||
|   } | ||||
|   if (cleanup_processed_ext_msg_at_ && cleanup_processed_ext_msg_at_.is_in_past()) { | ||||
|     processed_ext_msg_broadcasts_.clear(); | ||||
|     my_ext_msg_broadcasts_.clear(); | ||||
|     cleanup_processed_ext_msg_at_ = td::Timestamp::in(60.0); | ||||
|   } | ||||
|   alarm_timestamp().relax(sync_completed_at_); | ||||
|  |  | |||
|  | @ -252,6 +252,7 @@ class FullNodeShardImpl : public FullNodeShard { | |||
| 
 | ||||
|   FullNodeConfig config_; | ||||
| 
 | ||||
|   std::set<td::Bits256> my_ext_msg_broadcasts_; | ||||
|   std::set<td::Bits256> processed_ext_msg_broadcasts_; | ||||
|   td::Timestamp cleanup_processed_ext_msg_at_; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue