aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-08-21 00:49:32 +0200
committerKamil Domanski <kdomanski@kdemail.net>2014-08-31 02:18:42 +0200
commit31e9a8384a77947f6777d035992f4734618ed206 (patch)
tree9a055fbae630bad4b7982a5aae1294a9579382cb /src/protocol.h
parent84881f8c472cc67dc757686eb7dc3b495b13cab8 (diff)
Use CSizeComputer to avoid counting sizes in SerializationOp
Diffstat (limited to 'src/protocol.h')
-rw-r--r--src/protocol.h18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/protocol.h b/src/protocol.h
index 0f5c5559d1..e4b0991774 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -38,13 +38,11 @@ class CMessageHeader
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
- inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- size_t nSerSize = 0;
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(FLATDATA(pchMessageStart));
READWRITE(FLATDATA(pchCommand));
READWRITE(nMessageSize);
READWRITE(nChecksum);
- return nSerSize;
}
// TODO: make private (improves encapsulation)
@@ -90,12 +88,10 @@ class CAddress : public CService
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
- inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- size_t nSerSize = 0;
- bool fRead = boost::is_same<Operation, CSerActionUnserialize>();
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ bool fRead = ser_action.ForRead();
CAddress* pthis = const_cast<CAddress*>(this);
- CService* pip = (CService*)pthis;
if (fRead)
pthis->Init();
if (nType & SER_DISK)
@@ -104,9 +100,7 @@ class CAddress : public CService
(nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
READWRITE(nTime);
READWRITE(nServices);
- READWRITE(*pip);
-
- return nSerSize;
+ READWRITE(*(CService*)this);
}
// TODO: make private (improves encapsulation)
@@ -131,11 +125,9 @@ class CInv
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
- inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- size_t nSerSize = 0;
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(type);
READWRITE(hash);
- return nSerSize;
}
friend bool operator<(const CInv& a, const CInv& b);