/* */ #include "BtHaveMessage.h" #include "Peer.h" #include "PieceStorage.h" #include "message.h" #include "DlAbortEx.h" namespace aria2 { const char BtHaveMessage::NAME[] = "have"; BtHaveMessage::BtHaveMessage(size_t index) : IndexBtMessage(ID, NAME, index) {} std::unique_ptr BtHaveMessage::create(const unsigned char* data, size_t dataLength) { return IndexBtMessage::create(data, dataLength); } void BtHaveMessage::doReceivedAction() { if (isMetadataGetMode()) { return; } size_t index = getIndex(); if (!getPeer()->hasPiece(index)) { getPeer()->updateBitfield(index, 1); getPieceStorage()->addPieceStats(index); if (getPeer()->isSeeder() && getPieceStorage()->downloadFinished()) { throw DL_ABORT_EX(MSG_GOOD_BYE_SEEDER); } } } } // namespace aria2