mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-22 10:02:34 +02:00
[wallet] Flatten CWalletTx class hierarchy
Removes CMerkleTx as a base class for CWalletTx. Serialization logic is moved from CMerkleTx to CWalletTx.
This commit is contained in:
parent
b3a9d179f2
commit
783a76f23b
@ -372,43 +372,13 @@ struct COutputEntry
|
|||||||
class CMerkleTx
|
class CMerkleTx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTransactionRef tx;
|
|
||||||
uint256 hashBlock;
|
|
||||||
|
|
||||||
/* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest
|
|
||||||
* block in the chain we know this or any in-wallet dependency conflicts
|
|
||||||
* with. Older clients interpret nIndex == -1 as unconfirmed for backward
|
|
||||||
* compatibility.
|
|
||||||
*/
|
|
||||||
int nIndex;
|
|
||||||
|
|
||||||
CMerkleTx()
|
|
||||||
{
|
|
||||||
SetTx(MakeTransactionRef());
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit CMerkleTx(CTransactionRef arg)
|
|
||||||
{
|
|
||||||
SetTx(std::move(arg));
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
hashBlock = uint256();
|
|
||||||
nIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetTx(CTransactionRef arg)
|
|
||||||
{
|
|
||||||
tx = std::move(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
template <typename Stream, typename Operation>
|
template <typename Stream, typename Operation>
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||||
|
CTransactionRef tx;
|
||||||
|
uint256 hashBlock;
|
||||||
|
int nIndex;
|
||||||
std::vector<uint256> vMerkleBranch; // For compatibility with older versions.
|
std::vector<uint256> vMerkleBranch; // For compatibility with older versions.
|
||||||
READWRITE(tx);
|
READWRITE(tx);
|
||||||
READWRITE(hashBlock);
|
READWRITE(hashBlock);
|
||||||
@ -425,7 +395,7 @@ int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet,
|
|||||||
* A transaction with a bunch of additional info that only the owner cares about.
|
* A transaction with a bunch of additional info that only the owner cares about.
|
||||||
* It includes any unrecorded transactions needed to link it back to the block chain.
|
* It includes any unrecorded transactions needed to link it back to the block chain.
|
||||||
*/
|
*/
|
||||||
class CWalletTx : public CMerkleTx
|
class CWalletTx
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const CWallet* pwallet;
|
const CWallet* pwallet;
|
||||||
@ -490,7 +460,10 @@ public:
|
|||||||
mutable bool fInMempool;
|
mutable bool fInMempool;
|
||||||
mutable CAmount nChangeCached;
|
mutable CAmount nChangeCached;
|
||||||
|
|
||||||
CWalletTx(const CWallet* pwalletIn, CTransactionRef arg) : CMerkleTx(std::move(arg))
|
CWalletTx(const CWallet* pwalletIn, CTransactionRef arg)
|
||||||
|
: tx(std::move(arg)),
|
||||||
|
hashBlock(uint256()),
|
||||||
|
nIndex(-1)
|
||||||
{
|
{
|
||||||
Init(pwalletIn);
|
Init(pwalletIn);
|
||||||
}
|
}
|
||||||
@ -510,6 +483,15 @@ public:
|
|||||||
nOrderPos = -1;
|
nOrderPos = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTransactionRef tx;
|
||||||
|
uint256 hashBlock;
|
||||||
|
/* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest
|
||||||
|
* block in the chain we know this or any in-wallet dependency conflicts
|
||||||
|
* with. Older clients interpret nIndex == -1 as unconfirmed for backward
|
||||||
|
* compatibility.
|
||||||
|
*/
|
||||||
|
int nIndex;
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void Serialize(Stream& s) const
|
void Serialize(Stream& s) const
|
||||||
{
|
{
|
||||||
@ -522,7 +504,8 @@ public:
|
|||||||
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
|
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
|
||||||
}
|
}
|
||||||
|
|
||||||
s << static_cast<const CMerkleTx&>(*this);
|
std::vector<uint256> dummy_vector; //!< Used to be vMerkleBranch
|
||||||
|
s << tx << hashBlock << dummy_vector << nIndex;
|
||||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||||
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
|
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
|
||||||
}
|
}
|
||||||
@ -533,7 +516,8 @@ public:
|
|||||||
Init(nullptr);
|
Init(nullptr);
|
||||||
char fSpent;
|
char fSpent;
|
||||||
|
|
||||||
s >> static_cast<CMerkleTx&>(*this);
|
std::vector<uint256> dummy_vector; //!< Used to be vMerkleBranch
|
||||||
|
s >> tx >> hashBlock >> dummy_vector >> nIndex;
|
||||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||||
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
|
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
|
||||||
|
|
||||||
@ -546,6 +530,11 @@ public:
|
|||||||
mapValue.erase("timesmart");
|
mapValue.erase("timesmart");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetTx(CTransactionRef arg)
|
||||||
|
{
|
||||||
|
tx = std::move(arg);
|
||||||
|
}
|
||||||
|
|
||||||
//! make sure balances are recalculated
|
//! make sure balances are recalculated
|
||||||
void MarkDirty()
|
void MarkDirty()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user