mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
4aa197dbdb
fa4632c41714dfaa699bacc6a947d72668a4deef test: Move boost/stdlib includes last (MarcoFalke) fa488f131fd4f5bab0d01376c5a5013306f1abcd scripted-diff: Bump copyright headers (MarcoFalke) fac5c373006a9e4bcbb56843bb85f1aca4d87599 scripted-diff: Sort test includes (MarcoFalke) Pull request description: When writing tests, often includes need to be added or removed. Currently the list of includes is not sorted, so developers that write tests and have `clang-format` installed will either have an unrelated change (sorting) included in their commit or they will have to manually undo the sort. This pull preempts both issues by just sorting all includes in one commit. Please be aware that this is **NOT** a change to policy to enforce clang-format or any other developer guideline or process. Developers are free to use whatever tool they want, see also #18651. Edit: Also includes a commit to bump the copyright headers, so that the touched files don't need to be touched again for that. ACKs for top commit: practicalswift: ACK fa4632c41714dfaa699bacc6a947d72668a4deef jonatack: ACK fa4632c41714dfaa, light review and sanity checks with gcc build and clang fuzz build Tree-SHA512: 130a8d073a379ba556b1e64104d37c46b671425c0aef0ed725fd60156a95e8dc83fb6f0b5330b2f8152cf5daaf3983b4aca5e75812598f2626c39fd12b88b180
72 lines
2.2 KiB
C++
72 lines
2.2 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_UNDO_H
|
|
#define BITCOIN_UNDO_H
|
|
|
|
#include <coins.h>
|
|
#include <compressor.h>
|
|
#include <consensus/consensus.h>
|
|
#include <primitives/transaction.h>
|
|
#include <serialize.h>
|
|
#include <version.h>
|
|
|
|
/** Formatter for undo information for a CTxIn
|
|
*
|
|
* Contains the prevout's CTxOut being spent, and its metadata as well
|
|
* (coinbase or not, height). The serialization contains a dummy value of
|
|
* zero. This is compatible with older versions which expect to see
|
|
* the transaction version there.
|
|
*/
|
|
struct TxInUndoFormatter
|
|
{
|
|
template<typename Stream>
|
|
void Ser(Stream &s, const Coin& txout) {
|
|
::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase ));
|
|
if (txout.nHeight > 0) {
|
|
// Required to maintain compatibility with older undo format.
|
|
::Serialize(s, (unsigned char)0);
|
|
}
|
|
::Serialize(s, Using<TxOutCompression>(txout.out));
|
|
}
|
|
|
|
template<typename Stream>
|
|
void Unser(Stream &s, Coin& txout) {
|
|
uint32_t nCode = 0;
|
|
::Unserialize(s, VARINT(nCode));
|
|
txout.nHeight = nCode >> 1;
|
|
txout.fCoinBase = nCode & 1;
|
|
if (txout.nHeight > 0) {
|
|
// Old versions stored the version number for the last spend of
|
|
// a transaction's outputs. Non-final spends were indicated with
|
|
// height = 0.
|
|
unsigned int nVersionDummy;
|
|
::Unserialize(s, VARINT(nVersionDummy));
|
|
}
|
|
::Unserialize(s, Using<TxOutCompression>(txout.out));
|
|
}
|
|
};
|
|
|
|
/** Undo information for a CTransaction */
|
|
class CTxUndo
|
|
{
|
|
public:
|
|
// undo information for all txins
|
|
std::vector<Coin> vprevout;
|
|
|
|
SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); }
|
|
};
|
|
|
|
/** Undo information for a CBlock */
|
|
class CBlockUndo
|
|
{
|
|
public:
|
|
std::vector<CTxUndo> vtxundo; // for all but the coinbase
|
|
|
|
SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); }
|
|
};
|
|
|
|
#endif // BITCOIN_UNDO_H
|