mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
integrating the existing state of TON Storage / TON Payments / CPS Fift development branches
This commit is contained in:
parent
040df63c98
commit
4e2624459b
153 changed files with 10760 additions and 1695 deletions
40
rldp2/OutboundTransfer.cpp
Normal file
40
rldp2/OutboundTransfer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "OutboundTransfer.h"
|
||||
|
||||
namespace ton {
|
||||
namespace rldp2 {
|
||||
size_t OutboundTransfer::total_size() const {
|
||||
return data_.size();
|
||||
}
|
||||
std::map<td::uint32, OutboundTransfer::Part> &OutboundTransfer::parts(const RldpSender::Config &config) {
|
||||
while (parts_.size() < 20) {
|
||||
auto offset = next_part_ * part_size();
|
||||
if (offset >= data_.size()) {
|
||||
break;
|
||||
}
|
||||
td::BufferSlice D = data_.from_slice(data_.as_slice().substr(offset).truncate(part_size()));
|
||||
ton::fec::FecType fec_type = td::fec::RaptorQEncoder::Parameters{D.size(), symbol_size(), 0};
|
||||
auto encoder = fec_type.create_encoder(std::move(D)).move_as_ok();
|
||||
auto symbols_count = fec_type.symbols_count();
|
||||
parts_.emplace(next_part_, Part{std::move(encoder), RldpSender(config, symbols_count), std::move(fec_type)});
|
||||
next_part_++;
|
||||
}
|
||||
return parts_;
|
||||
}
|
||||
|
||||
void OutboundTransfer::drop_part(td::uint32 part_i) {
|
||||
parts_.erase(part_i);
|
||||
}
|
||||
|
||||
OutboundTransfer::Part *OutboundTransfer::get_part(td::uint32 part_i) {
|
||||
auto it = parts_.find(part_i);
|
||||
if (it == parts_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
bool OutboundTransfer::is_done() const {
|
||||
return next_part_ * part_size() >= data_.size() && parts_.empty();
|
||||
}
|
||||
} // namespace rldp2
|
||||
} // namespace ton
|
Loading…
Add table
Add a link
Reference in a new issue