Rebuild coinbase cache when needed
This commit is contained in:
parent
b8d5a3ce6b
commit
b04ffb923c
@ -4,6 +4,7 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "chain.h"
|
#include "chain.h"
|
||||||
|
#include "coinbase-payee.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -15,10 +16,17 @@ 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;
|
||||||
|
nChainSwitch++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//recalculate the coinbase payee cache if needed
|
||||||
|
if(nChainSwitch > 0) {
|
||||||
|
coinbasePayee.BuildIndex(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,11 +169,14 @@ void DumpCoinbasePayees()
|
|||||||
LogPrintf("Coinbase payee dump finished %dms\n", GetTimeMillis() - nStart);
|
LogPrintf("Coinbase payee dump finished %dms\n", GetTimeMillis() - nStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoinbasePayee::BuildIndex()
|
void CCoinbasePayee::BuildIndex(bool bForced)
|
||||||
{
|
{
|
||||||
if(mapPaidTime.size() > 0) {
|
if(mapPaidTime.size() > 0 && !bForced) {
|
||||||
LogPrintf("CCoinbasePayee::BuildIndex - coinbase cache exists, skipping BuildIndex\n");
|
LogPrintf("CCoinbasePayee::BuildIndex - coinbase cache exists, skipping BuildIndex\n");
|
||||||
return;
|
return;
|
||||||
|
} else if(bForced) {
|
||||||
|
LogPrintf("CCoinbasePayee::BuildIndex - Rebuilding coinbase cache\n");
|
||||||
|
mapPaidTime.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//scan last 30 days worth of blocks, run processBlockCoinbaseTX for each
|
//scan last 30 days worth of blocks, run processBlockCoinbaseTX for each
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
mapPaidTime.clear();
|
mapPaidTime.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildIndex();
|
void BuildIndex(bool bForced=false);
|
||||||
void ProcessBlockCoinbaseTX(CTransaction& txCoinbase, int64_t nTime);
|
void ProcessBlockCoinbaseTX(CTransaction& txCoinbase, int64_t nTime);
|
||||||
int64_t GetLastPaid(CScript& pubkey);
|
int64_t GetLastPaid(CScript& pubkey);
|
||||||
void CleanUp();
|
void CleanUp();
|
||||||
|
Loading…
Reference in New Issue
Block a user