@@ -268,9 +268,22 @@ class Transport {
268268 virtual bool ReceivedMessageComplete () const = 0;
269269 /* * Set the deserialization context version for objects returned by GetReceivedMessage. */
270270 virtual void SetReceiveVersion (int version) = 0;
271- /* * Feed wire bytes to the transport; chops off consumed bytes off front of msg_bytes. */
272- virtual int ReceivedBytes (Span<const uint8_t >& msg_bytes) = 0;
273- /* * Retrieve a completed message from transport (only when ReceivedMessageComplete). */
271+
272+ /* * Feed wire bytes to the transport.
273+ *
274+ * @return false if some bytes were invalid, in which case the transport can't be used anymore.
275+ *
276+ * Consumed bytes are chopped off the front of msg_bytes.
277+ */
278+ virtual bool ReceivedBytes (Span<const uint8_t >& msg_bytes) = 0;
279+
280+ /* * Retrieve a completed message from transport.
281+ *
282+ * This can only be called when ReceivedMessageComplete() is true.
283+ *
284+ * If reject_message=true is returned the message itself is invalid, but (other than false
285+ * returned by ReceivedBytes) the transport is not in an inconsistent state.
286+ */
274287 virtual CNetMessage GetReceivedMessage (std::chrono::microseconds time, bool & reject_message) = 0;
275288
276289 // 2. Sending side functions, for converting messages into bytes to be sent over the wire.
@@ -387,7 +400,7 @@ class V1Transport final : public Transport
387400 vRecv.SetVersion (nVersionIn);
388401 }
389402
390- int ReceivedBytes (Span<const uint8_t >& msg_bytes) override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex)
403+ bool ReceivedBytes (Span<const uint8_t >& msg_bytes) override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex)
391404 {
392405 AssertLockNotHeld (m_recv_mutex);
393406 LOCK (m_recv_mutex);
@@ -397,7 +410,7 @@ class V1Transport final : public Transport
397410 } else {
398411 msg_bytes = msg_bytes.subspan (ret);
399412 }
400- return ret;
413+ return ret >= 0 ;
401414 }
402415
403416 CNetMessage GetReceivedMessage (std::chrono::microseconds time, bool & reject_message) override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex);
0 commit comments