mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
partial merge #8149: import OverrideStream from "BIP144: Serialization, hashes, relay (sender side)"
This commit is contained in:
parent
9310daca98
commit
05e5ee1be6
@ -22,6 +22,33 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
template<typename Stream>
|
||||||
|
class OverrideStream
|
||||||
|
{
|
||||||
|
Stream* stream;
|
||||||
|
public:
|
||||||
|
const int nType;
|
||||||
|
const int nVersion;
|
||||||
|
|
||||||
|
OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
OverrideStream<Stream>& operator<<(const T& obj)
|
||||||
|
{
|
||||||
|
// Serialize to this stream
|
||||||
|
::Serialize(*this->stream, obj);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
OverrideStream<Stream>& operator>>(T& obj)
|
||||||
|
{
|
||||||
|
// Unserialize from this stream
|
||||||
|
::Unserialize(*this->stream, obj);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* Minimal stream for overwriting and/or appending to an existing byte vector
|
/* Minimal stream for overwriting and/or appending to an existing byte vector
|
||||||
*
|
*
|
||||||
* The referenced vector will grow as necessary
|
* The referenced vector will grow as necessary
|
||||||
|
Loading…
Reference in New Issue
Block a user