diff --git a/src/BtBitfieldMessage.cc b/src/BtBitfieldMessage.cc index 64418a0c..e53cdf85 100644 --- a/src/BtBitfieldMessage.cc +++ b/src/BtBitfieldMessage.cc @@ -113,8 +113,6 @@ std::vector BtBitfieldMessage::createMessage() return msg; } -size_t BtBitfieldMessage::getMessageLength() { return 5 + bitfieldLength_; } - std::string BtBitfieldMessage::toString() const { std::string s = NAME; diff --git a/src/BtBitfieldMessage.h b/src/BtBitfieldMessage.h index 195b1d1e..0015d439 100644 --- a/src/BtBitfieldMessage.h +++ b/src/BtBitfieldMessage.h @@ -68,8 +68,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; }; diff --git a/src/BtExtendedMessage.cc b/src/BtExtendedMessage.cc index 10517b3b..9f329c42 100644 --- a/src/BtExtendedMessage.cc +++ b/src/BtExtendedMessage.cc @@ -78,14 +78,6 @@ std::vector BtExtendedMessage::createMessage() return msg; } -size_t BtExtendedMessage::getMessageLength() -{ - if (!msgLength_) { - msgLength_ = 6 + extensionMessage_->getPayload().size(); - } - return msgLength_; -} - bool BtExtendedMessage::sendPredicate() const { return getPeer()->isExtendedMessagingEnabled(); diff --git a/src/BtExtendedMessage.h b/src/BtExtendedMessage.h index c22824d1..b61d4dfb 100644 --- a/src/BtExtendedMessage.h +++ b/src/BtExtendedMessage.h @@ -63,8 +63,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual bool sendPredicate() const CXX11_OVERRIDE; virtual std::string toString() const CXX11_OVERRIDE; diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc index 7f322f57..ce6023e7 100644 --- a/src/BtHandshakeMessage.cc +++ b/src/BtHandshakeMessage.cc @@ -93,8 +93,6 @@ std::vector BtHandshakeMessage::createMessage() return msg; } -size_t BtHandshakeMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string BtHandshakeMessage::toString() const { return fmt("%s peerId=%s, reserved=%s", NAME, diff --git a/src/BtHandshakeMessage.h b/src/BtHandshakeMessage.h index b1a55ad2..3aeeaf11 100644 --- a/src/BtHandshakeMessage.h +++ b/src/BtHandshakeMessage.h @@ -81,8 +81,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; bool isFastExtensionSupported() const; diff --git a/src/BtKeepAliveMessage.cc b/src/BtKeepAliveMessage.cc index bf656e46..b2172d7d 100644 --- a/src/BtKeepAliveMessage.cc +++ b/src/BtKeepAliveMessage.cc @@ -48,6 +48,4 @@ std::vector BtKeepAliveMessage::createMessage() return std::vector(MESSAGE_LENGTH); } -size_t BtKeepAliveMessage::getMessageLength() { return MESSAGE_LENGTH; } - } // namespace aria2 diff --git a/src/BtKeepAliveMessage.h b/src/BtKeepAliveMessage.h index 9312b48c..73bf05d8 100644 --- a/src/BtKeepAliveMessage.h +++ b/src/BtKeepAliveMessage.h @@ -54,8 +54,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE { return NAME; } }; diff --git a/src/BtPortMessage.cc b/src/BtPortMessage.cc index 4bc1d957..6a6c8d0f 100644 --- a/src/BtPortMessage.cc +++ b/src/BtPortMessage.cc @@ -114,8 +114,6 @@ std::vector BtPortMessage::createMessage() return msg; } -size_t BtPortMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string BtPortMessage::toString() const { return fmt("%s port=%u", NAME, port_); diff --git a/src/BtPortMessage.h b/src/BtPortMessage.h index ede01c00..ded9428b 100644 --- a/src/BtPortMessage.h +++ b/src/BtPortMessage.h @@ -73,8 +73,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; void setLocalNode(DHTNode* localNode); diff --git a/src/IndexBtMessage.cc b/src/IndexBtMessage.cc index f71d361d..a31e654d 100644 --- a/src/IndexBtMessage.cc +++ b/src/IndexBtMessage.cc @@ -53,8 +53,6 @@ std::vector IndexBtMessage::createMessage() return msg; } -size_t IndexBtMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string IndexBtMessage::toString() const { return fmt("%s index=%lu", getName(), static_cast(index_)); diff --git a/src/IndexBtMessage.h b/src/IndexBtMessage.h index 76f44bac..e4ed881b 100644 --- a/src/IndexBtMessage.h +++ b/src/IndexBtMessage.h @@ -67,8 +67,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; }; diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index 2f811ce7..ffda1801 100644 --- a/src/RangeBtMessage.cc +++ b/src/RangeBtMessage.cc @@ -63,8 +63,6 @@ std::vector RangeBtMessage::createMessage() return msg; } -size_t RangeBtMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string RangeBtMessage::toString() const { return fmt("%s index=%lu, begin=%d, length=%d", getName(), diff --git a/src/RangeBtMessage.h b/src/RangeBtMessage.h index 11fd8aa9..73c8f9eb 100644 --- a/src/RangeBtMessage.h +++ b/src/RangeBtMessage.h @@ -77,8 +77,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; }; diff --git a/src/SimpleBtMessage.cc b/src/SimpleBtMessage.cc index 57bc5aa2..92f1a8a8 100644 --- a/src/SimpleBtMessage.cc +++ b/src/SimpleBtMessage.cc @@ -57,7 +57,6 @@ void SimpleBtMessage::send() getPeer()->getIPAddress().c_str(), getPeer()->getPort(), toString().c_str())); auto msg = createMessage(); - size_t msgLength = getMessageLength(); A2_LOG_DEBUG( fmt("msglength = %lu bytes", static_cast(msg.size()))); getPeerConnection()->pushBytes(std::move(msg), getProgressUpdate()); diff --git a/src/SimpleBtMessage.h b/src/SimpleBtMessage.h index c1398149..76331682 100644 --- a/src/SimpleBtMessage.h +++ b/src/SimpleBtMessage.h @@ -51,8 +51,6 @@ public: virtual std::vector createMessage() = 0; - virtual size_t getMessageLength() = 0; - virtual std::unique_ptr getProgressUpdate(); virtual bool sendPredicate() const { return true; }; diff --git a/src/ZeroBtMessage.cc b/src/ZeroBtMessage.cc index d5641b06..dbe10f94 100644 --- a/src/ZeroBtMessage.cc +++ b/src/ZeroBtMessage.cc @@ -54,8 +54,6 @@ std::vector ZeroBtMessage::createMessage() return msg; } -size_t ZeroBtMessage::getMessageLength() { return MESSAGE_LENGTH; } - std::string ZeroBtMessage::toString() const { return getName(); } } // namespace aria2 diff --git a/src/ZeroBtMessage.h b/src/ZeroBtMessage.h index 875fd166..8afd3334 100644 --- a/src/ZeroBtMessage.h +++ b/src/ZeroBtMessage.h @@ -58,8 +58,6 @@ public: virtual std::vector createMessage() CXX11_OVERRIDE; - virtual size_t getMessageLength() CXX11_OVERRIDE; - virtual std::string toString() const CXX11_OVERRIDE; }; diff --git a/test/BtBitfieldMessageTest.cc b/test/BtBitfieldMessageTest.cc index f4b248fe..90b07810 100644 --- a/test/BtBitfieldMessageTest.cc +++ b/test/BtBitfieldMessageTest.cc @@ -79,7 +79,6 @@ void BtBitfieldMessageTest::testCreateMessage() auto rawmsg = msg.createMessage(); CPPUNIT_ASSERT_EQUAL((size_t)7, rawmsg.size()); CPPUNIT_ASSERT(std::equal(std::begin(rawmsg), std::end(rawmsg), data)); - CPPUNIT_ASSERT_EQUAL((size_t)7, msg.getMessageLength()); } void BtBitfieldMessageTest::testDoReceivedAction() diff --git a/test/BtExtendedMessageTest.cc b/test/BtExtendedMessageTest.cc index 5e7d4ca6..f32f3426 100644 --- a/test/BtExtendedMessageTest.cc +++ b/test/BtExtendedMessageTest.cc @@ -81,7 +81,6 @@ void BtExtendedMessageTest::testCreateMessage() auto rawmsg = msg.createMessage(); CPPUNIT_ASSERT_EQUAL((size_t)17, rawmsg.size()); CPPUNIT_ASSERT(std::equal(std::begin(rawmsg), std::end(rawmsg), data)); - CPPUNIT_ASSERT_EQUAL((size_t)17, msg.getMessageLength()); } void BtExtendedMessageTest::testDoReceivedAction() diff --git a/test/BtKeepAliveMessageTest.cc b/test/BtKeepAliveMessageTest.cc index 36d2eb59..2d9d4872 100644 --- a/test/BtKeepAliveMessageTest.cc +++ b/test/BtKeepAliveMessageTest.cc @@ -27,7 +27,6 @@ void BtKeepAliveMessageTest::testCreateMessage() memset(data, 0, sizeof(data)); BtKeepAliveMessage message; CPPUNIT_ASSERT_EQUAL((uint8_t)99, message.getId()); - CPPUNIT_ASSERT_EQUAL((size_t)4, message.getMessageLength()); auto rawmsg = message.createMessage(); CPPUNIT_ASSERT_EQUAL((size_t)4, rawmsg.size()); CPPUNIT_ASSERT(std::equal(std::begin(rawmsg), std::end(rawmsg), data));