|
|
@ -3478,48 +3478,43 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c |
|
|
|
unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const |
|
|
|
unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int nTimeSmart = wtx.nTimeReceived; |
|
|
|
unsigned int nTimeSmart = wtx.nTimeReceived; |
|
|
|
if (!wtx.hashUnset()) |
|
|
|
if (!wtx.hashUnset()) { |
|
|
|
{ |
|
|
|
if (mapBlockIndex.count(wtx.hashBlock)) { |
|
|
|
if (mapBlockIndex.count(wtx.hashBlock)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int64_t latestNow = wtx.nTimeReceived; |
|
|
|
int64_t latestNow = wtx.nTimeReceived; |
|
|
|
int64_t latestEntry = 0; |
|
|
|
int64_t latestEntry = 0; |
|
|
|
{ |
|
|
|
|
|
|
|
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
|
|
|
|
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
|
|
|
|
int64_t latestTolerated = latestNow + 300; |
|
|
|
int64_t latestTolerated = latestNow + 300; |
|
|
|
const TxItems & txOrdered = wtxOrdered; |
|
|
|
const TxItems& txOrdered = wtxOrdered; |
|
|
|
for (TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) |
|
|
|
for (auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { |
|
|
|
{ |
|
|
|
CWalletTx* const pwtx = it->second.first; |
|
|
|
CWalletTx *const pwtx = (*it).second.first; |
|
|
|
if (pwtx == &wtx) { |
|
|
|
if (pwtx == &wtx) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
CAccountingEntry *const pacentry = (*it).second.second; |
|
|
|
CAccountingEntry* const pacentry = it->second.second; |
|
|
|
int64_t nSmartTime; |
|
|
|
int64_t nSmartTime; |
|
|
|
if (pwtx) |
|
|
|
if (pwtx) { |
|
|
|
{ |
|
|
|
nSmartTime = pwtx->nTimeSmart; |
|
|
|
nSmartTime = pwtx->nTimeSmart; |
|
|
|
if (!nSmartTime) { |
|
|
|
if (!nSmartTime) |
|
|
|
nSmartTime = pwtx->nTimeReceived; |
|
|
|
nSmartTime = pwtx->nTimeReceived; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
} else { |
|
|
|
nSmartTime = pacentry->nTime; |
|
|
|
nSmartTime = pacentry->nTime; |
|
|
|
if (nSmartTime <= latestTolerated) |
|
|
|
} |
|
|
|
{ |
|
|
|
if (nSmartTime <= latestTolerated) { |
|
|
|
latestEntry = nSmartTime; |
|
|
|
latestEntry = nSmartTime; |
|
|
|
if (nSmartTime > latestNow) |
|
|
|
if (nSmartTime > latestNow) { |
|
|
|
latestNow = nSmartTime; |
|
|
|
latestNow = nSmartTime; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t blocktime = mapBlockIndex[wtx.hashBlock]->GetBlockTime(); |
|
|
|
int64_t blocktime = mapBlockIndex[wtx.hashBlock]->GetBlockTime(); |
|
|
|
nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow)); |
|
|
|
nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
LogPrintf("%s: found %s in block %s not in index\n", __func__, wtx.GetHash().ToString(), wtx.hashBlock.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
LogPrintf("AddToWallet(): found %s in block %s not in index\n", |
|
|
|
|
|
|
|
wtx.GetHash().ToString(), |
|
|
|
|
|
|
|
wtx.hashBlock.ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return nTimeSmart; |
|
|
|
return nTimeSmart; |
|
|
|
} |
|
|
|
} |
|
|
|