Ton

Форк
0
/
LossStats.cpp 
42 строки · 1.3 Кб
1
/*
2
    This file is part of TON Blockchain Library.
3

4
    TON Blockchain Library is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU Lesser General Public License as published by
6
    the Free Software Foundation, either version 2 of the License, or
7
    (at your option) any later version.
8

9
    TON Blockchain Library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Lesser General Public License for more details.
13

14
    You should have received a copy of the GNU Lesser General Public License
15
    along with TON Blockchain Library.  If not, see <http://www.gnu.org/licenses/>.
16

17
    Copyright 2017-2020 Telegram Systems LLP
18
*/
19

20
#include "LossStats.h"
21
#include "td/utils/misc.h"
22

23
#include <cmath>
24

25
namespace ton {
26
namespace rldp2 {
27
void LossStats::on_update(td::uint32 ack, td::uint32 lost) {
28
  ack_ += ack;
29
  lost_ += lost;
30

31
  if (ack_ + lost_ > 1000) {
32
    auto new_loss = td::clamp((double)lost_ / (ack_ + lost_), 0.001, 0.2);
33
    if (fabs(new_loss - loss) > 5e-3) {
34
      prob = LossSender(new_loss, 1e-9);
35
    }
36
    loss = new_loss;
37
    ack_ = 0;
38
    lost_ = 0;
39
  }
40
}
41
}  // namespace rldp2
42
}  // namespace ton
43

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.