mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Use CSizeComputer to avoid counting sizes in SerializationOp
This commit is contained in:
committed by
Kamil Domanski
parent
84881f8c47
commit
31e9a8384a
@@ -91,10 +91,8 @@ class CNetAddr
|
||||
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(ip));
|
||||
return nSerSize;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -155,16 +153,13 @@ class CService : public CNetAddr
|
||||
IMPLEMENT_SERIALIZE;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
bool fRead = boost::is_same<Operation, CSerActionUnserialize>();
|
||||
size_t nSerSize = 0;
|
||||
CService* pthis = const_cast<CService*>(this);
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
bool fRead = ser_action.ForRead();
|
||||
READWRITE(FLATDATA(ip));
|
||||
unsigned short portN = htons(port);
|
||||
READWRITE(portN);
|
||||
if (fRead)
|
||||
pthis->port = ntohs(portN);
|
||||
return nSerSize;
|
||||
port = ntohs(portN);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user