Remove PeerStorage:scheduleForcedChokeRound since it is not effective

This commit is contained in:
Tatsuhiro Tsujikawa 2016-06-04 22:11:51 +09:00
parent 6b8611885b
commit b95d7fbfec
5 changed files with 2 additions and 20 deletions

View file

@ -189,7 +189,6 @@ void DefaultBtInteractive::doPostHandshakeProcessing()
if (!metadataGetMode_) { if (!metadataGetMode_) {
addAllowedFastMessageToQueue(); addAllowedFastMessageToQueue();
} }
peerStorage_->scheduleForcedChokeRound();
sendPendingMessage(); sendPendingMessage();
} }

View file

@ -62,8 +62,7 @@ DefaultPeerStorage::DefaultPeerStorage()
: maxPeerListSize_(MAX_PEER_LIST_SIZE), : maxPeerListSize_(MAX_PEER_LIST_SIZE),
seederStateChoke_(make_unique<BtSeederStateChoke>()), seederStateChoke_(make_unique<BtSeederStateChoke>()),
leecherStateChoke_(make_unique<BtLeecherStateChoke>()), leecherStateChoke_(make_unique<BtLeecherStateChoke>()),
lastTransferStatMapUpdated_(Timer::zero()), lastTransferStatMapUpdated_(Timer::zero())
forceChokeRound_(false)
{ {
} }
@ -285,21 +284,16 @@ void DefaultPeerStorage::returnPeer(const std::shared_ptr<Peer>& peer)
bool DefaultPeerStorage::chokeRoundIntervalElapsed() bool DefaultPeerStorage::chokeRoundIntervalElapsed()
{ {
constexpr auto CHOKE_ROUND_INTERVAL = 10_s; constexpr auto CHOKE_ROUND_INTERVAL = 10_s;
auto forceChokeRound = forceChokeRound_;
forceChokeRound_ = false;
if (pieceStorage_->downloadFinished()) { if (pieceStorage_->downloadFinished()) {
auto interval = forceChokeRound ? 1_s : CHOKE_ROUND_INTERVAL;
return seederStateChoke_->getLastRound().difference(global::wallclock()) >= return seederStateChoke_->getLastRound().difference(global::wallclock()) >=
interval; CHOKE_ROUND_INTERVAL;
} }
return leecherStateChoke_->getLastRound().difference(global::wallclock()) >= return leecherStateChoke_->getLastRound().difference(global::wallclock()) >=
CHOKE_ROUND_INTERVAL; CHOKE_ROUND_INTERVAL;
} }
void DefaultPeerStorage::scheduleForcedChokeRound() { forceChokeRound_ = true; }
void DefaultPeerStorage::executeChoke() void DefaultPeerStorage::executeChoke()
{ {
if (pieceStorage_->downloadFinished()) { if (pieceStorage_->downloadFinished()) {

View file

@ -74,8 +74,6 @@ private:
std::map<std::string, Timer> badPeers_; std::map<std::string, Timer> badPeers_;
Timer lastBadPeerCleaned_; Timer lastBadPeerCleaned_;
bool forceChokeRound_;
bool isPeerAlreadyAdded(const std::shared_ptr<Peer>& peer); bool isPeerAlreadyAdded(const std::shared_ptr<Peer>& peer);
void addUniqPeer(const std::shared_ptr<Peer>& peer); void addUniqPeer(const std::shared_ptr<Peer>& peer);
@ -115,8 +113,6 @@ public:
virtual bool chokeRoundIntervalElapsed() CXX11_OVERRIDE; virtual bool chokeRoundIntervalElapsed() CXX11_OVERRIDE;
virtual void scheduleForcedChokeRound() CXX11_OVERRIDE;
virtual void executeChoke() CXX11_OVERRIDE; virtual void executeChoke() CXX11_OVERRIDE;
void deleteUnusedPeer(size_t delSize); void deleteUnusedPeer(size_t delSize);

View file

@ -113,11 +113,6 @@ public:
virtual bool chokeRoundIntervalElapsed() = 0; virtual bool chokeRoundIntervalElapsed() = 0;
/**
* Schedules choke round forcibly.
*/
virtual void scheduleForcedChokeRound() = 0;
virtual void executeChoke() = 0; virtual void executeChoke() = 0;
}; };

View file

@ -84,8 +84,6 @@ public:
virtual bool chokeRoundIntervalElapsed() CXX11_OVERRIDE { return false; } virtual bool chokeRoundIntervalElapsed() CXX11_OVERRIDE { return false; }
virtual void scheduleForcedChokeRound() CXX11_OVERRIDE {}
virtual void executeChoke() CXX11_OVERRIDE { ++numChokeExecuted_; } virtual void executeChoke() CXX11_OVERRIDE { ++numChokeExecuted_; }
int getNumChokeExecuted() const { return numChokeExecuted_; } int getNumChokeExecuted() const { return numChokeExecuted_; }