File tree Expand file tree Collapse file tree 3 files changed +5
-4
lines changed
Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 2626 * A UTXO entry.
2727 *
2828 * Serialized format:
29- * - VARINT((coinbase ? 1 : 0 ) | (height << 1 ))
29+ * - VARINT((height << 1 ) | (coinbase ? 1 : 0 ))
3030 * - the non-spent CTxOut (via TxOutCompression)
3131 */
3232class Coin
@@ -61,7 +61,7 @@ class Coin
6161 template <typename Stream>
6262 void Serialize (Stream &s) const {
6363 assert (!IsSpent ());
64- uint32_t code = nHeight * uint32_t { 2 } + fCoinBase ;
64+ uint32_t code{ static_cast < uint32_t >( nHeight << 1 ) | fCoinBase } ;
6565 ::Serialize (s, VARINT(code));
6666 ::Serialize (s, Using<TxOutCompression>(out));
6767 }
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ template <typename T>
5151static void TxOutSer (T& ss, const COutPoint& outpoint, const Coin& coin)
5252{
5353 ss << outpoint;
54- ss << static_cast <uint32_t >(( coin.nHeight << 1 ) + coin.fCoinBase );
54+ ss << ( static_cast <uint32_t >(coin.nHeight << 1 ) | coin.fCoinBase );
5555 ss << coin.out ;
5656}
5757
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ struct TxInUndoFormatter
2323{
2424 template <typename Stream>
2525 void Ser (Stream &s, const Coin& txout) {
26- ::Serialize (s, VARINT(txout.nHeight * uint32_t {2 } + txout.fCoinBase ));
26+ uint32_t nCode{static_cast <uint32_t >(txout.nHeight << 1 ) | txout.fCoinBase };
27+ ::Serialize (s, VARINT(nCode));
2728 if (txout.nHeight > 0 ) {
2829 // Required to maintain compatibility with older undo format.
2930 ::Serialize (s, (unsigned char )0);
You can’t perform that action at this time.
0 commit comments