Merge bitcoin/bitcoin#32768: wallet: Remove CWalletTx::fTimeReceivedIsTxTime
9eb2c82e7cwalletdb: Remove unused upgraded_txs (Ava Chow)c668033709wallet: Remove unused fTimeReceivedIsTxTime (Ava Chow) Pull request description: `CWalletTx::fTimeReceivedIsTxTime` is no longer used and can be removed. This additionally allows the removal of the `upgraded_txs` loop in `LoadWallet`. ACKs for top commit: maflcko: lgtm ACK9eb2c82e7cEunovo: ACK https://github.com/bitcoin/bitcoin/pull/32768/commits/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9 davidgumberg: ACK https://github.com/bitcoin/bitcoin/commit/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9 PeterWrighten: ACK https://github.com/bitcoin/bitcoin/commit/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9 rkrux: ACK9eb2c82e7cw0xlt: ACK https://github.com/bitcoin/bitcoin/pull/32768/commits/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9 Tree-SHA512: 05cf3a50f0d8ab6ef423ad1113c5ce6f45bfdc90e2c0dcf61c2dceced2465502e574b4b5b0091fcbb4bdd2182f8d69224f1e5516c7c505de07102b84a5f40e9c
This commit is contained in:
3 files changed
+9
-36
No files matched your search
@@ -203,7 +203,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
mapValue_t mapValue;
|
mapValue_t mapValue;
|
||||||
std::vector<std::pair<std::string, std::string> > vOrderForm;
|
std::vector<std::pair<std::string, std::string> > vOrderForm;
|
||||||
unsigned int fTimeReceivedIsTxTime;
|
|
||||||
unsigned int nTimeReceived; //!< time received by this node
|
unsigned int nTimeReceived; //!< time received by this node
|
||||||
/**
|
/**
|
||||||
* Stable timestamp that never changes, and reflects the order a transaction
|
* Stable timestamp that never changes, and reflects the order a transaction
|
||||||
@@ -240,7 +239,6 @@ public:
|
|||||||
{
|
{
|
||||||
mapValue.clear();
|
mapValue.clear();
|
||||||
vOrderForm.clear();
|
vOrderForm.clear();
|
||||||
fTimeReceivedIsTxTime = false;
|
|
||||||
nTimeReceived = 0;
|
nTimeReceived = 0;
|
||||||
nTimeSmart = 0;
|
nTimeSmart = 0;
|
||||||
fChangeCached = false;
|
fChangeCached = false;
|
||||||
@@ -274,10 +272,11 @@ public:
|
|||||||
|
|
||||||
std::vector<uint8_t> dummy_vector1; //!< Used to be vMerkleBranch
|
std::vector<uint8_t> dummy_vector1; //!< Used to be vMerkleBranch
|
||||||
std::vector<uint8_t> dummy_vector2; //!< Used to be vtxPrev
|
std::vector<uint8_t> dummy_vector2; //!< Used to be vtxPrev
|
||||||
bool dummy_bool = false; //!< Used to be fFromMe and fSpent
|
bool dummy_bool = false; //!< Used to be fFromMe, and fSpent
|
||||||
|
uint32_t dummy_int = 0; // Used to be fTimeReceivedIsTxTime
|
||||||
uint256 serializedHash = TxStateSerializedBlockHash(m_state);
|
uint256 serializedHash = TxStateSerializedBlockHash(m_state);
|
||||||
int serializedIndex = TxStateSerializedIndex(m_state);
|
int serializedIndex = TxStateSerializedIndex(m_state);
|
||||||
s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << dummy_bool << dummy_bool;
|
s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << dummy_int << nTimeReceived << dummy_bool << dummy_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
@@ -287,10 +286,11 @@ public:
|
|||||||
|
|
||||||
std::vector<uint256> dummy_vector1; //!< Used to be vMerkleBranch
|
std::vector<uint256> dummy_vector1; //!< Used to be vMerkleBranch
|
||||||
std::vector<CMerkleTx> dummy_vector2; //!< Used to be vtxPrev
|
std::vector<CMerkleTx> dummy_vector2; //!< Used to be vtxPrev
|
||||||
bool dummy_bool; //! Used to be fFromMe and fSpent
|
bool dummy_bool; //! Used to be fFromMe, and fSpent
|
||||||
|
uint32_t dummy_int; // Used to be fTimeReceivedIsTxTime
|
||||||
uint256 serialized_block_hash;
|
uint256 serialized_block_hash;
|
||||||
int serializedIndex;
|
int serializedIndex;
|
||||||
s >> TX_WITH_WITNESS(tx) >> serialized_block_hash >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> dummy_bool >> dummy_bool;
|
s >> TX_WITH_WITNESS(tx) >> serialized_block_hash >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> mapValue >> vOrderForm >> dummy_int >> nTimeReceived >> dummy_bool >> dummy_bool;
|
||||||
|
|
||||||
m_state = TxStateInterpretSerialized({serialized_block_hash, serializedIndex});
|
m_state = TxStateInterpretSerialized({serialized_block_hash, serializedIndex});
|
||||||
|
|
||||||
|
|||||||
@@ -726,7 +726,6 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
|
|||||||
if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
|
if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
|
||||||
copyTo->mapValue = copyFrom->mapValue;
|
copyTo->mapValue = copyFrom->mapValue;
|
||||||
copyTo->vOrderForm = copyFrom->vOrderForm;
|
copyTo->vOrderForm = copyFrom->vOrderForm;
|
||||||
// fTimeReceivedIsTxTime not copied on purpose
|
|
||||||
// nTimeReceived not copied on purpose
|
// nTimeReceived not copied on purpose
|
||||||
copyTo->nTimeSmart = copyFrom->nTimeSmart;
|
copyTo->nTimeSmart = copyFrom->nTimeSmart;
|
||||||
// nOrderPos not copied on purpose
|
// nOrderPos not copied on purpose
|
||||||
@@ -2227,7 +2226,6 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
|
|||||||
CHECK_NONFATAL(wtx.vOrderForm.empty());
|
CHECK_NONFATAL(wtx.vOrderForm.empty());
|
||||||
wtx.mapValue = std::move(mapValue);
|
wtx.mapValue = std::move(mapValue);
|
||||||
wtx.vOrderForm = std::move(orderForm);
|
wtx.vOrderForm = std::move(orderForm);
|
||||||
wtx.fTimeReceivedIsTxTime = true;
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+3
-28
@@ -1005,7 +1005,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vector<Txid>& upgraded_txs, bool& any_unordered) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, bool& any_unordered) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||||
{
|
{
|
||||||
AssertLockHeld(pwallet->cs_wallet);
|
AssertLockHeld(pwallet->cs_wallet);
|
||||||
DBErrors result = DBErrors::LOAD_OK;
|
DBErrors result = DBErrors::LOAD_OK;
|
||||||
@@ -1013,7 +1013,7 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
|
|||||||
// Load tx record
|
// Load tx record
|
||||||
any_unordered = false;
|
any_unordered = false;
|
||||||
LoadResult tx_res = LoadRecords(pwallet, batch, DBKeys::TX,
|
LoadResult tx_res = LoadRecords(pwallet, batch, DBKeys::TX,
|
||||||
[&any_unordered, &upgraded_txs] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
[&any_unordered] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||||
DBErrors result = DBErrors::LOAD_OK;
|
DBErrors result = DBErrors::LOAD_OK;
|
||||||
Txid hash;
|
Txid hash;
|
||||||
key >> hash;
|
key >> hash;
|
||||||
@@ -1030,27 +1030,6 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
|
|||||||
if (wtx.GetHash() != hash)
|
if (wtx.GetHash() != hash)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Undo serialize changes in 31600
|
|
||||||
if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
|
|
||||||
{
|
|
||||||
if (!value.empty())
|
|
||||||
{
|
|
||||||
uint8_t fTmp;
|
|
||||||
uint8_t fUnused;
|
|
||||||
std::string unused_string;
|
|
||||||
value >> fTmp >> fUnused >> unused_string;
|
|
||||||
pwallet->WalletLogPrintf("LoadWallet() upgrading tx ver=%d %d %s\n",
|
|
||||||
wtx.fTimeReceivedIsTxTime, fTmp, hash.ToString());
|
|
||||||
wtx.fTimeReceivedIsTxTime = fTmp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pwallet->WalletLogPrintf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString());
|
|
||||||
wtx.fTimeReceivedIsTxTime = 0;
|
|
||||||
}
|
|
||||||
upgraded_txs.push_back(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wtx.nOrderPos == -1)
|
if (wtx.nOrderPos == -1)
|
||||||
any_unordered = true;
|
any_unordered = true;
|
||||||
|
|
||||||
@@ -1149,7 +1128,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||||||
{
|
{
|
||||||
DBErrors result = DBErrors::LOAD_OK;
|
DBErrors result = DBErrors::LOAD_OK;
|
||||||
bool any_unordered = false;
|
bool any_unordered = false;
|
||||||
std::vector<Txid> upgraded_txs;
|
|
||||||
|
|
||||||
LOCK(pwallet->cs_wallet);
|
LOCK(pwallet->cs_wallet);
|
||||||
|
|
||||||
@@ -1186,7 +1164,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||||||
result = std::max(LoadAddressBookRecords(pwallet, *m_batch), result);
|
result = std::max(LoadAddressBookRecords(pwallet, *m_batch), result);
|
||||||
|
|
||||||
// Load tx records
|
// Load tx records
|
||||||
result = std::max(LoadTxRecords(pwallet, *m_batch, upgraded_txs, any_unordered), result);
|
result = std::max(LoadTxRecords(pwallet, *m_batch, any_unordered), result);
|
||||||
|
|
||||||
// Load SPKMs
|
// Load SPKMs
|
||||||
result = std::max(LoadActiveSPKMs(pwallet, *m_batch), result);
|
result = std::max(LoadActiveSPKMs(pwallet, *m_batch), result);
|
||||||
@@ -1210,9 +1188,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||||||
if (result != DBErrors::LOAD_OK)
|
if (result != DBErrors::LOAD_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
for (const Txid& hash : upgraded_txs)
|
|
||||||
WriteTx(pwallet->mapWallet.at(hash));
|
|
||||||
|
|
||||||
if (!has_last_client || last_client != CLIENT_VERSION) // Update
|
if (!has_last_client || last_client != CLIENT_VERSION) // Update
|
||||||
m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);
|
m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user