mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: make CTxMemPool::get*Index functions and arguments const
This commit is contained in:
parent
5ad49ad668
commit
625982e8d2
@ -33,7 +33,7 @@ bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetSpentIndex(CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value)
|
bool GetSpentIndex(const CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value)
|
||||||
{
|
{
|
||||||
if (!fSpentIndex)
|
if (!fSpentIndex)
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,7 +27,7 @@ bool GetAddressIndex(uint160 addressHash, AddressType type,
|
|||||||
int32_t start = 0, int32_t end = 0);
|
int32_t start = 0, int32_t end = 0);
|
||||||
bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs);
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs);
|
||||||
bool GetSpentIndex(CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value);
|
bool GetSpentIndex(const CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value);
|
||||||
bool GetTimestampIndex(const uint32_t high, const uint32_t low, std::vector<uint256>& hashes);
|
bool GetTimestampIndex(const uint32_t high, const uint32_t low, std::vector<uint256>& hashes);
|
||||||
|
|
||||||
#endif // BITCOIN_RPC_CLIENT_H
|
#endif // BITCOIN_RPC_CLIENT_H
|
||||||
|
@ -427,7 +427,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view)
|
void CTxMemPool::addAddressIndex(const CTxMemPoolEntry& entry, const CCoinsViewCache& view)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
const CTransaction& tx = entry.GetTx();
|
const CTransaction& tx = entry.GetTx();
|
||||||
@ -470,12 +470,12 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC
|
|||||||
mapAddressInserted.insert(std::make_pair(txhash, inserted));
|
mapAddressInserted.insert(std::make_pair(txhash, inserted));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTxMemPool::getAddressIndex(std::vector<std::pair<uint160, AddressType> > &addresses,
|
bool CTxMemPool::getAddressIndex(const std::vector<std::pair<uint160, AddressType>>& addresses,
|
||||||
std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results)
|
std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta>>& results) const
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
for (const auto& address : addresses) {
|
for (const auto& address : addresses) {
|
||||||
addressDeltaMap::iterator ait = mapAddress.lower_bound(CMempoolAddressDeltaKey(address.second, address.first));
|
addressDeltaMap::const_iterator ait = mapAddress.lower_bound(CMempoolAddressDeltaKey(address.second, address.first));
|
||||||
while (ait != mapAddress.end() && (*ait).first.m_address_bytes == address.first && (*ait).first.m_address_type == address.second) {
|
while (ait != mapAddress.end() && (*ait).first.m_address_bytes == address.first && (*ait).first.m_address_type == address.second) {
|
||||||
results.push_back(*ait);
|
results.push_back(*ait);
|
||||||
ait++;
|
ait++;
|
||||||
@ -500,7 +500,7 @@ bool CTxMemPool::removeAddressIndex(const uint256 txhash)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view)
|
void CTxMemPool::addSpentIndex(const CTxMemPoolEntry& entry, const CCoinsViewCache& view)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
@ -530,12 +530,11 @@ void CTxMemPool::addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCac
|
|||||||
mapSpentInserted.insert(make_pair(txhash, inserted));
|
mapSpentInserted.insert(make_pair(txhash, inserted));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTxMemPool::getSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
|
bool CTxMemPool::getSpentIndex(const CSpentIndexKey& key, CSpentIndexValue& value) const
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
mapSpentIndex::iterator it;
|
mapSpentIndex::const_iterator it = mapSpent.find(key);
|
||||||
|
|
||||||
it = mapSpent.find(key);
|
|
||||||
if (it != mapSpent.end()) {
|
if (it != mapSpent.end()) {
|
||||||
value = it->second;
|
value = it->second;
|
||||||
return true;
|
return true;
|
||||||
|
@ -635,13 +635,13 @@ public:
|
|||||||
void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
|
void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
|
||||||
void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
|
void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
|
||||||
|
|
||||||
void addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
|
void addAddressIndex(const CTxMemPoolEntry& entry, const CCoinsViewCache& view);
|
||||||
bool getAddressIndex(std::vector<std::pair<uint160, AddressType> > &addresses,
|
bool getAddressIndex(const std::vector<std::pair<uint160, AddressType>>& addresses,
|
||||||
std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results);
|
std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta>>& results) const;
|
||||||
bool removeAddressIndex(const uint256 txhash);
|
bool removeAddressIndex(const uint256 txhash);
|
||||||
|
|
||||||
void addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
|
void addSpentIndex(const CTxMemPoolEntry& entry, const CCoinsViewCache& view);
|
||||||
bool getSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value);
|
bool getSpentIndex(const CSpentIndexKey& key, CSpentIndexValue& value) const;
|
||||||
bool removeSpentIndex(const uint256 txhash);
|
bool removeSpentIndex(const uint256 txhash);
|
||||||
|
|
||||||
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
Loading…
Reference in New Issue
Block a user