mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
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.
|
||||
|
||||
#include "chain.h"
|
||||
#include "coinbase-payee.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -15,10 +16,17 @@ 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;
|
||||
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);
|
||||
}
|
||||
|
||||
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");
|
||||
return;
|
||||
} else if(bForced) {
|
||||
LogPrintf("CCoinbasePayee::BuildIndex - Rebuilding coinbase cache\n");
|
||||
mapPaidTime.clear();
|
||||
}
|
||||
|
||||
//scan last 30 days worth of blocks, run processBlockCoinbaseTX for each
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
mapPaidTime.clear();
|
||||
}
|
||||
|
||||
void BuildIndex();
|
||||
void BuildIndex(bool bForced=false);
|
||||
void ProcessBlockCoinbaseTX(CTransaction& txCoinbase, int64_t nTime);
|
||||
int64_t GetLastPaid(CScript& pubkey);
|
||||
void CleanUp();
|
||||
|
Loading…
Reference in New Issue
Block a user