Skip to content

Commit 630fc54

Browse files
committed
Clean up braces in CWallet::ComputeTimeSmart
1 parent 6c996c2 commit 630fc54

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

src/wallet/wallet.cpp

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,48 +3478,43 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c
34783478
unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
34793479
{
34803480
unsigned int nTimeSmart = wtx.nTimeReceived;
3481-
if (!wtx.hashUnset())
3482-
{
3483-
if (mapBlockIndex.count(wtx.hashBlock))
3484-
{
3481+
if (!wtx.hashUnset()) {
3482+
if (mapBlockIndex.count(wtx.hashBlock)) {
34853483
int64_t latestNow = wtx.nTimeReceived;
34863484
int64_t latestEntry = 0;
3487-
{
3488-
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
3489-
int64_t latestTolerated = latestNow + 300;
3490-
const TxItems & txOrdered = wtxOrdered;
3491-
for (TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
3492-
{
3493-
CWalletTx *const pwtx = (*it).second.first;
3494-
if (pwtx == &wtx)
3495-
continue;
3496-
CAccountingEntry *const pacentry = (*it).second.second;
3497-
int64_t nSmartTime;
3498-
if (pwtx)
3499-
{
3500-
nSmartTime = pwtx->nTimeSmart;
3501-
if (!nSmartTime)
3502-
nSmartTime = pwtx->nTimeReceived;
3485+
3486+
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
3487+
int64_t latestTolerated = latestNow + 300;
3488+
const TxItems& txOrdered = wtxOrdered;
3489+
for (auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) {
3490+
CWalletTx* const pwtx = it->second.first;
3491+
if (pwtx == &wtx) {
3492+
continue;
3493+
}
3494+
CAccountingEntry* const pacentry = it->second.second;
3495+
int64_t nSmartTime;
3496+
if (pwtx) {
3497+
nSmartTime = pwtx->nTimeSmart;
3498+
if (!nSmartTime) {
3499+
nSmartTime = pwtx->nTimeReceived;
35033500
}
3504-
else
3505-
nSmartTime = pacentry->nTime;
3506-
if (nSmartTime <= latestTolerated)
3507-
{
3508-
latestEntry = nSmartTime;
3509-
if (nSmartTime > latestNow)
3510-
latestNow = nSmartTime;
3511-
break;
3501+
} else {
3502+
nSmartTime = pacentry->nTime;
3503+
}
3504+
if (nSmartTime <= latestTolerated) {
3505+
latestEntry = nSmartTime;
3506+
if (nSmartTime > latestNow) {
3507+
latestNow = nSmartTime;
35123508
}
3509+
break;
35133510
}
35143511
}
35153512

35163513
int64_t blocktime = mapBlockIndex[wtx.hashBlock]->GetBlockTime();
35173514
nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));
3515+
} else {
3516+
LogPrintf("%s: found %s in block %s not in index\n", __func__, wtx.GetHash().ToString(), wtx.hashBlock.ToString());
35183517
}
3519-
else
3520-
LogPrintf("AddToWallet(): found %s in block %s not in index\n",
3521-
wtx.GetHash().ToString(),
3522-
wtx.hashBlock.ToString());
35233518
}
35243519
return nTimeSmart;
35253520
}

0 commit comments

Comments
 (0)