07620746a5
This fixes a bug in ScanQuorums which made it return quorums which were not mined at the time of pindexStart. This was due to quorumHashes being based on older blocks (the phase=0 block) which are ancestors of pindexStart even if the commitment was actually mined in a later block. GetMinedAndActiveCommitmentsUntilBlock is also going to be used for quorum commitment merkle roots in CCbTx. This also removes GetFirstMinedQuorumHash as it's not needed anymore.
85 lines
1.8 KiB
C++
85 lines
1.8 KiB
C++
// Copyright (c) 2018 The Dash Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef DASH_EVODB_H
|
|
#define DASH_EVODB_H
|
|
|
|
#include "dbwrapper.h"
|
|
#include "sync.h"
|
|
#include "uint256.h"
|
|
|
|
static const std::string EVODB_BEST_BLOCK = "b_b";
|
|
|
|
class CEvoDB
|
|
{
|
|
private:
|
|
CCriticalSection cs;
|
|
CDBWrapper db;
|
|
|
|
typedef CDBTransaction<CDBWrapper, CDBBatch> RootTransaction;
|
|
typedef CDBTransaction<RootTransaction, RootTransaction> CurTransaction;
|
|
typedef CScopedDBTransaction<RootTransaction, RootTransaction> ScopedTransaction;
|
|
|
|
CDBBatch rootBatch;
|
|
RootTransaction rootDBTransaction;
|
|
CurTransaction curDBTransaction;
|
|
|
|
public:
|
|
CEvoDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
|
|
|
std::unique_ptr<ScopedTransaction> BeginTransaction()
|
|
{
|
|
LOCK(cs);
|
|
auto t = ScopedTransaction::Begin(curDBTransaction);
|
|
return t;
|
|
}
|
|
|
|
CurTransaction& GetCurTransaction()
|
|
{
|
|
return curDBTransaction;
|
|
}
|
|
|
|
template <typename K, typename V>
|
|
bool Read(const K& key, V& value)
|
|
{
|
|
LOCK(cs);
|
|
return curDBTransaction.Read(key, value);
|
|
}
|
|
|
|
template <typename K, typename V>
|
|
void Write(const K& key, const V& value)
|
|
{
|
|
LOCK(cs);
|
|
curDBTransaction.Write(key, value);
|
|
}
|
|
|
|
template <typename K>
|
|
bool Exists(const K& key)
|
|
{
|
|
LOCK(cs);
|
|
return curDBTransaction.Exists(key);
|
|
}
|
|
|
|
template <typename K>
|
|
void Erase(const K& key)
|
|
{
|
|
LOCK(cs);
|
|
curDBTransaction.Erase(key);
|
|
}
|
|
|
|
CDBWrapper& GetRawDB()
|
|
{
|
|
return db;
|
|
}
|
|
|
|
bool CommitRootTransaction();
|
|
|
|
bool VerifyBestBlock(const uint256& hash);
|
|
void WriteBestBlock(const uint256& hash);
|
|
};
|
|
|
|
extern CEvoDB* evoDb;
|
|
|
|
#endif //DASH_EVODB_H
|