Skip to content

Commit fd44ac1

Browse files
committed
[Wallet] Rename std::pair<const CWalletTx*, unsigned int> to CInputCoin
1 parent df1ca9e commit fd44ac1

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/bench/coin_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void CoinSelection(benchmark::State& state)
4848
addCoin(1000 * COIN, wallet, vCoins);
4949
addCoin(3 * COIN, wallet, vCoins);
5050

51-
std::set<std::pair<const CWalletTx*, unsigned int> > setCoinsRet;
51+
std::set<CInputCoin> setCoinsRet;
5252
CAmount nValueRet;
5353
bool success = wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, 0, vCoins, setCoinsRet, nValueRet);
5454
assert(success);

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *pWallet)
2424
{
2525
CMutableTransaction txNew(tx);
26-
std::vector<std::pair<const CWalletTx *, unsigned int>> vCoins;
26+
std::vector<CInputCoin> vCoins;
2727
// Look up the inputs. We should have already checked that this transaction
2828
// IsAllFromMe(ISMINE_SPENDABLE), so every input should already be in our
2929
// wallet, with a valid index into the vout array.

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern UniValue importmulti(const JSONRPCRequest& request);
2929

3030
std::vector<std::unique_ptr<CWalletTx>> wtxn;
3131

32-
typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinSet;
32+
typedef std::set<CInputCoin> CoinSet;
3333

3434
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
3535

src/wallet/wallet.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ const uint256 CMerkleTx::ABANDON_HASH(uint256S("00000000000000000000000000000000
6565

6666
struct CompareValueOnly
6767
{
68-
bool operator()(const std::pair<CAmount, std::pair<const CWalletTx*, unsigned int> >& t1,
69-
const std::pair<CAmount, std::pair<const CWalletTx*, unsigned int> >& t2) const
68+
bool operator()(const std::pair<CAmount, CInputCoin>& t1,
69+
const std::pair<CAmount, CInputCoin>& t2) const
7070
{
7171
return t1.first < t2.first;
7272
}
@@ -2032,7 +2032,7 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlySafe, const
20322032
}
20332033
}
20342034

2035-
static void ApproximateBestSubset(const std::vector<std::pair<CAmount, std::pair<const CWalletTx*,unsigned int> > >& vValue, const CAmount& nTotalLower, const CAmount& nTargetValue,
2035+
static void ApproximateBestSubset(const std::vector<std::pair<CAmount, CInputCoin> >& vValue, const CAmount& nTotalLower, const CAmount& nTargetValue,
20362036
std::vector<char>& vfBest, CAmount& nBest, int iterations = 1000)
20372037
{
20382038
std::vector<char> vfIncluded;
@@ -2079,16 +2079,16 @@ static void ApproximateBestSubset(const std::vector<std::pair<CAmount, std::pair
20792079
}
20802080

20812081
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMine, const int nConfTheirs, const uint64_t nMaxAncestors, std::vector<COutput> vCoins,
2082-
std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const
2082+
std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet) const
20832083
{
20842084
setCoinsRet.clear();
20852085
nValueRet = 0;
20862086

20872087
// List of values less than target
2088-
std::pair<CAmount, std::pair<const CWalletTx*,unsigned int> > coinLowestLarger;
2088+
std::pair<CAmount, CInputCoin> coinLowestLarger;
20892089
coinLowestLarger.first = std::numeric_limits<CAmount>::max();
20902090
coinLowestLarger.second.first = NULL;
2091-
std::vector<std::pair<CAmount, std::pair<const CWalletTx*,unsigned int> > > vValue;
2091+
std::vector<std::pair<CAmount, CInputCoin> > vValue;
20922092
CAmount nTotalLower = 0;
20932093

20942094
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
@@ -2109,7 +2109,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
21092109
int i = output.i;
21102110
CAmount n = pcoin->tx->vout[i].nValue;
21112111

2112-
std::pair<CAmount,std::pair<const CWalletTx*,unsigned int> > coin = std::make_pair(n,std::make_pair(pcoin, i));
2112+
std::pair<CAmount,CInputCoin> coin = std::make_pair(n,std::make_pair(pcoin, i));
21132113

21142114
if (n == nTargetValue)
21152115
{
@@ -2187,7 +2187,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
21872187
return true;
21882188
}
21892189

2190-
bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const
2190+
bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const
21912191
{
21922192
std::vector<COutput> vCoins(vAvailableCoins);
21932193

@@ -2205,7 +2205,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
22052205
}
22062206

22072207
// calculate value from preset inputs and store them
2208-
std::set<std::pair<const CWalletTx*, uint32_t> > setPresetCoins;
2208+
std::set<CInputCoin> setPresetCoins;
22092209
CAmount nValueFromPresetInputs = 0;
22102210

22112211
std::vector<COutPoint> vPresetInputs;
@@ -2395,7 +2395,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
23952395
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);
23962396

23972397
{
2398-
std::set<std::pair<const CWalletTx*,unsigned int> > setCoins;
2398+
std::set<CInputCoin> setCoins;
23992399
LOCK2(cs_main, cs_wallet);
24002400
{
24012401
std::vector<COutput> vAvailableCoins;

src/wallet/wallet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ class CWalletTx : public CMerkleTx
475475
};
476476

477477

478-
478+
using CInputCoin = std::pair<const CWalletTx*, unsigned int>;
479479

480480
class COutput
481481
{
@@ -632,7 +632,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
632632
* all coins from coinControl are selected; Never select unconfirmed coins
633633
* if they are not ours
634634
*/
635-
bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL) const;
635+
bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL) const;
636636

637637
CWalletDB *pwalletdbEncryption;
638638

@@ -780,7 +780,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
780780
* completion the coin set and corresponding actual target value is
781781
* assembled
782782
*/
783-
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, uint64_t nMaxAncestors, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
783+
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, uint64_t nMaxAncestors, std::vector<COutput> vCoins, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet) const;
784784

785785
bool IsSpent(const uint256& hash, unsigned int n) const;
786786

0 commit comments

Comments
 (0)