refactoring + sha1_info should be requestable
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
#include "../ft_sha1_info.hpp"
|
||||
|
||||
#include <mio/mio.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
namespace States {
|
||||
|
||||
@@ -19,11 +21,11 @@ struct SHA1 final : public StateI {
|
||||
const FTInfoSHA1&& sha1_info,
|
||||
const std::vector<uint8_t>&& sha1_info_data,
|
||||
const std::vector<uint8_t>&& sha1_info_hash,
|
||||
std::vector<bool>&& have_chunk = {}
|
||||
std::vector<bool>&& have_chunk
|
||||
);
|
||||
~SHA1(void) override = default;
|
||||
|
||||
bool iterate(void) override;
|
||||
bool iterate(float delta) override;
|
||||
std::unique_ptr<StateI> nextState(void) override;
|
||||
|
||||
public: // callbacks
|
||||
@@ -39,6 +41,11 @@ struct SHA1 final : public StateI {
|
||||
void onFT1ReceiveDataSHA1Chunk(uint32_t group_number, uint32_t peer_number, uint8_t transfer_id, size_t data_offset, const uint8_t* data, size_t data_size) override;
|
||||
void onFT1SendDataSHA1Chunk(uint32_t group_number, uint32_t peer_number, uint8_t transfer_id, size_t data_offset, uint8_t* data, size_t data_size) override;
|
||||
|
||||
private:
|
||||
// avoids duplicates
|
||||
// clears timer if exists
|
||||
void queueUpRequestInfo(uint32_t group_number, uint32_t peer_number);
|
||||
|
||||
private:
|
||||
mio::mmap_source _file_map;
|
||||
const FTInfoSHA1 _sha1_info;
|
||||
@@ -48,6 +55,11 @@ struct SHA1 final : public StateI {
|
||||
// index is the same as for info
|
||||
std::vector<bool> _have_chunk;
|
||||
bool _have_all {false};
|
||||
|
||||
// group_number, peer_number
|
||||
std::deque<std::pair<uint32_t, uint32_t>> _queue_requested_info;
|
||||
// group_number, peer_number, transfer_id, second since (remote) activity
|
||||
std::vector<std::tuple<uint32_t, uint32_t, uint8_t, float>> _transfers_requested_info;
|
||||
};
|
||||
|
||||
} // States
|
||||
|
||||
Reference in New Issue
Block a user