mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
Fix bug of broadcast stop on receiving the last FEC piece (#1040)
This commit is contained in:
parent
2634e63e4f
commit
11f39acef5
2 changed files with 34 additions and 21 deletions
|
@ -78,7 +78,6 @@ td::Status OverlayFecBroadcastPart::check_signature() {
|
|||
}
|
||||
|
||||
td::Status OverlayFecBroadcastPart::run_checks() {
|
||||
|
||||
TRY_STATUS(check_time());
|
||||
TRY_STATUS(check_duplicate());
|
||||
TRY_STATUS(check_source());
|
||||
|
@ -96,12 +95,15 @@ void BroadcastFec::broadcast_checked(td::Result<td::Unit> R) {
|
|||
while (!parts_.empty()) {
|
||||
distribute_part(parts_.begin()->first);
|
||||
}
|
||||
|
||||
is_checked_ = true;
|
||||
}
|
||||
|
||||
// Do we need status here??
|
||||
td::Status BroadcastFec::distribute_part(td::uint32 seqno) {
|
||||
auto i = parts_.find(seqno);
|
||||
if (i == parts_.end()) {
|
||||
VLOG(OVERLAY_WARNING) << "not distibuting empty part " << seqno;
|
||||
// should not get here
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
@ -132,7 +134,6 @@ td::Status BroadcastFec::distribute_part(td::uint32 seqno) {
|
|||
}
|
||||
|
||||
td::Status OverlayFecBroadcastPart::apply() {
|
||||
|
||||
if (!bcast_) {
|
||||
bcast_ = overlay_->get_fec_broadcast(broadcast_hash_);
|
||||
}
|
||||
|
@ -175,6 +176,10 @@ td::Status OverlayFecBroadcastPart::apply() {
|
|||
overlay_->deliver_broadcast(bcast_->get_source().compute_short_id(), R.move_as_ok());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bcast_->set_overlay(overlay_);
|
||||
bcast_->set_src_peer_id(src_peer_id_);
|
||||
TRY_STATUS(bcast_->add_part(seqno_, data_.clone(), export_serialized_short(), export_serialized()));
|
||||
}
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
@ -304,7 +309,8 @@ td::Status OverlayFecBroadcastPart::create_new(OverlayImpl *overlay, td::actor::
|
|||
|
||||
auto B = std::make_unique<OverlayFecBroadcastPart>(
|
||||
broadcast_hash, part_hash, PublicKey{}, overlay->get_certificate(local_id), data_hash, size, flags,
|
||||
part_data_hash, std::move(part), seqno, std::move(fec_type), date, td::BufferSlice{}, false, nullptr, overlay, adnl::AdnlNodeIdShort::zero());
|
||||
part_data_hash, std::move(part), seqno, std::move(fec_type), date, td::BufferSlice{}, false, nullptr, overlay,
|
||||
adnl::AdnlNodeIdShort::zero());
|
||||
auto to_sign = B->to_sign();
|
||||
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
|
|
|
@ -82,15 +82,15 @@ class BroadcastFec : public td::ListNode {
|
|||
}
|
||||
}
|
||||
|
||||
td::Status add_part(td::uint32 seqno, td::BufferSlice data,
|
||||
td::BufferSlice serialized_fec_part_short,
|
||||
td::Status add_part(td::uint32 seqno, td::BufferSlice data, td::BufferSlice serialized_fec_part_short,
|
||||
td::BufferSlice serialized_fec_part) {
|
||||
CHECK(decoder_);
|
||||
if (decoder_) {
|
||||
td::fec::Symbol s;
|
||||
s.id = seqno;
|
||||
s.data = std::move(data);
|
||||
|
||||
decoder_->add_symbol(std::move(s));
|
||||
}
|
||||
parts_[seqno] = std::pair<td::BufferSlice, td::BufferSlice>(std::move(serialized_fec_part_short),
|
||||
std::move(serialized_fec_part));
|
||||
|
||||
|
@ -200,8 +200,13 @@ class BroadcastFec : public td::ListNode {
|
|||
|
||||
td::Status distribute_part(td::uint32 seqno);
|
||||
|
||||
bool is_checked() const {
|
||||
return is_checked_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ready_ = false;
|
||||
bool is_checked_ = false;
|
||||
|
||||
Overlay::BroadcastHash hash_;
|
||||
Overlay::BroadcastDataHash data_hash_;
|
||||
|
@ -310,14 +315,16 @@ class OverlayFecBroadcastPart : public td::ListNode {
|
|||
td::Status run() {
|
||||
TRY_STATUS(run_checks());
|
||||
TRY_STATUS(apply());
|
||||
if(!untrusted_) {
|
||||
if (!untrusted_ || bcast_->is_checked()) {
|
||||
TRY_STATUS(distribute());
|
||||
}
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
static td::Status create(OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id, tl_object_ptr<ton_api::overlay_broadcastFec> broadcast);
|
||||
static td::Status create(OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id, tl_object_ptr<ton_api::overlay_broadcastFecShort> broadcast);
|
||||
static td::Status create(OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id,
|
||||
tl_object_ptr<ton_api::overlay_broadcastFec> broadcast);
|
||||
static td::Status create(OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id,
|
||||
tl_object_ptr<ton_api::overlay_broadcastFecShort> broadcast);
|
||||
static td::Status create_new(OverlayImpl *overlay, td::actor::ActorId<OverlayImpl> overlay_actor_id,
|
||||
PublicKeyHash local_id, Overlay::BroadcastDataHash data_hash, td::uint32 size,
|
||||
td::uint32 flags, td::BufferSlice part, td::uint32 seqno, fec::FecType fec_type,
|
||||
|
|
Loading…
Reference in a new issue