From 143c80789cb67e42569e97aaf4163e8ef10d71c5 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Sun, 19 Jul 2015 06:45:35 -0700 Subject: [PATCH] rebuild index when switching chains --- src/chain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/chain.cpp b/src/chain.cpp index 3d434c6c7..4a98af371 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -16,11 +16,18 @@ void CChain::SetTip(CBlockIndex *pindex) { vChain.clear(); return; } + int nChainSwitch = 0; vChain.resize(pindex->nHeight + 1); while (pindex && vChain[pindex->nHeight] != pindex) { vChain[pindex->nHeight] = pindex; pindex = pindex->pprev; } + + //recalculate the coinbase payee cache if needed + if(nChainSwitch > 1) { + coinbasePayee.BuildIndex(true); + } + } CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {