mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: make CBlockTreeDB::Read*Index arguments const
With bonus code formatting. We cannot make the functions themselves const as the iterators are non-const.
This commit is contained in:
parent
625982e8d2
commit
9a6503d9e8
@ -9,8 +9,9 @@
|
||||
#include <uint256.h>
|
||||
#include <validation.h>
|
||||
|
||||
bool GetAddressIndex(uint160 addressHash, AddressType type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount>>& addressIndex, int32_t start, int32_t end)
|
||||
bool GetAddressIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount>>& addressIndex,
|
||||
const int32_t start, const int32_t end)
|
||||
{
|
||||
if (!fAddressIndex)
|
||||
return error("address index not enabled");
|
||||
@ -21,7 +22,7 @@ bool GetAddressIndex(uint160 addressHash, AddressType type,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||
bool GetAddressUnspentIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs)
|
||||
{
|
||||
if (!fAddressIndex)
|
||||
@ -33,7 +34,7 @@ bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetSpentIndex(const CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value)
|
||||
bool GetSpentIndex(const CTxMemPool& mempool, const CSpentIndexKey& key, CSpentIndexValue& value)
|
||||
{
|
||||
if (!fSpentIndex)
|
||||
return false;
|
||||
|
@ -22,12 +22,12 @@ struct CSpentIndexValue;
|
||||
|
||||
enum class AddressType : uint8_t;
|
||||
|
||||
bool GetAddressIndex(uint160 addressHash, AddressType type,
|
||||
bool GetAddressIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount>>& addressIndex,
|
||||
int32_t start = 0, int32_t end = 0);
|
||||
bool GetAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||
const int32_t start = 0, const int32_t end = 0);
|
||||
bool GetAddressUnspentIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs);
|
||||
bool GetSpentIndex(const CTxMemPool& mempool, CSpentIndexKey& key, CSpentIndexValue& value);
|
||||
bool GetSpentIndex(const CTxMemPool& mempool, const CSpentIndexKey& key, CSpentIndexValue& value);
|
||||
bool GetTimestampIndex(const uint32_t high, const uint32_t low, std::vector<uint256>& hashes);
|
||||
|
||||
#endif // BITCOIN_RPC_CLIENT_H
|
||||
|
17
src/txdb.cpp
17
src/txdb.cpp
@ -263,7 +263,7 @@ bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockF
|
||||
return WriteBatch(batch, true);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value) {
|
||||
bool CBlockTreeDB::ReadSpentIndex(const CSpentIndexKey key, CSpentIndexValue& value) {
|
||||
return Read(std::make_pair(DB_SPENTINDEX, key), value);
|
||||
}
|
||||
|
||||
@ -291,9 +291,9 @@ bool CBlockTreeDB::UpdateAddressUnspentIndex(const std::vector<std::pair<CAddres
|
||||
return WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs) {
|
||||
|
||||
bool CBlockTreeDB::ReadAddressUnspentIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs)
|
||||
{
|
||||
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
pcursor->Seek(std::make_pair(DB_ADDRESSUNSPENTINDEX, CAddressIndexIteratorKey(type, addressHash)));
|
||||
@ -330,10 +330,10 @@ bool CBlockTreeDB::EraseAddressIndex(const std::vector<std::pair<CAddressIndexKe
|
||||
return WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, AddressType type,
|
||||
bool CBlockTreeDB::ReadAddressIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount>>& addressIndex,
|
||||
int start, int end) {
|
||||
|
||||
const int32_t start, const int32_t end)
|
||||
{
|
||||
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
if (start > 0 && end > 0) {
|
||||
@ -376,8 +376,7 @@ bool CBlockTreeDB::EraseTimestampIndex(const CTimestampIndexKey& timestampIndex)
|
||||
return WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadTimestampIndex(const unsigned int &high, const unsigned int &low, std::vector<uint256> &hashes) {
|
||||
|
||||
bool CBlockTreeDB::ReadTimestampIndex(const uint32_t high, const uint32_t low, std::vector<uint256>& hashes) {
|
||||
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
pcursor->Seek(std::make_pair(DB_TIMESTAMPINDEX, CTimestampIndexIteratorKey(low)));
|
||||
|
17
src/txdb.h
17
src/txdb.h
@ -84,19 +84,24 @@ public:
|
||||
bool ReadLastBlockFile(int &nFile);
|
||||
bool WriteReindexing(bool fReindexing);
|
||||
void ReadReindexing(bool &fReindexing);
|
||||
bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value);
|
||||
|
||||
bool ReadSpentIndex(const CSpentIndexKey key, CSpentIndexValue& value);
|
||||
bool UpdateSpentIndex(const std::vector<std::pair<CSpentIndexKey, CSpentIndexValue>>& vect);
|
||||
bool UpdateAddressUnspentIndex(const std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue > >&vect);
|
||||
bool ReadAddressUnspentIndex(uint160 addressHash, AddressType type,
|
||||
|
||||
bool ReadAddressUnspentIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& vect);
|
||||
bool UpdateAddressUnspentIndex(const std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& vect);
|
||||
|
||||
bool WriteAddressIndex(const std::vector<std::pair<CAddressIndexKey, CAmount>>& vect);
|
||||
bool EraseAddressIndex(const std::vector<std::pair<CAddressIndexKey, CAmount>>& vect);
|
||||
bool ReadAddressIndex(uint160 addressHash, AddressType type,
|
||||
bool ReadAddressIndex(const uint160& addressHash, const AddressType type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount>>& addressIndex,
|
||||
int start = 0, int end = 0);
|
||||
const int32_t start = 0, const int32_t end = 0);
|
||||
|
||||
bool WriteTimestampIndex(const CTimestampIndexKey& timestampIndex);
|
||||
bool EraseTimestampIndex(const CTimestampIndexKey& timestampIndex);
|
||||
bool ReadTimestampIndex(const unsigned int &high, const unsigned int &low, std::vector<uint256> &vect);
|
||||
bool ReadTimestampIndex(const uint32_t high, const uint32_t low, std::vector<uint256>& hashes);
|
||||
|
||||
bool WriteFlag(const std::string &name, bool fValue);
|
||||
bool ReadFlag(const std::string &name, bool &fValue);
|
||||
bool LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user