mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Experimental flags for speeding up broadcasts
This commit is contained in:
parent
04f2bc1360
commit
8a08bf67a2
19 changed files with 131 additions and 46 deletions
|
@ -32,7 +32,7 @@ void OverlayOutboundFecBroadcast::alarm() {
|
|||
fec_type_.size(), flags_, std::move(X.data), X.id, fec_type_, date_);
|
||||
}
|
||||
|
||||
alarm_timestamp() = td::Timestamp::in(0.010);
|
||||
alarm_timestamp() = td::Timestamp::in(delay_);
|
||||
|
||||
if (seqno_ >= to_send_) {
|
||||
stop();
|
||||
|
@ -46,8 +46,9 @@ void OverlayOutboundFecBroadcast::start_up() {
|
|||
|
||||
OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags,
|
||||
td::actor::ActorId<OverlayImpl> overlay,
|
||||
PublicKeyHash local_id)
|
||||
PublicKeyHash local_id, double speed_multiplier)
|
||||
: flags_(flags) {
|
||||
delay_ /= speed_multiplier;
|
||||
CHECK(data.size() <= (1 << 27));
|
||||
local_id_ = local_id;
|
||||
overlay_ = std::move(overlay);
|
||||
|
@ -63,9 +64,10 @@ OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, t
|
|||
}
|
||||
|
||||
td::actor::ActorId<OverlayOutboundFecBroadcast> OverlayOutboundFecBroadcast::create(
|
||||
td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, PublicKeyHash local_id) {
|
||||
return td::actor::create_actor<OverlayOutboundFecBroadcast>(td::actor::ActorOptions().with_name("bcast"),
|
||||
std::move(data), flags, overlay, local_id)
|
||||
td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, PublicKeyHash local_id,
|
||||
double speed_multiplier) {
|
||||
return td::actor::create_actor<OverlayOutboundFecBroadcast>(
|
||||
td::actor::ActorOptions().with_name("bcast"), std::move(data), flags, overlay, local_id, speed_multiplier)
|
||||
.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class OverlayOutboundFecBroadcast : public td::actor::Actor {
|
|||
PublicKeyHash local_id_;
|
||||
Overlay::BroadcastDataHash data_hash_;
|
||||
td::uint32 flags_ = 0;
|
||||
double delay_ = 0.010;
|
||||
td::int32 date_;
|
||||
std::unique_ptr<td::fec::Encoder> encoder_;
|
||||
td::actor::ActorId<OverlayImpl> overlay_;
|
||||
|
@ -45,9 +46,9 @@ class OverlayOutboundFecBroadcast : public td::actor::Actor {
|
|||
public:
|
||||
static td::actor::ActorId<OverlayOutboundFecBroadcast> create(td::BufferSlice data, td::uint32 flags,
|
||||
td::actor::ActorId<OverlayImpl> overlay,
|
||||
PublicKeyHash local_id);
|
||||
PublicKeyHash local_id, double speed_multiplier = 1.0);
|
||||
OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay,
|
||||
PublicKeyHash local_id);
|
||||
PublicKeyHash local_id, double speed_multiplier = 1.0);
|
||||
|
||||
void alarm() override;
|
||||
void start_up() override;
|
||||
|
|
|
@ -63,7 +63,7 @@ td::actor::ActorOwn<Overlay> Overlay::create_private(
|
|||
return td::actor::create_actor<OverlayImpl>(
|
||||
overlay_actor_name(overlay_id), keyring, adnl, manager, dht_node, local_id, std::move(overlay_id),
|
||||
OverlayType::FixedMemberList, std::move(nodes), std::vector<PublicKeyHash>(), OverlayMemberCertificate{},
|
||||
std::move(callback), std::move(rules), std::move(scope));
|
||||
std::move(callback), std::move(rules), std::move(scope), std::move(opts));
|
||||
}
|
||||
|
||||
td::actor::ActorOwn<Overlay> Overlay::create_semiprivate(
|
||||
|
@ -99,6 +99,7 @@ OverlayImpl::OverlayImpl(td::actor::ActorId<keyring::Keyring> keyring, td::actor
|
|||
overlay_id_ = id_full_.compute_short_id();
|
||||
frequent_dht_lookup_ = opts_.frequent_dht_lookup_;
|
||||
peer_list_.local_member_flags_ = opts_.local_overlay_member_flags_;
|
||||
opts_.broadcast_speed_multiplier_ = std::max(opts_.broadcast_speed_multiplier_, 1e-9);
|
||||
|
||||
VLOG(OVERLAY_INFO) << this << ": creating";
|
||||
|
||||
|
@ -490,7 +491,8 @@ void OverlayImpl::send_broadcast_fec(PublicKeyHash send_as, td::uint32 flags, td
|
|||
VLOG(OVERLAY_WARNING) << "broadcast source certificate is invalid";
|
||||
return;
|
||||
}
|
||||
OverlayOutboundFecBroadcast::create(std::move(data), flags, actor_id(this), send_as);
|
||||
OverlayOutboundFecBroadcast::create(std::move(data), flags, actor_id(this), send_as,
|
||||
opts_.broadcast_speed_multiplier_);
|
||||
}
|
||||
|
||||
void OverlayImpl::print(td::StringBuilder &sb) {
|
||||
|
|
|
@ -269,6 +269,7 @@ struct OverlayOptions {
|
|||
td::uint32 nodes_to_send_ = 4;
|
||||
td::uint32 propagate_broadcast_to_ = 5;
|
||||
td::uint32 default_permanent_members_flags_ = 0;
|
||||
double broadcast_speed_multiplier_ = 1.0;
|
||||
};
|
||||
|
||||
class Overlays : public td::actor::Actor {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue