Ton

Форк
0
/
RldpReceiver.cpp 
52 строки · 1.6 Кб
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 "RldpReceiver.h"
21

22
namespace ton {
23
namespace rldp2 {
24
td::Variant<RldpReceiver::ActionSendAck, RldpReceiver::ActionWait> RldpReceiver::next_action(td::Timestamp now) {
25
  if (send_ack_at_ && (send_ack_at_.is_in_past(now))) {
26
    return ActionSendAck{ack};
27
  }
28
  return ActionWait{send_ack_at_};
29
}
30

31
void RldpReceiver::on_ack_sent(td::Timestamp now) {
32
  if (cnt_ != 0) {
33
    //LOG(ERROR) << "RESEND ACK " << cnt_;
34
  }
35
  cnt_++;
36
  send_ack_at_ = {};
37
  if (cnt_ <= 7) {
38
    send_ack_at_.relax(td::Timestamp::at(now.at() + config_.ack_delay * (1 << cnt_)));
39
  }
40
}
41

42
bool RldpReceiver::on_received(td::uint32 seqno, td::Timestamp now) {
43
  if (!ack.on_got_packet(seqno)) {
44
    return false;
45
  }
46
  cnt_ = 0;
47
  send_ack_at_.relax(td::Timestamp::at(now.at() + config_.ack_delay));
48
  return true;
49
}
50

51
}  // namespace rldp2
52
}  // namespace ton
53

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

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

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

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