mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
Replace lock with thread safety annotation in CBlockTreeDB::LoadBlockIndexGuts()
This commit is contained in:
parent
d4e92d8436
commit
20276ca5d1
2 changed files with 7 additions and 9 deletions
13
src/txdb.cpp
13
src/txdb.cpp
|
@ -296,8 +296,8 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
||||||
|
|
||||||
bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(::cs_main);
|
||||||
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
std::unique_ptr<CDBIterator> pcursor(NewIterator());
|
||||||
|
|
||||||
pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256()));
|
pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256()));
|
||||||
|
|
||||||
// Load m_block_index
|
// Load m_block_index
|
||||||
|
@ -311,19 +311,16 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
|
||||||
CBlockIndex* pindexNew = insertBlockIndex(diskindex.GetBlockHash());
|
CBlockIndex* pindexNew = insertBlockIndex(diskindex.GetBlockHash());
|
||||||
pindexNew->pprev = insertBlockIndex(diskindex.hashPrev);
|
pindexNew->pprev = insertBlockIndex(diskindex.hashPrev);
|
||||||
pindexNew->nHeight = diskindex.nHeight;
|
pindexNew->nHeight = diskindex.nHeight;
|
||||||
|
pindexNew->nFile = diskindex.nFile;
|
||||||
|
pindexNew->nDataPos = diskindex.nDataPos;
|
||||||
|
pindexNew->nUndoPos = diskindex.nUndoPos;
|
||||||
pindexNew->nVersion = diskindex.nVersion;
|
pindexNew->nVersion = diskindex.nVersion;
|
||||||
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
|
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
|
||||||
pindexNew->nTime = diskindex.nTime;
|
pindexNew->nTime = diskindex.nTime;
|
||||||
pindexNew->nBits = diskindex.nBits;
|
pindexNew->nBits = diskindex.nBits;
|
||||||
pindexNew->nNonce = diskindex.nNonce;
|
pindexNew->nNonce = diskindex.nNonce;
|
||||||
pindexNew->nTx = diskindex.nTx;
|
|
||||||
{
|
|
||||||
LOCK(::cs_main);
|
|
||||||
pindexNew->nFile = diskindex.nFile;
|
|
||||||
pindexNew->nDataPos = diskindex.nDataPos;
|
|
||||||
pindexNew->nUndoPos = diskindex.nUndoPos;
|
|
||||||
pindexNew->nStatus = diskindex.nStatus;
|
pindexNew->nStatus = diskindex.nStatus;
|
||||||
}
|
pindexNew->nTx = diskindex.nTx;
|
||||||
|
|
||||||
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams)) {
|
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams)) {
|
||||||
return error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());
|
return error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());
|
||||||
|
|
|
@ -86,7 +86,8 @@ public:
|
||||||
void ReadReindexing(bool &fReindexing);
|
void ReadReindexing(bool &fReindexing);
|
||||||
bool WriteFlag(const std::string &name, bool fValue);
|
bool WriteFlag(const std::string &name, bool fValue);
|
||||||
bool ReadFlag(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);
|
bool LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<bilingual_str> CheckLegacyTxindex(CBlockTreeDB& block_tree_db);
|
std::optional<bilingual_str> CheckLegacyTxindex(CBlockTreeDB& block_tree_db);
|
||||||
|
|
Loading…
Add table
Reference in a new issue