/* */ #include "BtAllowedFastMessage.h" #include "DlAbortEx.h" #include "Peer.h" #include "fmt.h" #include "SocketBuffer.h" namespace aria2 { const char BtAllowedFastMessage::NAME[] = "allowed fast"; BtAllowedFastMessage::BtAllowedFastMessage(size_t index): IndexBtMessage(ID, NAME, index) {} std::unique_ptr BtAllowedFastMessage::create (const unsigned char* data, size_t dataLength) { return IndexBtMessage::create(data, dataLength); } void BtAllowedFastMessage::doReceivedAction() { if(!getPeer()->isFastExtensionEnabled()) { throw DL_ABORT_EX (fmt("%s received while fast extension is disabled", toString().c_str())); } if(isMetadataGetMode()) { return; } getPeer()->addPeerAllowedIndex(getIndex()); } namespace { struct ThisProgressUpdate : public ProgressUpdate { ThisProgressUpdate(const std::shared_ptr& peer, size_t index) : peer(peer), index(index) {} virtual void update(size_t length, bool complete) CXX11_OVERRIDE { if(complete) { peer->addAmAllowedIndex(index); } } std::shared_ptr peer; size_t index; }; } // namespace std::unique_ptr BtAllowedFastMessage::getProgressUpdate() { return make_unique(getPeer(), getIndex()); } } // namespace aria2