rebuild index when switching chains
This commit is contained in:
parent
2e6eb9f2b6
commit
143c80789c
@ -16,11 +16,18 @@ void CChain::SetTip(CBlockIndex *pindex) {
|
|||||||
vChain.clear();
|
vChain.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int nChainSwitch = 0;
|
||||||
vChain.resize(pindex->nHeight + 1);
|
vChain.resize(pindex->nHeight + 1);
|
||||||
while (pindex && vChain[pindex->nHeight] != pindex) {
|
while (pindex && vChain[pindex->nHeight] != pindex) {
|
||||||
vChain[pindex->nHeight] = pindex;
|
vChain[pindex->nHeight] = pindex;
|
||||||
pindex = pindex->pprev;
|
pindex = pindex->pprev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//recalculate the coinbase payee cache if needed
|
||||||
|
if(nChainSwitch > 1) {
|
||||||
|
coinbasePayee.BuildIndex(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
|
CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user