@@ -548,16 +548,13 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
548
548
bucketMap[INF_FEERATE] = bucketIndex;
549
549
assert (bucketMap.size () == buckets.size ());
550
550
551
- feeStats = new TxConfirmStats (buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE);
552
- shortStats = new TxConfirmStats (buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE);
553
- longStats = new TxConfirmStats (buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE);
551
+ feeStats = std::unique_ptr<TxConfirmStats>( new TxConfirmStats (buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE) );
552
+ shortStats = std::unique_ptr<TxConfirmStats>( new TxConfirmStats (buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE) );
553
+ longStats = std::unique_ptr<TxConfirmStats>( new TxConfirmStats (buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE) );
554
554
}
555
555
556
556
CBlockPolicyEstimator::~CBlockPolicyEstimator ()
557
557
{
558
- delete feeStats;
559
- delete shortStats;
560
- delete longStats;
561
558
}
562
559
563
560
void CBlockPolicyEstimator::processTransaction (const CTxMemPoolEntry& entry, bool validFeeEstimate)
@@ -690,16 +687,16 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
690
687
double sufficientTxs = SUFFICIENT_FEETXS;
691
688
switch (horizon) {
692
689
case FeeEstimateHorizon::SHORT_HALFLIFE: {
693
- stats = shortStats;
690
+ stats = shortStats. get () ;
694
691
sufficientTxs = SUFFICIENT_TXS_SHORT;
695
692
break ;
696
693
}
697
694
case FeeEstimateHorizon::MED_HALFLIFE: {
698
- stats = feeStats;
695
+ stats = feeStats. get () ;
699
696
break ;
700
697
}
701
698
case FeeEstimateHorizon::LONG_HALFLIFE: {
702
- stats = longStats;
699
+ stats = longStats. get () ;
703
700
break ;
704
701
}
705
702
default : {
@@ -1002,12 +999,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
1002
999
}
1003
1000
1004
1001
// Destroy old TxConfirmStats and point to new ones that already reference buckets and bucketMap
1005
- delete feeStats;
1006
- delete shortStats;
1007
- delete longStats;
1008
- feeStats = fileFeeStats.release ();
1009
- shortStats = fileShortStats.release ();
1010
- longStats = fileLongStats.release ();
1002
+ feeStats = std::move (fileFeeStats);
1003
+ shortStats = std::move (fileShortStats);
1004
+ longStats = std::move (fileLongStats);
1011
1005
1012
1006
nBestSeenHeight = nFileBestSeenHeight;
1013
1007
historicalFirst = nFileHistoricalFirst;
0 commit comments