Refactor/encapsulate chain globals into a CChain class
This commit is contained in:
@@ -42,7 +42,7 @@ int ClientModel::getNumConnections() const
|
||||
|
||||
int ClientModel::getNumBlocks() const
|
||||
{
|
||||
return nBestHeight;
|
||||
return chainActive.Height();
|
||||
}
|
||||
|
||||
int ClientModel::getNumBlocksAtStartup()
|
||||
@@ -53,8 +53,8 @@ int ClientModel::getNumBlocksAtStartup()
|
||||
|
||||
QDateTime ClientModel::getLastBlockDate() const
|
||||
{
|
||||
if (pindexBest)
|
||||
return QDateTime::fromTime_t(pindexBest->GetBlockTime());
|
||||
if (chainActive.Tip())
|
||||
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
|
||||
else if(!isTestNet())
|
||||
return QDateTime::fromTime_t(1231006505); // Genesis block's time
|
||||
else
|
||||
@@ -63,7 +63,7 @@ QDateTime ClientModel::getLastBlockDate() const
|
||||
|
||||
double ClientModel::getVerificationProgress() const
|
||||
{
|
||||
return Checkpoints::GuessVerificationProgress(pindexBest);
|
||||
return Checkpoints::GuessVerificationProgress(chainActive.Tip());
|
||||
}
|
||||
|
||||
void ClientModel::updateTimer()
|
||||
|
||||
@@ -17,7 +17,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
|
||||
if (!IsFinalTx(wtx))
|
||||
{
|
||||
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||
return tr("Open for %n more block(s)", "", wtx.nLockTime - nBestHeight + 1);
|
||||
return tr("Open for %n more block(s)", "", wtx.nLockTime - chainActive.Height() + 1);
|
||||
else
|
||||
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime));
|
||||
}
|
||||
|
||||
@@ -160,14 +160,14 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
idx);
|
||||
status.confirmed = wtx.IsConfirmed();
|
||||
status.depth = wtx.GetDepthInMainChain();
|
||||
status.cur_num_blocks = nBestHeight;
|
||||
status.cur_num_blocks = chainActive.Height();
|
||||
|
||||
if (!IsFinalTx(wtx))
|
||||
{
|
||||
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||
{
|
||||
status.status = TransactionStatus::OpenUntilBlock;
|
||||
status.open_for = wtx.nLockTime - nBestHeight + 1;
|
||||
status.open_for = wtx.nLockTime - chainActive.Height() + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -221,7 +221,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
|
||||
bool TransactionRecord::statusUpdateNeeded()
|
||||
{
|
||||
return status.cur_num_blocks != nBestHeight;
|
||||
return status.cur_num_blocks != chainActive.Height();
|
||||
}
|
||||
|
||||
QString TransactionRecord::getTxID() const
|
||||
|
||||
@@ -250,9 +250,9 @@ void TransactionTableModel::updateTransaction(const QString &hash, int status)
|
||||
|
||||
void TransactionTableModel::updateConfirmations()
|
||||
{
|
||||
if(nBestHeight != cachedNumBlocks)
|
||||
if(chainActive.Height() != cachedNumBlocks)
|
||||
{
|
||||
cachedNumBlocks = nBestHeight;
|
||||
cachedNumBlocks = chainActive.Height();
|
||||
// Blocks came in since last poll.
|
||||
// Invalidate status (number of confirmations) and (possibly) description
|
||||
// for all rows. Qt is smart enough to only actually request the data for the
|
||||
|
||||
@@ -73,10 +73,10 @@ void WalletModel::updateStatus()
|
||||
|
||||
void WalletModel::pollBalanceChanged()
|
||||
{
|
||||
if(nBestHeight != cachedNumBlocks)
|
||||
if(chainActive.Height() != cachedNumBlocks)
|
||||
{
|
||||
// Balance and number of transactions might have changed
|
||||
cachedNumBlocks = nBestHeight;
|
||||
cachedNumBlocks = chainActive.Height();
|
||||
checkBalanceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user