mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Break up CAddrMan's IMPLEMENT_SERIALIZE
This commit is contained in:
committed by
Pieter Wuille
parent
87e40799fd
commit
b069750d3f
@@ -830,6 +830,35 @@ struct ser_streamplaceholder
|
||||
|
||||
typedef std::vector<char, zero_after_free_allocator<char> > CSerializeData;
|
||||
|
||||
class CSizeComputer
|
||||
{
|
||||
protected:
|
||||
size_t nSize;
|
||||
|
||||
public:
|
||||
int nType;
|
||||
int nVersion;
|
||||
|
||||
CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {}
|
||||
|
||||
CSizeComputer& write(const char *psz, int nSize)
|
||||
{
|
||||
this->nSize += nSize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CSizeComputer& operator<<(const T& obj)
|
||||
{
|
||||
::Serialize(*this, obj, nType, nVersion);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return nSize;
|
||||
}
|
||||
};
|
||||
|
||||
/** Double ended buffer combining vector and stream-like interfaces.
|
||||
*
|
||||
* >> and << read and write unformatted data using the above serialization templates.
|
||||
|
||||
Reference in New Issue
Block a user