Changeset View
Changeset View
Standalone View
Standalone View
src/compressor.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | template <typename Stream> void Serialize(Stream &s) const { | ||||
s << CFlatData(script); | s << CFlatData(script); | ||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
unsigned int nSize = 0; | unsigned int nSize = 0; | ||||
s >> VARINT(nSize); | s >> VARINT(nSize); | ||||
if (nSize < nSpecialScripts) { | if (nSize < nSpecialScripts) { | ||||
std::vector<uint8_t> vch(GetSpecialSize(nSize), 0x00); | std::vector<uint8_t> vch(GetSpecialSize(nSize), 0x00); | ||||
s >> REF(CFlatData(vch)); | s >> CFlatData(vch); | ||||
Decompress(nSize, vch); | Decompress(nSize, vch); | ||||
return; | return; | ||||
} | } | ||||
nSize -= nSpecialScripts; | nSize -= nSpecialScripts; | ||||
if (nSize > MAX_SCRIPT_SIZE) { | if (nSize > MAX_SCRIPT_SIZE) { | ||||
// Overly long script, replace with a short invalid one | // Overly long script, replace with a short invalid one | ||||
script << OP_RETURN; | script << OP_RETURN; | ||||
s.ignore(nSize); | s.ignore(nSize); | ||||
} else { | } else { | ||||
script.resize(nSize); | script.resize(nSize); | ||||
s >> REF(CFlatData(script)); | s >> CFlatData(script); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** wrapper for CTxOut that provides a more compact serialization */ | /** wrapper for CTxOut that provides a more compact serialization */ | ||||
class CTxOutCompressor { | class CTxOutCompressor { | ||||
private: | private: | ||||
CTxOut &txout; | CTxOut &txout; | ||||
Show All 25 Lines |