@@ -638,8 +638,6 @@ class CNetMessage {
638
638
*/
639
639
class TransportDeserializer {
640
640
public:
641
- // prepare for next message
642
- virtual void Reset () = 0;
643
641
// returns true if the current deserialization is complete
644
642
virtual bool Complete () const = 0;
645
643
// set the serialization context version
@@ -666,11 +664,6 @@ class V1TransportDeserializer : public TransportDeserializer
666
664
const uint256& GetMessageHash () const ;
667
665
int readHeader (const char *pch, unsigned int nBytes);
668
666
int readData (const char *pch, unsigned int nBytes);
669
- public:
670
-
671
- V1TransportDeserializer (const CMessageHeader::MessageStartChars& pchMessageStartIn, int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), hdr(pchMessageStartIn), vRecv(nTypeIn, nVersionIn) {
672
- Reset ();
673
- }
674
667
675
668
void Reset () {
676
669
vRecv.clear ();
@@ -682,6 +675,13 @@ class V1TransportDeserializer : public TransportDeserializer
682
675
data_hash.SetNull ();
683
676
hasher.Reset ();
684
677
}
678
+
679
+ public:
680
+
681
+ V1TransportDeserializer (const CMessageHeader::MessageStartChars& pchMessageStartIn, int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), hdr(pchMessageStartIn), vRecv(nTypeIn, nVersionIn) {
682
+ Reset ();
683
+ }
684
+
685
685
bool Complete () const
686
686
{
687
687
if (!in_data)
@@ -694,7 +694,9 @@ class V1TransportDeserializer : public TransportDeserializer
694
694
vRecv.SetVersion (nVersionIn);
695
695
}
696
696
int Read (const char *pch, unsigned int nBytes) {
697
- return in_data ? readData (pch, nBytes) : readHeader (pch, nBytes);
697
+ int ret = in_data ? readData (pch, nBytes) : readHeader (pch, nBytes);
698
+ if (ret < 0 ) Reset ();
699
+ return ret;
698
700
}
699
701
CNetMessage GetMessage (const CMessageHeader::MessageStartChars& message_start, int64_t time);
700
702
};
0 commit comments