19
#include "overlay-fec.hpp"
21
#include "adnl/utils.hpp"
27
void OverlayOutboundFecBroadcast::alarm() {
28
for (td::uint32 i = 0; i < 4; i++) {
29
auto X = encoder_->gen_symbol(seqno_++);
30
CHECK(X.data.size() <= 1000);
31
td::actor::send_closure(overlay_, &OverlayImpl::send_new_fec_broadcast_part, local_id_, data_hash_,
32
fec_type_.size(), flags_, std::move(X.data), X.id, fec_type_, date_);
35
alarm_timestamp() = td::Timestamp::in(0.010);
37
if (seqno_ >= to_send_) {
42
void OverlayOutboundFecBroadcast::start_up() {
43
encoder_->prepare_more_symbols();
47
OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags,
48
td::actor::ActorId<OverlayImpl> overlay,
49
PublicKeyHash local_id)
51
CHECK(data.size() <= (1 << 27));
53
overlay_ = std::move(overlay);
54
date_ = static_cast<td::int32>(td::Clocks::system());
55
to_send_ = (static_cast<td::uint32>(data.size()) / symbol_size_ + 1) * 2;
57
data_hash_ = td::sha256_bits256(data);
59
fec_type_ = td::fec::RaptorQEncoder::Parameters{data.size(), symbol_size_, 0};
60
auto E = fec_type_.create_encoder(std::move(data));
62
encoder_ = E.move_as_ok();
65
td::actor::ActorId<OverlayOutboundFecBroadcast> OverlayOutboundFecBroadcast::create(
66
td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, PublicKeyHash local_id) {
67
return td::actor::create_actor<OverlayOutboundFecBroadcast>(td::actor::ActorOptions().with_name("bcast"),
68
std::move(data), flags, overlay, local_id)