2
This file is part of TON Blockchain Library.
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.
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.
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/>.
17
Copyright 2017-2020 Telegram Systems LLP
22
#include "td/utils/check.h"
26
td::uint32 FecHelper::get_fec_symbols_count() const {
27
constexpr td::uint32 x = 5;
28
constexpr td::uint32 y = 5;
29
// smallest (symbols_count + x + y * i) > received_symbols_count
30
if (symbols_count + x > received_symbols_count) {
31
return symbols_count + x;
33
td::uint32 i = (received_symbols_count - (symbols_count + x)) / y + 1;
34
return symbols_count + x + i * y;
37
td::uint32 FecHelper::get_left_fec_symbols_count() const {
38
auto fec_symbols_count = get_fec_symbols_count();
39
CHECK(fec_symbols_count > received_symbols_count);
40
return fec_symbols_count - received_symbols_count;