mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Recent updates in storage (#667)
* Fix error handling in Torrent.cpp, improve choosing peers for upload * Various improvements in storage daemon "get-pieces-info" Store "added at" Improve calculating up/down speed Improve TL protocol for future compatibility Remove empty directories on "--remove-files" Better windows support Debug logs in PeerActor More restrictions on TorrentInfo Bugfixes * Global speed limits for download and upload +bugfix * Reset download/upload speed on changing settings or completion * Exclude some system files in TorrentCreator
This commit is contained in:
parent
e3af63e6c0
commit
bb21f732fd
21 changed files with 974 additions and 213 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "PartsHelper.h"
|
||||
#include "PeerActor.h"
|
||||
#include "Torrent.h"
|
||||
#include "SpeedLimiter.h"
|
||||
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/Variant.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "db.h"
|
||||
|
||||
namespace ton {
|
||||
|
||||
class NodeActor : public td::actor::Actor {
|
||||
public:
|
||||
class NodeCallback {
|
||||
|
@ -60,14 +62,15 @@ class NodeActor : public td::actor::Actor {
|
|||
struct DbInitialData {
|
||||
std::vector<PendingSetFilePriority> priorities;
|
||||
std::set<td::uint64> pieces_in_db;
|
||||
td::uint32 added_at;
|
||||
};
|
||||
|
||||
NodeActor(PeerId self_id, ton::Torrent torrent, td::unique_ptr<Callback> callback,
|
||||
td::unique_ptr<NodeCallback> node_callback, std::shared_ptr<db::DbType> db, bool should_download = true,
|
||||
bool should_upload = true);
|
||||
td::unique_ptr<NodeCallback> node_callback, std::shared_ptr<db::DbType> db, SpeedLimiters speed_limiters,
|
||||
bool should_download = true, bool should_upload = true);
|
||||
NodeActor(PeerId self_id, ton::Torrent torrent, td::unique_ptr<Callback> callback,
|
||||
td::unique_ptr<NodeCallback> node_callback, std::shared_ptr<db::DbType> db, bool should_download,
|
||||
bool should_upload, DbInitialData db_initial_data);
|
||||
td::unique_ptr<NodeCallback> node_callback, std::shared_ptr<db::DbType> db, SpeedLimiters speed_limiters,
|
||||
bool should_download, bool should_upload, DbInitialData db_initial_data);
|
||||
void start_peer(PeerId peer_id, td::Promise<td::actor::ActorId<PeerActor>> promise);
|
||||
|
||||
struct NodeState {
|
||||
|
@ -76,11 +79,12 @@ class NodeActor : public td::actor::Actor {
|
|||
bool active_upload;
|
||||
double download_speed;
|
||||
double upload_speed;
|
||||
td::uint32 added_at;
|
||||
const std::vector<td::uint8> &file_priority;
|
||||
};
|
||||
void with_torrent(td::Promise<NodeState> promise) {
|
||||
promise.set_value(NodeState{torrent_, should_download_, should_upload_, download_speed_.speed(),
|
||||
upload_speed_.speed(), file_priority_});
|
||||
upload_speed_.speed(), added_at_, file_priority_});
|
||||
}
|
||||
std::string get_stats_str();
|
||||
|
||||
|
@ -98,20 +102,22 @@ class NodeActor : public td::actor::Actor {
|
|||
void get_peers_info(td::Promise<tl_object_ptr<ton_api::storage_daemon_peerList>> promise);
|
||||
|
||||
static void load_from_db(std::shared_ptr<db::DbType> db, td::Bits256 hash, td::unique_ptr<Callback> callback,
|
||||
td::unique_ptr<NodeCallback> node_callback,
|
||||
td::unique_ptr<NodeCallback> node_callback, SpeedLimiters speed_limiters,
|
||||
td::Promise<td::actor::ActorOwn<NodeActor>> promise);
|
||||
static void cleanup_db(std::shared_ptr<db::DbType> db, td::Bits256 hash, td::Promise<td::Unit> promise);
|
||||
|
||||
private:
|
||||
PeerId self_id_;
|
||||
ton::Torrent torrent_;
|
||||
std::shared_ptr<td::BufferSlice> torrent_info_str_;
|
||||
std::shared_ptr<TorrentInfo> torrent_info_shared_;
|
||||
std::vector<td::uint8> file_priority_;
|
||||
td::unique_ptr<Callback> callback_;
|
||||
td::unique_ptr<NodeCallback> node_callback_;
|
||||
std::shared_ptr<db::DbType> db_;
|
||||
bool should_download_{false};
|
||||
bool should_upload_{false};
|
||||
td::uint32 added_at_{0};
|
||||
SpeedLimiters speed_limiters_;
|
||||
|
||||
class Notifier : public td::actor::Actor {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue