/* */ #include "ShareRatioSeedCriteria.h" #include "DownloadContext.h" #include "PeerStorage.h" #include "PieceStorage.h" namespace aria2 { ShareRatioSeedCriteria::ShareRatioSeedCriteria (double ratio, const SharedHandle& downloadContext) : ratio_(ratio), downloadContext_(downloadContext) {} ShareRatioSeedCriteria::~ShareRatioSeedCriteria() {} void ShareRatioSeedCriteria::reset() {} bool ShareRatioSeedCriteria::evaluate() { int64_t completedLength = pieceStorage_->getCompletedLength(); if(completedLength == 0) { return true; } TransferStat stat = peerStorage_->calculateStat(); return ratio_ <= 1.0*stat.getAllTimeUploadLength()/completedLength; } void ShareRatioSeedCriteria::setPeerStorage (const SharedHandle& peerStorage) { peerStorage_ = peerStorage; } void ShareRatioSeedCriteria::setPieceStorage (const SharedHandle& pieceStorage) { pieceStorage_ = pieceStorage; } } // namespace aria2