mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 09:42:17 +01:00
Merge bitcoin/bitcoin#32882: index: remove unnecessary locator cleaning in BaseIndex::Init()
facd01e6ffrefactor: remove redundant locator cleanup in BaseIndex::Init() (Hao Xu) Pull request description: Leverage locator.IsNull() to simplify ReadBestBlock() and remove unnecessary SetNull(). ACKs for top commit: l0rinc: ACKfacd01e6fffurszy: utACKfacd01e6ffsedited: ACKfacd01e6ffTree-SHA512: ca418a3d4c72b9bfdb194e03d5acfacf7b567850ab385ad3a1ec6d070eedef4aea2bb8335f8bfe0316e84c22583111fc202f7603044c5d4d05754db23f75b47f
This commit is contained in:
@@ -73,13 +73,16 @@ BaseIndex::DB::DB(const fs::path& path, size_t n_cache_size, bool f_memory, bool
|
||||
.options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()}}
|
||||
{}
|
||||
|
||||
bool BaseIndex::DB::ReadBestBlock(CBlockLocator& locator) const
|
||||
CBlockLocator BaseIndex::DB::ReadBestBlock() const
|
||||
{
|
||||
CBlockLocator locator;
|
||||
|
||||
bool success = Read(DB_BEST_BLOCK, locator);
|
||||
if (!success) {
|
||||
locator.SetNull();
|
||||
}
|
||||
return success;
|
||||
|
||||
return locator;
|
||||
}
|
||||
|
||||
void BaseIndex::DB::WriteBestBlock(CDBBatch& batch, const CBlockLocator& locator)
|
||||
@@ -111,10 +114,7 @@ bool BaseIndex::Init()
|
||||
// callbacks are not missed once m_synced is true.
|
||||
m_chain->context()->validation_signals->RegisterValidationInterface(this);
|
||||
|
||||
CBlockLocator locator;
|
||||
if (!GetDB().ReadBestBlock(locator)) {
|
||||
locator.SetNull();
|
||||
}
|
||||
const auto locator{GetDB().ReadBestBlock()};
|
||||
|
||||
LOCK(cs_main);
|
||||
CChain& index_chain = m_chainstate->m_chain;
|
||||
|
||||
Reference in New Issue
Block a user