@@ -480,9 +480,11 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, CWalletDB* pwalletdb)
480
480
LOCK (cs_wallet);
481
481
// Inserts only if not already there, returns tx inserted or tx found
482
482
pair<map<uint256, CWalletTx>::iterator, bool > ret = mapWallet.insert (make_pair (hash, wtxIn));
483
- CWalletTx& wtx = (* ret.first ). second ;
483
+ CWalletTx& wtx = ret.first -> second ;
484
484
wtx.BindWallet (this );
485
485
bool fInsertedNew = ret.second ;
486
+ bool fUpdated = false ;
487
+
486
488
if (fInsertedNew )
487
489
{
488
490
wtx.nTimeReceived = GetAdjustedTime ();
@@ -494,53 +496,16 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, CWalletDB* pwalletdb)
494
496
auto mapItem = mapBlockIndex.find (wtxIn.hashBlock );
495
497
if (mapItem != mapBlockIndex.end ())
496
498
{
497
- unsigned int latestNow = wtx.nTimeReceived ;
498
- unsigned int latestEntry = 0 ;
499
- {
500
- // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
501
- int64_t latestTolerated = latestNow + 300 ;
502
- std::list<CAccountingEntry> acentries;
503
- TxItems txOrdered = OrderedTxItems (acentries);
504
- for (TxItems::reverse_iterator it = txOrdered.rbegin (); it != txOrdered.rend (); ++it)
505
- {
506
- CWalletTx *const pwtx = (*it).second .first ;
507
- if (pwtx == &wtx)
508
- continue ;
509
- CAccountingEntry *const pacentry = (*it).second .second ;
510
- int64_t nSmartTime;
511
- if (pwtx)
512
- {
513
- nSmartTime = pwtx->nTimeSmart ;
514
- if (!nSmartTime)
515
- nSmartTime = pwtx->nTimeReceived ;
516
- }
517
- else
518
- nSmartTime = pacentry->nTime ;
519
- if (nSmartTime <= latestTolerated)
520
- {
521
- latestEntry = nSmartTime;
522
- if (nSmartTime > latestNow)
523
- latestNow = nSmartTime;
524
- break ;
525
- }
526
- }
527
- }
528
-
529
- unsigned int & blocktime = mapItem->second ->nTime ;
530
- wtx.nTimeSmart = std::max (latestEntry, std::min (blocktime, latestNow));
499
+ wtx.nTimeSmart = mapItem->second ->nTime ;
531
500
}
532
501
else
533
502
{
534
503
LogPrint (BCLog::LogFlags::VERBOSE, " AddToWallet() : found %s in block %s not in index" ,
535
- wtxIn. GetHash () .ToString ().substr (0 ,10 ),
504
+ hash .ToString ().substr (0 ,10 ),
536
505
wtxIn.hashBlock .ToString ());
537
506
}
538
507
}
539
- }
540
-
541
- bool fUpdated = false ;
542
- if (!fInsertedNew )
543
- {
508
+ } else {
544
509
// Merge
545
510
if (!wtxIn.hashBlock .IsNull () && wtxIn.hashBlock != wtx.hashBlock )
546
511
{
@@ -594,7 +559,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, CWalletDB* pwalletdb)
594
559
std::string strCmd = gArgs .GetArg (" -walletnotify" , " " );
595
560
if (!strCmd.empty ())
596
561
{
597
- boost::replace_all (strCmd, " %s" , wtxIn. GetHash () .GetHex ());
562
+ boost::replace_all (strCmd, " %s" , hash .GetHex ());
598
563
boost::thread t (runCommand, strCmd); // thread runs free
599
564
}
600
565
0 commit comments