mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 19:21:28 +02:00
Change getWalletTxs to return a set instead of a vector
For some reason, the primary consumer of getWalletTxs requires the transactions to be in hash order when it is processing them. std::map will iterate in hash order so the transactions end up in that order when placed into the vector. To ensure this order when mapWallet is no longer ordered, the vector is replaced with a set which will maintain the hash order.
This commit is contained in:
@ -183,7 +183,7 @@ public:
|
|||||||
virtual WalletTx getWalletTx(const uint256& txid) = 0;
|
virtual WalletTx getWalletTx(const uint256& txid) = 0;
|
||||||
|
|
||||||
//! Get list of all wallet transactions.
|
//! Get list of all wallet transactions.
|
||||||
virtual std::vector<WalletTx> getWalletTxs() = 0;
|
virtual std::set<WalletTx> getWalletTxs() = 0;
|
||||||
|
|
||||||
//! Try to get updated status for a particular transaction, if possible without blocking.
|
//! Try to get updated status for a particular transaction, if possible without blocking.
|
||||||
virtual bool tryGetTxStatus(const uint256& txid,
|
virtual bool tryGetTxStatus(const uint256& txid,
|
||||||
@ -395,6 +395,8 @@ struct WalletTx
|
|||||||
int64_t time;
|
int64_t time;
|
||||||
std::map<std::string, std::string> value_map;
|
std::map<std::string, std::string> value_map;
|
||||||
bool is_coinbase;
|
bool is_coinbase;
|
||||||
|
|
||||||
|
bool operator<(const WalletTx& a) const { return tx->GetHash() < a.tx->GetHash(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Updated transaction status.
|
//! Updated transaction status.
|
||||||
|
@ -318,13 +318,12 @@ public:
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
std::vector<WalletTx> getWalletTxs() override
|
std::set<WalletTx> getWalletTxs() override
|
||||||
{
|
{
|
||||||
LOCK(m_wallet->cs_wallet);
|
LOCK(m_wallet->cs_wallet);
|
||||||
std::vector<WalletTx> result;
|
std::set<WalletTx> result;
|
||||||
result.reserve(m_wallet->mapWallet.size());
|
|
||||||
for (const auto& entry : m_wallet->mapWallet) {
|
for (const auto& entry : m_wallet->mapWallet) {
|
||||||
result.emplace_back(MakeWalletTx(*m_wallet, entry.second));
|
result.emplace(MakeWalletTx(*m_wallet, entry.second));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user