/* */ #ifndef _D_BT_RUNTIME_H_ #define _D_BT_RUNTIME_H_ #include "common.h" #include "BtConstants.h" namespace aria2 { class BtRuntime { private: uint64_t uploadLengthAtStartup; uint16_t port; bool halt; unsigned int connections; bool _ready; static const unsigned int MIN_PEERS = 40; public: BtRuntime(): uploadLengthAtStartup(0), port(0), halt(false), connections(0), _ready(false) {} ~BtRuntime() {} uint64_t getUploadLengthAtStartup() const { return uploadLengthAtStartup; } void setUploadLengthAtStartup(uint64_t length) { this->uploadLengthAtStartup = length; } void setListenPort(uint16_t port) { this->port = port; } uint16_t getListenPort() const { return port; } bool isHalt() const { return halt; } void setHalt(bool halt) { this->halt = halt; } unsigned int getConnections() const { return connections; } void increaseConnections() { connections++; } void decreaseConnections() { connections--; } bool lessThanMaxPeers() const { return connections < MAX_PEERS; } bool lessThanMinPeers() const { return connections < MIN_PEERS; } bool lessThanEqMinPeers() const { return connections <= MIN_PEERS; } bool ready() { return _ready; } void setReady(bool go) { _ready = go; } static const unsigned int MAX_PEERS = 55; }; typedef SharedHandle BtRuntimeHandle; } // namespace aria2 #endif // _D_BT_RUNTIME_H_