wrapper for CTxOut that provides a more compact serialization */
| 84 | |
| 85 | /** wrapper for CTxOut that provides a more compact serialization */ |
| 86 | class CTxOutCompressor |
| 87 | { |
| 88 | private: |
| 89 | CTxOut &txout; |
| 90 | |
| 91 | public: |
| 92 | explicit CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { } |
| 93 | |
| 94 | ADD_SERIALIZE_METHODS; |
| 95 | |
| 96 | template <typename Stream, typename Operation> |
| 97 | inline void SerializationOp(Stream& s, Operation ser_action) { |
| 98 | if (!ser_action.ForRead()) { |
| 99 | uint64_t nVal = CompressAmount(txout.nValue); |
| 100 | READWRITE(VARINT(nVal)); |
| 101 | } else { |
| 102 | uint64_t nVal = 0; |
| 103 | READWRITE(VARINT(nVal)); |
| 104 | txout.nValue = DecompressAmount(nVal); |
| 105 | } |
| 106 | CScriptCompressor cscript(REF(txout.scriptPubKey)); |
| 107 | READWRITE(cscript); |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | #endif // BITCOIN_COMPRESSOR_H |
no outgoing calls
no test coverage detected