8#ifndef BFI_BITCOIN_SERIALIZE_HPP
9#define BFI_BITCOIN_SERIALIZE_HPP
23#include <veriblock/pop/blob.hpp>
24#include <veriblock/pop/entities/popdata.hpp>
25#include <veriblock/pop/read_stream.hpp>
26#include <veriblock/pop/slice.hpp>
27#include <veriblock/pop/write_stream.hpp>
33static const uint64_t MAX_SIZE = 0x02000000;
52inline T& REF(
const T& val) {
53 return const_cast<T&
>(val);
61inline T* NCONST_PTR(
const T* val) {
62 return const_cast<T*
>(val);
66inline char* CharCast(
char* c) {
return c; }
67inline char* CharCast(
unsigned char* c) {
return (
char*)c; }
68inline const char* CharCast(
const char* c) {
return c; }
69inline const char* CharCast(
const unsigned char* c) {
return (
const char*)c; }
75template <
typename Stream>
76inline void ser_writedata8(Stream& s, uint8_t obj) {
77 s.template writeLE<uint8_t>(obj);
79template <
typename Stream>
80inline void ser_writedata16(Stream& s, uint16_t obj) {
81 s.template writeLE<uint16_t>(obj);
83template <
typename Stream>
84inline void ser_writedata16be(Stream& s, uint16_t obj) {
85 s.template writeBE<uint16_t>(obj);
87template <
typename Stream>
88inline void ser_writedata32(Stream& s, uint32_t obj) {
89 s.template writeLE<uint32_t>(obj);
91template <
typename Stream>
92inline void ser_writedata32be(Stream& s, uint32_t obj) {
93 s.template writeBE<uint32_t>(obj);
95template <
typename Stream>
96inline void ser_writedata64(Stream& s, uint64_t obj) {
97 s.template writeLE<uint64_t>(obj);
100template <
typename Stream,
typename T>
104 if (!s.template readLE<T>(out, state)) {
105 throw std::ios_base::failure(state.toString());
110template <
typename Stream,
typename T>
114 if (!s.template readBE<T>(out, state)) {
115 throw std::ios_base::failure(state.toString());
120template <
typename Stream>
121inline uint8_t ser_readdata8(Stream& s) {
122 return ReadLE<Stream, uint8_t>(s);
124template <
typename Stream>
125inline uint16_t ser_readdata16(Stream& s) {
126 return ReadLE<Stream, uint16_t>(s);
128template <
typename Stream>
129inline uint16_t ser_readdata16be(Stream& s) {
130 return ReadBE<Stream, uint16_t>(s);
132template <
typename Stream>
133inline uint32_t ser_readdata32(Stream& s) {
134 return ReadLE<Stream, uint32_t>(s);
136template <
typename Stream>
137inline uint32_t ser_readdata32be(Stream& s) {
138 return ReadBE<Stream, uint32_t>(s);
140template <
typename Stream>
141inline uint64_t ser_readdata64(Stream& s) {
142 return ReadLE<Stream, uint64_t>(s);
144inline uint64_t ser_double_to_uint64(
double x) {
152inline uint32_t ser_float_to_uint32(
float x) {
160inline double ser_uint64_to_double(uint64_t y) {
168inline float ser_uint32_to_float(uint32_t y) {
187 SER_NETWORK = (1 << 0),
189 SER_GETHASH = (1 << 2),
195X& ReadWriteAsHelper(X& x) {
199const X& ReadWriteAsHelper(
const X& x) {
203#define READWRITE(...) (SerReadWriteMany(s, ser_action, __VA_ARGS__))
204#define READWRITEAS(type, obj) \
205 (SerReadWriteMany(s, ser_action, ReadWriteAsHelper<type>(obj)))
213#define ADD_SERIALIZE_METHODS \
214 template <typename Stream> \
215 void Serialize(Stream& s) const { \
216 NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize()); \
218 template <typename Stream> \
219 void Unserialize(Stream& s) { \
220 SerializationOp(s, CSerActionUnserialize()); \
223#ifndef CHAR_EQUALS_INT8
224template <
typename Stream>
225inline void Serialize(Stream& s,
char a) {
226 ser_writedata8(s, a);
229template <
typename Stream>
230inline void Serialize(Stream& s, int8_t a) {
231 ser_writedata8(s, a);
233template <
typename Stream>
234inline void Serialize(Stream& s, uint8_t a) {
235 ser_writedata8(s, a);
237template <
typename Stream>
238inline void Serialize(Stream& s, int16_t a) {
239 ser_writedata16(s, a);
241template <
typename Stream>
242inline void Serialize(Stream& s, uint16_t a) {
243 ser_writedata16(s, a);
245template <
typename Stream>
246inline void Serialize(Stream& s, int32_t a) {
247 ser_writedata32(s, a);
249template <
typename Stream>
250inline void Serialize(Stream& s, uint32_t a) {
251 ser_writedata32(s, a);
253template <
typename Stream>
254inline void Serialize(Stream& s, int64_t a) {
255 ser_writedata64(s, a);
257template <
typename Stream>
258inline void Serialize(Stream& s, uint64_t a) {
259 ser_writedata64(s, a);
261template <
typename Stream>
262inline void Serialize(Stream& s,
float a) {
263 ser_writedata32(s, ser_float_to_uint32(a));
265template <
typename Stream>
266inline void Serialize(Stream& s,
double a) {
267 ser_writedata64(s, ser_double_to_uint64(a));
269template <
typename Stream,
int N>
270inline void Serialize(Stream& s,
const char (&a)[N]) {
273template <
typename Stream,
int N>
274inline void Serialize(Stream& s,
const unsigned char (&a)[N]) {
275 s.write(CharCast(a), N);
277template <
typename Stream>
278inline void Serialize(Stream& s,
280 s.write(CharCast(slice.data()), slice.size());
282template <
typename Stream,
size_t N>
284 s.write(CharCast(blob.data()), blob.size());
287#ifndef CHAR_EQUALS_INT8
288template <
typename Stream>
289inline void Unserialize(Stream& s,
char& a) {
290 a = ser_readdata8(s);
293template <
typename Stream>
294inline void Unserialize(Stream& s, int8_t& a) {
295 a = ser_readdata8(s);
297template <
typename Stream>
298inline void Unserialize(Stream& s, uint8_t& a) {
299 a = ser_readdata8(s);
301template <
typename Stream>
302inline void Unserialize(Stream& s, int16_t& a) {
303 a = ser_readdata16(s);
305template <
typename Stream>
306inline void Unserialize(Stream& s, uint16_t& a) {
307 a = ser_readdata16(s);
309template <
typename Stream>
310inline void Unserialize(Stream& s, int32_t& a) {
311 a = ser_readdata32(s);
313template <
typename Stream>
314inline void Unserialize(Stream& s, uint32_t& a) {
315 a = ser_readdata32(s);
317template <
typename Stream>
318inline void Unserialize(Stream& s, int64_t& a) {
319 a = ser_readdata64(s);
321template <
typename Stream>
322inline void Unserialize(Stream& s, uint64_t& a) {
323 a = ser_readdata64(s);
325template <
typename Stream>
326inline void Unserialize(Stream& s,
float& a) {
327 a = ser_uint32_to_float(ser_readdata32(s));
329template <
typename Stream>
330inline void Unserialize(Stream& s,
double& a) {
331 a = ser_uint64_to_double(ser_readdata64(s));
333template <
typename Stream,
int N>
334inline void Unserialize(Stream& s,
char (&a)[N]) {
336 if (!s.read(N, (uint8_t*)a, state)) {
337 throw std::ios_base::failure(state.toString());
340template <
typename Stream,
int N>
341inline void Unserialize(Stream& s,
unsigned char (&a)[N]) {
343 if (!s.read(N, a, state)) {
344 throw std::ios_base::failure(state.toString());
347template <
typename Stream>
348inline void Unserialize(Stream& s,
351 if (!s.read(slice.size(), slice.data(), state)) {
352 throw std::ios_base::failure(state.toString());
355template <
typename Stream,
size_t N>
358 if (!s.read(blob.size(), blob.data(), state)) {
359 throw std::ios_base::failure(state.toString());
363template <
typename Stream>
364inline void Serialize(Stream& s,
bool a) {
366 ser_writedata8(s, f);
368template <
typename Stream>
369inline void Unserialize(Stream& s,
bool& a) {
370 char f = ser_readdata8(s);
381inline unsigned int GetSizeOfCompactSize(uint64_t nSize) {
383 return sizeof(
unsigned char);
384 else if (nSize <= std::numeric_limits<unsigned short>::max())
385 return sizeof(
unsigned char) +
sizeof(
unsigned short);
386 else if (nSize <= std::numeric_limits<unsigned int>::max())
387 return sizeof(
unsigned char) +
sizeof(
unsigned int);
389 return sizeof(
unsigned char) +
sizeof(uint64_t);
392inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize);
394template <
typename Stream>
395void WriteCompactSize(Stream& os, uint64_t nSize) {
397 ser_writedata8(os, (uint8_t)nSize);
398 }
else if (nSize <= std::numeric_limits<unsigned short>::max()) {
399 ser_writedata8(os, 253);
400 ser_writedata16(os, (uint16_t)nSize);
401 }
else if (nSize <= std::numeric_limits<unsigned int>::max()) {
402 ser_writedata8(os, 254);
403 ser_writedata32(os, (uint32_t)nSize);
405 ser_writedata8(os, 255);
406 ser_writedata64(os, nSize);
411template <
typename Stream>
412uint64_t ReadCompactSize(Stream& is) {
413 uint8_t chSize = ser_readdata8(is);
414 uint64_t nSizeRet = 0;
417 }
else if (chSize == 253) {
418 nSizeRet = ser_readdata16(is);
420 throw std::ios_base::failure(
"non-canonical ReadCompactSize()");
421 }
else if (chSize == 254) {
422 nSizeRet = ser_readdata32(is);
423 if (nSizeRet < 0x10000u)
424 throw std::ios_base::failure(
"non-canonical ReadCompactSize()");
426 nSizeRet = ser_readdata64(is);
427 if (nSizeRet < 0x100000000ULL)
428 throw std::ios_base::failure(
"non-canonical ReadCompactSize()");
430 if (nSizeRet > MAX_SIZE)
431 throw std::ios_base::failure(
"ReadCompactSize(): size too large");
469enum class VarIntMode { DEFAULT, NONNEGATIVE_SIGNED };
471template <VarIntMode Mode,
typename I>
474 static_assert(Mode != VarIntMode::DEFAULT || std::is_unsigned<I>::value,
475 "Unsigned type required with mode DEFAULT.");
477 Mode != VarIntMode::NONNEGATIVE_SIGNED || std::is_signed<I>::value,
478 "Signed type required with mode NONNEGATIVE_SIGNED.");
482template <VarIntMode Mode,
typename I>
483inline unsigned int GetSizeOfVarInt(I n) {
488 if (n <= 0x7F)
break;
495inline void WriteVarInt(CSizeComputer& os, I n);
497template <
typename Stream, VarIntMode Mode,
typename I>
498void WriteVarInt(Stream& os, I n) {
499 CheckVarIntMode<Mode, I>();
500 unsigned char tmp[(
sizeof(n) * 8 + 6) / 7];
503 tmp[len] = (n & 0x7F) | (len ? 0x80 : 0x00);
504 if (n <= 0x7F)
break;
509 ser_writedata8(os, tmp[len]);
513template <
typename Stream, VarIntMode Mode,
typename I>
514I ReadVarInt(Stream& is) {
515 CheckVarIntMode<Mode, I>();
518 unsigned char chData = ser_readdata8(is);
519 if (n > (std::numeric_limits<I>::max() >> 7)) {
520 throw std::ios_base::failure(
"ReadVarInt(): size too large");
522 n = (n << 7) | (chData & 0x7F);
524 if (n == std::numeric_limits<I>::max()) {
525 throw std::ios_base::failure(
"ReadVarInt(): size too large");
534#define VARINT(obj, ...) WrapVarInt<__VA_ARGS__>(REF(obj))
535#define COMPACTSIZE(obj) CCompactSize(REF(obj))
536#define LIMITED_STRING(obj, n) LimitedString<n>(REF(obj))
538template <VarIntMode Mode,
typename I>
544 explicit CVarInt(I& nIn) : n(nIn) {}
546 template <
typename Stream>
547 void Serialize(Stream& s)
const {
548 WriteVarInt<Stream, Mode, I>(s, n);
551 template <
typename Stream>
552 void Unserialize(Stream& s) {
553 n = ReadVarInt<Stream, Mode, I>(s);
572 explicit BigEndian(I& val) : m_val(val) {
573 static_assert(std::is_unsigned<I>::value,
574 "BigEndian type must be unsigned integer");
575 static_assert(
sizeof(I) == 2 && std::numeric_limits<I>::min() == 0 &&
576 std::numeric_limits<I>::max() ==
577 std::numeric_limits<uint16_t>::max(),
578 "Unsupported BigEndian size");
581 template <
typename Stream>
582 void Serialize(Stream& s)
const {
583 ser_writedata16be(s, m_val);
586 template <
typename Stream>
587 void Unserialize(Stream& s) {
588 m_val = ser_readdata16be(s);
599 template <
typename Stream>
600 void Serialize(Stream& s)
const {
601 WriteCompactSize<Stream>(s, n);
604 template <
typename Stream>
605 void Unserialize(Stream& s) {
606 n = ReadCompactSize<Stream>(s);
610template <
size_t Limit>
616 explicit LimitedString(std::string& _string) : string(_string) {}
618 template <
typename Stream>
619 void Unserialize(Stream& s) {
620 size_t size = ReadCompactSize(s);
622 throw std::ios_base::failure(
"String length limit exceeded");
627 if (!s.read(size, (uint8_t*)
string.data(), state)) {
628 throw std::ios_base::failure(state.toString());
633 template <
typename Stream>
634 void Serialize(Stream& s)
const {
635 WriteCompactSize(s,
string.size());
636 if (!
string.empty()) s.write((
char*)
string.data(),
string.size());
640template <VarIntMode Mode = VarIntMode::DEFAULT,
typename I>
646BigEndian<I> WrapBigEndian(I& n) {
647 return BigEndian<I>(n);
657template <
typename Stream,
typename C>
658void Serialize(Stream& os,
const std::basic_string<C>& str);
659template <
typename Stream,
typename C>
660void Unserialize(Stream& is, std::basic_string<C>& str);
667template <
typename Stream,
typename T,
typename A>
668void Serialize_impl(Stream& os,
669 const std::vector<T, A>& v,
670 const unsigned char&);
671template <
typename Stream,
typename T,
typename A>
672void Serialize_impl(Stream& os,
const std::vector<T, A>& v,
const bool&);
673template <
typename Stream,
typename T,
typename A,
typename V>
674void Serialize_impl(Stream& os,
const std::vector<T, A>& v,
const V&);
675template <
typename Stream,
typename T,
typename A>
676inline void Serialize(Stream& os,
const std::vector<T, A>& v);
677template <
typename Stream,
typename T,
typename A>
678void Unserialize_impl(Stream& is, std::vector<T, A>& v,
const unsigned char&);
679template <
typename Stream,
typename T,
typename A,
typename V>
680void Unserialize_impl(Stream& is, std::vector<T, A>& v,
const V&);
681template <
typename Stream,
typename T,
typename A>
682inline void Unserialize(Stream& is, std::vector<T, A>& v);
687template <
typename Stream,
typename K,
typename T>
688void Serialize(Stream& os,
const std::pair<K, T>& item);
689template <
typename Stream,
typename K,
typename T>
690void Unserialize(Stream& is, std::pair<K, T>& item);
695template <
typename Stream,
typename K,
typename T,
typename Pred,
typename A>
696void Serialize(Stream& os,
const std::map<K, T, Pred, A>& m);
697template <
typename Stream,
typename K,
typename T,
typename Pred,
typename A>
698void Unserialize(Stream& is, std::map<K, T, Pred, A>& m);
703template <
typename Stream,
typename K,
typename Pred,
typename A>
704void Serialize(Stream& os,
const std::set<K, Pred, A>& m);
705template <
typename Stream,
typename K,
typename Pred,
typename A>
706void Unserialize(Stream& is, std::set<K, Pred, A>& m);
711template <
typename Stream,
typename T>
712void Serialize(Stream& os,
const std::shared_ptr<const T>& p);
713template <
typename Stream,
typename T>
714void Unserialize(Stream& os, std::shared_ptr<const T>& p);
719template <
typename Stream,
typename T>
720void Serialize(Stream& os,
const std::unique_ptr<const T>& p);
721template <
typename Stream,
typename T>
722void Unserialize(Stream& os, std::unique_ptr<const T>& p);
728template <
typename Stream,
typename T>
729inline void Serialize(Stream& os,
const T& a) {
733template <
typename Stream,
typename T>
734inline void Unserialize(Stream& is, T&& a) {
741template <
typename Stream,
typename C>
742void Serialize(Stream& os,
const std::basic_string<C>& str) {
743 WriteCompactSize(os, str.size());
744 if (!str.empty()) os.write((
char*)str.data(), str.size() *
sizeof(C));
747template <
typename Stream,
typename C>
748void Unserialize(Stream& is, std::basic_string<C>& str) {
749 uint32_t nSize = (uint32_t)ReadCompactSize(is);
753 if (!is.read(nSize *
sizeof(C), (uint8_t*)str.data(), state)) {
754 throw std::ios_base::failure(state.toString());
762template <
typename Stream,
typename T,
typename A>
763void Serialize_impl(Stream& os,
764 const std::vector<T, A>& v,
765 const unsigned char&) {
766 WriteCompactSize(os, v.size());
767 if (!v.empty()) os.write((
char*)v.data(), v.size() *
sizeof(T));
770template <
typename Stream,
typename T,
typename A>
771void Serialize_impl(Stream& os,
const std::vector<T, A>& v,
const bool&) {
775 WriteCompactSize(os, v.size());
776 for (
bool elem : v) {
781template <
typename Stream,
typename T,
typename A,
typename V>
782void Serialize_impl(Stream& os,
const std::vector<T, A>& v,
const V&) {
783 WriteCompactSize(os, v.size());
784 for (
typename std::vector<T, A>::const_iterator vi = v.begin(); vi != v.end();
786 Serialize(os, (*vi));
790template <
typename Stream,
typename T,
typename A>
791inline void Serialize(Stream& os,
const std::vector<T, A>& v) {
792 Serialize_impl(os, v, T());
795template <
typename Stream,
typename T,
typename A>
796void Unserialize_impl(Stream& is, std::vector<T, A>& v,
const unsigned char&) {
799 uint64_t nSize = ReadCompactSize(is);
803 uint64_t blk = std::min(nSize - i, (uint64_t)(1 + 4999999 /
sizeof(T)));
805 if (!is.read(blk *
sizeof(T), (uint8_t*)&v[i], state)) {
806 throw std::ios_base::failure(state.toString());
812template <
typename Stream,
typename T,
typename A,
typename V>
813void Unserialize_impl(Stream& is, std::vector<T, A>& v,
const V&) {
815 uint64_t nSize = ReadCompactSize(is);
818 while (nMid < nSize) {
819 nMid += 5000000 /
sizeof(T);
820 if (nMid > nSize) nMid = nSize;
822 for (; i < nMid; i++) Unserialize(is, v[i]);
826template <
typename Stream,
typename T,
typename A>
827inline void Unserialize(Stream& is, std::vector<T, A>& v) {
828 Unserialize_impl(is, v, T());
834template <
typename Stream,
typename K,
typename T>
835void Serialize(Stream& os,
const std::pair<K, T>& item) {
836 Serialize(os, item.first);
837 Serialize(os, item.second);
840template <
typename Stream,
typename K,
typename T>
841void Unserialize(Stream& is, std::pair<K, T>& item) {
842 Unserialize(is, item.first);
843 Unserialize(is, item.second);
849template <
typename Stream,
typename K,
typename T,
typename Pred,
typename A>
850void Serialize(Stream& os,
const std::map<K, T, Pred, A>& m) {
851 WriteCompactSize(os, m.size());
852 for (
const auto& entry : m) Serialize(os, entry);
855template <
typename Stream,
typename K,
typename T,
typename Pred,
typename A>
856void Unserialize(Stream& is, std::map<K, T, Pred, A>& m) {
858 uint64_t nSize = ReadCompactSize(is);
859 typename std::map<K, T, Pred, A>::iterator mi = m.begin();
860 for (uint64_t i = 0; i < nSize; i++) {
861 std::pair<K, T> item;
862 Unserialize(is, item);
863 mi = m.insert(mi, item);
870template <
typename Stream,
typename K,
typename Pred,
typename A>
871void Serialize(Stream& os,
const std::set<K, Pred, A>& m) {
872 WriteCompactSize(os, m.size());
873 for (
typename std::set<K, Pred, A>::const_iterator it = m.begin();
876 Serialize(os, (*it));
879template <
typename Stream,
typename K,
typename Pred,
typename A>
880void Unserialize(Stream& is, std::set<K, Pred, A>& m) {
882 uint64_t nSize = ReadCompactSize(is);
883 typename std::set<K, Pred, A>::iterator it = m.begin();
884 for (uint64_t i = 0; i < nSize; i++) {
886 Unserialize(is, key);
887 it = m.insert(it, key);
894template <
typename Stream,
typename T>
895void Serialize(Stream& os,
const std::unique_ptr<const T>& p) {
899template <
typename Stream,
typename T>
900void Unserialize(Stream& is, std::unique_ptr<const T>& p) {
901 p.reset(
new T(deserialize, is));
907template <
typename Stream,
typename T>
908void Serialize(Stream& os,
const std::shared_ptr<const T>& p) {
912template <
typename Stream,
typename T>
913void Unserialize(Stream& is, std::shared_ptr<const T>& p) {
914 p = std::make_shared<const T>(deserialize, is);
922void UnserializeOrThrow(
const std::vector<uint8_t>& in, T& out) {
923 ValidationState state;
924 ReadStream stream(in);
926 throw std::ios_base::failure(state.toString());
930template <
typename Stream>
931inline void Serialize(Stream& s,
const PopData& popData) {
932 std::vector<uint8_t> bytes_data = popData.toVbkEncoding();
933 Serialize(s, bytes_data);
935template <
typename Stream>
936inline void Unserialize(Stream& s, PopData& popData) {
937 std::vector<uint8_t> bytes_data;
938 Unserialize(s, bytes_data);
939 UnserializeOrThrow(bytes_data, popData);
946 constexpr bool ForRead()
const {
return false; }
949 constexpr bool ForRead()
const {
return true; }
970 explicit CSizeComputer(
int nVersionIn) : nSize(0), nVersion(nVersionIn) {}
972 void write(
const char*,
size_t _nSize) { this->nSize += _nSize; }
976 typename =
typename std::enable_if<std::is_integral<T>::value>::type>
978 this->nSize +=
sizeof(T);
983 typename =
typename std::enable_if<std::is_integral<T>::value>::type>
984 void writeBE(T,
size_t) {
985 this->nSize +=
sizeof(T);
989 void seek(
size_t _nSize) { this->nSize += _nSize; }
991 template <
typename T>
993 Serialize(*
this, obj);
997 size_t size()
const {
return nSize; }
999 int GetVersion()
const {
return nVersion; }
1002template <
typename Stream>
1003void SerializeMany(Stream&) {}
1005template <
typename Stream,
typename Arg,
typename... Args>
1006void SerializeMany(Stream& s,
const Arg& arg,
const Args&... args) {
1008 SerializeMany(s, args...);
1011template <
typename Stream>
1012inline void UnserializeMany(Stream&) {}
1014template <
typename Stream,
typename Arg,
typename... Args>
1015inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args) {
1016 Unserialize(s, arg);
1017 UnserializeMany(s, args...);
1020template <
typename Stream,
typename... Args>
1021inline void SerReadWriteMany(Stream& s,
1022 CSerActionSerialize,
1023 const Args&... args) {
1024 SerializeMany(s, args...);
1027template <
typename Stream,
typename... Args>
1028inline void SerReadWriteMany(Stream& s, CSerActionUnserialize, Args&&... args) {
1029 UnserializeMany(s, args...);
1032template <
typename I>
1033inline void WriteVarInt(CSizeComputer& s, I n) {
1034 s.seek(GetSizeOfVarInt<I>(n));
1037inline void WriteCompactSize(CSizeComputer& s, uint64_t nSize) {
1038 s.seek(GetSizeOfCompactSize(nSize));
1041template <
typename T>
1042size_t GetSerializeSize(
const T& t,
int nVersion = 0) {
1043 return (CSizeComputer(nVersion) << t).size();
1046template <
typename... T>
1047size_t GetSerializeSizeMany(
int nVersion,
const T&... t) {
1048 CSizeComputer sc(nVersion);
1049 SerializeMany(sc, t...);
Class that is used for storing validation state.
Serialization wrapper class for big-endian integers.
void seek(size_t _nSize)
Pretend _nSize bytes are written, without specifying them.
bool DeserializeFromVbkEncoding(ReadStream &stream, AltBlockAddon &out, ValidationState &state)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Contiguous byte array of fixed size.
Non-owning contiguous array.
Support for ADD_SERIALIZE_METHODS and READWRITE macro.
Dummy data type to identify deserializing constructors.