diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-01-26 17:50:06 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-01-26 17:50:06 +0900 |
| commit | ba69f5c0c318132bb95c561f89488c754341ee96 (patch) | |
| tree | 26f016e6e2f2fd104c01fb6e2ac48374f5f2586c /src/Peer.cc | |
| parent | 8524ac38067ba2ca2e692de39166edd6612e1d5b (diff) | |
Refactor peer list management in DefaultPeerStorage
Peer list is now divided into 2: unusedPeers_ and usedPeers_.
Duplicate check is done using std::set by comparing pair of IP address
and port. For this, only IP address and port given to the Peer
constructor are used. In other words, TCP port received from extended
message is not used for this purpose.
Diffstat (limited to 'src/Peer.cc')
| -rw-r--r-- | src/Peer.cc | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/Peer.cc b/src/Peer.cc index b4fc13ac..1ca02d91 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -45,12 +45,11 @@ namespace aria2 { -#define BAD_CONDITION_INTERVAL 10 - Peer::Peer(std::string ipaddr, uint16_t port, bool incoming): ipaddr_(ipaddr), port_(port), - id_(fmt("%s(%u)", ipaddr_.c_str(), port_)), + origPort_(port), + cuid_(0), firstContactTime_(global::wallclock()), badConditionStartTime_(0), seeder_(false), @@ -60,7 +59,6 @@ Peer::Peer(std::string ipaddr, uint16_t port, bool incoming): disconnectedGracefully_(false) { memset(peerId_, 0, PEER_ID_LENGTH); - resetStatus(); } Peer::~Peer() @@ -98,10 +96,6 @@ void Peer::setPeerId(const unsigned char* peerId) memcpy(peerId_, peerId, PEER_ID_LENGTH); } -void Peer::resetStatus() { - cuid_ = 0; -} - bool Peer::amChoking() const { assert(res_); @@ -328,12 +322,6 @@ void Peer::startBadCondition() badConditionStartTime_ = global::wallclock(); } -bool Peer::isGood() const -{ - return badConditionStartTime_. - difference(global::wallclock()) >= BAD_CONDITION_INTERVAL; -} - uint8_t Peer::getExtensionMessageID(int key) const { assert(res_); |
