mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
Remove unused SetTip(nullptr) code
This commit is contained in:
parent
816ca01650
commit
faab8dceb3
5 changed files with 15 additions and 16 deletions
|
@ -18,11 +18,9 @@ std::string CBlockIndex::ToString() const
|
|||
pprev, nHeight, hashMerkleRoot.ToString(), GetBlockHash().ToString());
|
||||
}
|
||||
|
||||
void CChain::SetTip(CBlockIndex *pindex) {
|
||||
if (pindex == nullptr) {
|
||||
vChain.clear();
|
||||
return;
|
||||
}
|
||||
void CChain::SetTip(CBlockIndex& block)
|
||||
{
|
||||
CBlockIndex* pindex = █
|
||||
vChain.resize(pindex->nHeight + 1);
|
||||
while (pindex && vChain[pindex->nHeight] != pindex) {
|
||||
vChain[pindex->nHeight] = pindex;
|
||||
|
|
|
@ -465,7 +465,7 @@ public:
|
|||
}
|
||||
|
||||
/** Set/initialize a chain with a given tip. */
|
||||
void SetTip(CBlockIndex* pindex);
|
||||
void SetTip(CBlockIndex& block);
|
||||
|
||||
/** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
|
||||
CBlockLocator GetLocator(const CBlockIndex* pindex = nullptr) const;
|
||||
|
|
|
@ -325,7 +325,7 @@ void MinerTestingSetup::TestBasicMining(const CChainParams& chainparams, const C
|
|||
next->pprev = prev;
|
||||
next->nHeight = prev->nHeight + 1;
|
||||
next->BuildSkip();
|
||||
m_node.chainman->ActiveChain().SetTip(next);
|
||||
m_node.chainman->ActiveChain().SetTip(*next);
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||
// Extend to a 210000-long block chain.
|
||||
|
@ -337,7 +337,7 @@ void MinerTestingSetup::TestBasicMining(const CChainParams& chainparams, const C
|
|||
next->pprev = prev;
|
||||
next->nHeight = prev->nHeight + 1;
|
||||
next->BuildSkip();
|
||||
m_node.chainman->ActiveChain().SetTip(next);
|
||||
m_node.chainman->ActiveChain().SetTip(*next);
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||
|
||||
|
@ -362,7 +362,7 @@ void MinerTestingSetup::TestBasicMining(const CChainParams& chainparams, const C
|
|||
// Delete the dummy blocks again.
|
||||
while (m_node.chainman->ActiveChain().Tip()->nHeight > nHeight) {
|
||||
CBlockIndex* del = m_node.chainman->ActiveChain().Tip();
|
||||
m_node.chainman->ActiveChain().SetTip(del->pprev);
|
||||
m_node.chainman->ActiveChain().SetTip(*Assert(del->pprev));
|
||||
m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(del->pprev->GetBlockHash());
|
||||
delete del->phashBlock;
|
||||
delete del;
|
||||
|
|
|
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(getlocator_test)
|
|||
|
||||
// Build a CChain for the main branch.
|
||||
CChain chain;
|
||||
chain.SetTip(&vBlocksMain.back());
|
||||
chain.SetTip(vBlocksMain.back());
|
||||
|
||||
// Test 100 random starting points for locators.
|
||||
for (int n=0; n<100; n++) {
|
||||
|
@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(findearliestatleast_test)
|
|||
|
||||
// Build a CChain for the main branch.
|
||||
CChain chain;
|
||||
chain.SetTip(&vBlocksMain.back());
|
||||
chain.SetTip(vBlocksMain.back());
|
||||
|
||||
// Verify that FindEarliestAtLeast is correct.
|
||||
for (unsigned int i=0; i<10000; ++i) {
|
||||
|
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(findearliestatleast_edge_test)
|
|||
}
|
||||
|
||||
CChain chain;
|
||||
chain.SetTip(&blocks.back());
|
||||
chain.SetTip(blocks.back());
|
||||
|
||||
BOOST_CHECK_EQUAL(chain.FindEarliestAtLeast(50, 0)->nHeight, 0);
|
||||
BOOST_CHECK_EQUAL(chain.FindEarliestAtLeast(100, 0)->nHeight, 0);
|
||||
|
|
|
@ -2578,6 +2578,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
|
|||
|
||||
CBlockIndex *pindexDelete = m_chain.Tip();
|
||||
assert(pindexDelete);
|
||||
assert(pindexDelete->pprev);
|
||||
// Read block from disk.
|
||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||
CBlock& block = *pblock;
|
||||
|
@ -2625,7 +2626,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
|
|||
}
|
||||
}
|
||||
|
||||
m_chain.SetTip(pindexDelete->pprev);
|
||||
m_chain.SetTip(*pindexDelete->pprev);
|
||||
|
||||
UpdateTip(pindexDelete->pprev);
|
||||
// Let wallets know transactions went from 1-confirmed to
|
||||
|
@ -2739,7 +2740,7 @@ bool CChainState::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew
|
|||
disconnectpool.removeForBlock(blockConnecting.vtx);
|
||||
}
|
||||
// Update m_chain & related variables.
|
||||
m_chain.SetTip(pindexNew);
|
||||
m_chain.SetTip(*pindexNew);
|
||||
UpdateTip(pindexNew);
|
||||
|
||||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
||||
|
@ -3887,7 +3888,7 @@ bool CChainState::LoadChainTip()
|
|||
if (!pindex) {
|
||||
return false;
|
||||
}
|
||||
m_chain.SetTip(pindex);
|
||||
m_chain.SetTip(*pindex);
|
||||
PruneBlockIndexCandidates();
|
||||
|
||||
tip = m_chain.Tip();
|
||||
|
@ -4964,7 +4965,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
|||
return false;
|
||||
}
|
||||
|
||||
snapshot_chainstate.m_chain.SetTip(snapshot_start_block);
|
||||
snapshot_chainstate.m_chain.SetTip(*snapshot_start_block);
|
||||
|
||||
// The remainder of this function requires modifying data protected by cs_main.
|
||||
LOCK(::cs_main);
|
||||
|
|
Loading…
Add table
Reference in a new issue