Blackcoin Lore
This commit is contained in:
19
src/undo.h
19
src/undo.h
@@ -14,30 +14,33 @@
|
||||
*
|
||||
* Contains the prevout's CTxOut being spent, and if this was the
|
||||
* last output of the affected transaction, its metadata as well
|
||||
* (coinbase or not, height, transaction version)
|
||||
* (coinbase or not, height, transaction version, time)
|
||||
*/
|
||||
class CTxInUndo
|
||||
{
|
||||
public:
|
||||
CTxOut txout; // the txout data before being spent
|
||||
bool fCoinBase; // if the outpoint was the last unspent: whether it belonged to a coinbase
|
||||
bool fCoinStake; // if the outpoint was the last unspent: whether it belonged to a coinstake
|
||||
unsigned int nHeight; // if the outpoint was the last unspent: its height
|
||||
int nVersion; // if the outpoint was the last unspent: its version
|
||||
unsigned int nTime; // if the outpoint was the last unspent: its time
|
||||
|
||||
CTxInUndo() : txout(), fCoinBase(false), nHeight(0), nVersion(0) {}
|
||||
CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, unsigned int nHeightIn = 0, int nVersionIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn), nVersion(nVersionIn) { }
|
||||
|
||||
CTxInUndo() : txout(), fCoinBase(false), fCoinStake(false), nHeight(0), nVersion(0), nTime(0) {}
|
||||
CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, bool fCoinStakeIn = false, unsigned int nHeightIn = 0, int nVersionIn = 0, unsigned int nTimeIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), fCoinStake(fCoinStakeIn), nHeight(nHeightIn), nVersion(nVersionIn), nTime(nTimeIn) { }
|
||||
unsigned int GetSerializeSize(int nType, int nVersion) const {
|
||||
return ::GetSerializeSize(VARINT(nHeight*2+(fCoinBase ? 1 : 0)), nType, nVersion) +
|
||||
return ::GetSerializeSize(VARINT(nHeight*4+(fCoinBase ? 1 : 0)+(fCoinStake ? 2 : 0)), nType, nVersion) +
|
||||
(nHeight > 0 ? ::GetSerializeSize(VARINT(this->nVersion), nType, nVersion) : 0) +
|
||||
::GetSerializeSize(this->nTime, nType, nVersion) +
|
||||
::GetSerializeSize(CTxOutCompressor(REF(txout)), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream &s, int nType, int nVersion) const {
|
||||
::Serialize(s, VARINT(nHeight*2+(fCoinBase ? 1 : 0)), nType, nVersion);
|
||||
::Serialize(s, VARINT(nHeight*4+(fCoinBase ? 1 : 0)+(fCoinStake ? 2 : 0)), nType, nVersion);
|
||||
if (nHeight > 0)
|
||||
::Serialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Serialize(s, this->nTime, nType, nVersion);
|
||||
::Serialize(s, CTxOutCompressor(REF(txout)), nType, nVersion);
|
||||
}
|
||||
|
||||
@@ -45,10 +48,12 @@ public:
|
||||
void Unserialize(Stream &s, int nType, int nVersion) {
|
||||
unsigned int nCode = 0;
|
||||
::Unserialize(s, VARINT(nCode), nType, nVersion);
|
||||
nHeight = nCode / 2;
|
||||
nHeight = nCode / 4;
|
||||
fCoinBase = nCode & 1;
|
||||
fCoinStake = nCode & 2;
|
||||
if (nHeight > 0)
|
||||
::Unserialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Unserialize(s, this->nTime, nType, nVersion);
|
||||
::Unserialize(s, REF(CTxOutCompressor(REF(txout))), nType, nVersion);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user