Refactor/encapsulate chain globals into a CChain class
This commit is contained in:
@@ -799,7 +799,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
// no need to read and scan block, if block was created before
|
||||
// our wallet birthday (as adjusted for block time variability)
|
||||
if (nTimeFirstKey && (pindex->nTime < (nTimeFirstKey - 7200))) {
|
||||
pindex = pindex->GetNextInMainChain();
|
||||
pindex = chainActive.Next(pindex);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
if (AddToWalletIfInvolvingMe(tx.GetHash(), tx, &block, fUpdate))
|
||||
ret++;
|
||||
}
|
||||
pindex = pindex->GetNextInMainChain();
|
||||
pindex = chainActive.Next(pindex);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -864,7 +864,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
if (fMissing)
|
||||
{
|
||||
// TODO: optimize this to scan just part of the block chain?
|
||||
if (ScanForWalletTransactions(pindexGenesisBlock))
|
||||
if (ScanForWalletTransactions(chainActive.Genesis()))
|
||||
fRepeat = true; // Found missing transactions: re-do re-accept.
|
||||
}
|
||||
}
|
||||
@@ -1933,7 +1933,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64> &mapKeyBirth) const {
|
||||
mapKeyBirth[it->first] = it->second.nCreateTime;
|
||||
|
||||
// map in which we'll infer heights of other keys
|
||||
CBlockIndex *pindexMax = FindBlockByHeight(std::max(0, nBestHeight - 144)); // the tip can be reorganised; use a 144-block safety margin
|
||||
CBlockIndex *pindexMax = chainActive[std::max(0, chainActive.Height() - 144)]; // the tip can be reorganised; use a 144-block safety margin
|
||||
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock;
|
||||
std::set<CKeyID> setKeys;
|
||||
GetKeys(setKeys);
|
||||
@@ -1953,7 +1953,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64> &mapKeyBirth) const {
|
||||
// iterate over all wallet transactions...
|
||||
const CWalletTx &wtx = (*it).second;
|
||||
std::map<uint256, CBlockIndex*>::const_iterator blit = mapBlockIndex.find(wtx.hashBlock);
|
||||
if (blit != mapBlockIndex.end() && blit->second->IsInMainChain()) {
|
||||
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
|
||||
// ... which are already in a block
|
||||
int nHeight = blit->second->nHeight;
|
||||
BOOST_FOREACH(const CTxOut &txout, wtx.vout) {
|
||||
|
||||
Reference in New Issue
Block a user