@@ -101,9 +101,9 @@ OverlayImpl::OverlayImpl(td::actor::ActorId<keyring::Keyring> keyring, td::actor
101101
102102 VLOG (OVERLAY_INFO) << this << " : creating" ;
103103
104- update_root_member_list ( std::move (nodes), std::move (root_public_keys), std::move (cert ));
105-
106- update_neighbours (static_cast <td::uint32>(nodes. size ()) );
104+ auto nodes_size = static_cast <td::uint32>(nodes. size ( ));
105+ OverlayImpl::update_root_member_list ( std::move (nodes), std::move (root_public_keys), std::move (cert));
106+ update_neighbours (nodes_size );
107107}
108108
109109void OverlayImpl::process_query (adnl::AdnlNodeIdShort src, ton_api::overlay_getRandomPeers &query,
@@ -457,20 +457,6 @@ void OverlayImpl::bcast_gc() {
457457 CHECK (delivered_broadcasts_.size () == bcast_lru_.size ());
458458}
459459
460- void OverlayImpl::wait_neighbours_not_empty (td::Promise<td::Unit> promise, int max_retries) {
461- if (!peer_list_.neighbours_ .empty ()) {
462- promise.set_result (td::Unit ());
463- } else if (max_retries > 0 ) {
464- delay_action (
465- [SelfId = actor_id (this ), promise = std::move (promise), max_retries]() mutable {
466- td::actor::send_closure (SelfId, &OverlayImpl::wait_neighbours_not_empty, std::move (promise), max_retries - 1 );
467- },
468- td::Timestamp::in (0.5 ));
469- } else {
470- promise.set_error (td::Status::Error (ErrorCode::timeout));
471- }
472- }
473-
474460void OverlayImpl::send_broadcast (PublicKeyHash send_as, td::uint32 flags, td::BufferSlice data) {
475461 if (!has_valid_membership_certificate ()) {
476462 VLOG (OVERLAY_WARNING) << " member certificate is invalid, valid_until="
@@ -481,33 +467,23 @@ void OverlayImpl::send_broadcast(PublicKeyHash send_as, td::uint32 flags, td::Bu
481467 VLOG (OVERLAY_WARNING) << " broadcast source certificate is invalid" ;
482468 return ;
483469 }
484- wait_neighbours_not_empty ([this , send_as, flags, data = std::move (data)](td::Result<td::Unit> R) mutable {
485- if (R.is_error ()) {
486- return ;
487- }
488- auto S = BroadcastSimple::create_new (actor_id (this ), keyring_, send_as, std::move (data), flags);
489- if (S.is_error ()) {
490- LOG (WARNING) << " failed to send broadcast: " << S;
491- }
492- });
470+ auto S = BroadcastSimple::create_new (actor_id (this ), keyring_, send_as, std::move (data), flags);
471+ if (S.is_error ()) {
472+ LOG (WARNING) << " failed to send broadcast: " << S;
473+ }
493474}
494475
495476void OverlayImpl::send_broadcast_fec (PublicKeyHash send_as, td::uint32 flags, td::BufferSlice data) {
496477 if (!has_valid_membership_certificate ()) {
497- VLOG (OVERLAY_WARNING) << " meber certificate ist invalid, valid_until="
478+ VLOG (OVERLAY_WARNING) << " meber certificate is invalid, valid_until="
498479 << peer_list_.local_cert_is_valid_until_ .at_unix ();
499480 return ;
500481 }
501482 if (!has_valid_broadcast_certificate (send_as, data.size (), true )) {
502483 VLOG (OVERLAY_WARNING) << " broadcast source certificate is invalid" ;
503484 return ;
504485 }
505- wait_neighbours_not_empty ([this , send_as, flags, data = std::move (data)](td::Result<td::Unit> R) mutable {
506- if (R.is_error ()) {
507- return ;
508- }
509- OverlayOutboundFecBroadcast::create (std::move (data), flags, actor_id (this ), send_as);
510- });
486+ OverlayOutboundFecBroadcast::create (std::move (data), flags, actor_id (this ), send_as);
511487}
512488
513489void OverlayImpl::print (td::StringBuilder &sb) {
@@ -752,7 +728,8 @@ bool OverlayImpl::has_valid_broadcast_certificate(const PublicKeyHash &source, s
752728 return false ;
753729 }
754730 auto it = certs_.find (source);
755- return check_source_eligible (source, it == certs_.end () ? nullptr : it->second .get (), (td::uint32)size, is_fec);
731+ return check_source_eligible (source, it == certs_.end () ? nullptr : it->second .get (), (td::uint32)size, is_fec) !=
732+ BroadcastCheckResult::Forbidden;
756733}
757734
758735} // namespace overlay
0 commit comments